I am working on traffic-light-controller project using PIC18F4550 and cascaded three 74LS164 shift-registers with CCS C programming. I am having a problem with the timing. When I use timer2, as can be seen in the code below, my circuit looses 10mins within 24 hours daily. When I changed to timer0, it lost one hour daily. Can anyone in the forum help with appropriate timer setup configuration? Thank you.
folorunsoa.
//set_timer2(0);
//setup_timer_2(T2_DIV_BY_4,100,10);
//enable_interrupts(INT_TIMER2 );
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32); //1.0 s overflow
enable_interrupts(INT_TIMER0);
enable_interrupts(INT_RB );
enable_interrupts(global);
folorunsoa.
//set_timer2(0);
//setup_timer_2(T2_DIV_BY_4,100,10);
//enable_interrupts(INT_TIMER2 );
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32); //1.0 s overflow
enable_interrupts(INT_TIMER0);
enable_interrupts(INT_RB );
enable_interrupts(global);
Last edited: