I am doing a programming on a rpm (revolution per minute) counter for a toy car. When an IR sensor signal input to the PIC, interrupt will be enabled and timer 0 will started to count the rpm and display the value in 16x2 lcd.
The below code shows about the interrupt and timer0:
And the to display the rpm value per minute in lcd, the code is shown below:
The above code are combined together but nothing shown in the lcd.
Can anyone correct my mistakes? Thanks.
The below code shows about the interrupt and timer0:
Code:
#use delay (clock = 20000000)
#include <LCD.C>
#define INTS_PER_MINUTE 153 // (40000000/(4*256*256))
BYTE minutes; // A running minutes counter
BYTE int_count; // Number of interrupts left before a minute has elapsed
#int_rtcc // This function is called every time
void clock_isr() { // the RTCC (timer0) overflows (255->0).
BYTE start;
int_count=INTS_PER_MINUTE;
set_timer0(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT); // For this program this is apx 153 times
if(--int_count==0) { // per minute.
++minutes;
int_count=INTS_PER_MINUTE;
}
}
And the to display the rpm value per minute in lcd, the code is shown below:
Code:
void main ( void )
{
char display [ 4 ];
// Initialization
input(PIN_B0);
output_high(PIN_A0);
output_high(PIN_A1);
output_high(PIN_A2);
output_high(PIN_A3);
output_low(PIN_A4);
output_low(PIN_A5);
lcd_init();
lcd_gotoxy (1,1);
lcd_putc ("RPM:" +minutes );
}
Can anyone correct my mistakes? Thanks.