hemnath
Advanced Member level 3
I'm using internal clock in PIC18F2520 using CCS c compiler. I'm displaying a string "SECONDS" and displays counting numbers from 0,1,2,3...
When i power, it shows "SECONDS 0" in the display and after 18 seconds only, it starts incrementing its value. Why is it so? Please help.. Once it's starts incrementing, it counts for every second,thats normal.
When i power, it shows "SECONDS 0" in the display and after 18 seconds only, it starts incrementing its value. Why is it so? Please help.. Once it's starts incrementing, it counts for every second,thats normal.
HTML:
#include <18F2520.h>
#include <string.h>
#fuses INTRC_IO,NOWDT,NOLVP,PUT
#use delay(clock=31000)
#define EN PIN_A1
#define RS PIN_A2
#define INTS_PER_SECOND 15 //15.1371 // (31000/(4*2*256))
INT16 seconds;
BYTE INT_count;
#INT_rtcc
void clock_isr()
{
if (--INT_count == 0)
{
++seconds;
INT_count = INTS_PER_SECOND;
}
}
void lcd_cmd(CHAR a); // function declaration
void lcd_print(CHAR rstr[]);
CHAR msg[16];
void main ()
{
set_timer0 (0) ;
setup_counters (RTCC_INTERNAL, RTCC_DIV_2|RTCC_8_BIT);
enable_interrupts (INT_RTCC) ;
enable_interrupts (GLOBAL) ;
output_low (RS);//set LCD to command mode
lcd_cmd (0x30);
lcd_cmd (0x01);
lcd_cmd (0x02);
lcd_cmd (0x0c);
lcd_cmd (0x06);
seconds =0;
WHILE (1)
{
output_low (RS);//set LCD to command mode
lcd_cmd (0x02);//move cursor to home position
sprintf (msg, "SECONDS %LU ", seconds ) ;
if (seconds==1)
{
output_high(pin_a3);
}
lcd_print (msg);
}
}
void lcd_cmd(CHAR a)
{
output_b (a);
delay_ms (10);
output_high (EN);
delay_ms (10);
output_low (EN);
}
void lcd_print(CHAR rstr[])
{
INT i;
FOR (i=0; rstr[i]!='\0'; i++)
{
output_high (rs);
lcd_cmd (rstr[i]);
}
}