glenjoy
Banned
- Joined
- Jan 1, 2004
- Messages
- 962
- Helped
- 72
- Reputation
- 146
- Reaction score
- 20
- Trophy points
- 1,298
- Location
- Philippines
- Activity points
- 0
ccs timer interrupt
I am making a speed measurement device.
Speed ranges from 250 fps to 800 fps, so timing is really critical.
I tried using this kind of loop but seems creates some kind of delay, attached is my original code.
I need your help in editing this code by using interrupts, the code creates a delay in display of lcd.
Thanks.
Glenjoy
I am making a speed measurement device.
Speed ranges from 250 fps to 800 fps, so timing is really critical.
I tried using this kind of loop but seems creates some kind of delay, attached is my original code.
Code:
include "C:\Documents and Settings\Glenjoy\My Documents\Chronograph 2\Chronograph.h"
#include <LCD.C>
long micro_S;
long milli_S;
long speed;
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
lcd_init();
setup_oscillator(False);
speed = 0;
set_tris_a(0x03);
// set_tris_b(0x00);
output_b(0x00);
lcd_putc("\f");
lcd_putc("S: ");
for(;;)
{
while(input(PIN_A0)==0);
lcd_putc("\f");
lcd_putc("S: ");
do
{
delay_us(1);
micro_S++;
}while(!input(PIN_A1));
speed = 328080/micro_S;
milli_S = micro_S;
micro_S = 0;
printf(LCD_PUTC, "%Lu",speed);
}
}
I need your help in editing this code by using interrupts, the code creates a delay in display of lcd.
Thanks.
Glenjoy