Hello there. I am new with timers and I want to see timer0 overflowing and the value of TMR0L counting up. I got the code ready but not sure what I am missing. My code is below. Please help !
The main should start with initial value of 250 for TMR0L as long as INTCON.B2 TMR0IF is not set as 1. The TMR0L value should increase upto 255 and then overflow and start again from zero. After main() it should be again set to 255 and the last instruction clears the overflow flag.
The main should start with initial value of 250 for TMR0L as long as INTCON.B2 TMR0IF is not set as 1. The TMR0L value should increase upto 255 and then overflow and start again from zero. After main() it should be again set to 255 and the last instruction clears the overflow flag.
Rich (BB code):
void main() {
TRISA = 0x00; // set direction to be output
TRISB = 0x00; // set direction to be output
TRISC = 0x00; // set direction to be output
TRISD = 0x00; // set direction to be output
T0CON.B7=1;
TMR0L=250;
T0CON.B6=1;
T0CON.B5=0;
T0CON.B3=1;
INTCON.B5=0;
while(INTCON.B2==0);
{
PORTA = 0x00; // Turn OFF LEDs on PORTA
PORTB = 0x00; // Turn OFF LEDs on PORTB
PORTC = 0x00; // Turn OFF LEDs on PORTC
PORTD = 0x00; // Turn OFF LEDs on PORTD
delay_ms(1000);
PORTA = 0xFF; // Turn ON LEDs on PORTA
PORTB = 0xFF; // Turn ON LEDs on PORTB
PORTC = 0xFF; // Turn ON LEDs on PORTC
PORTD = 0xFF; // Turn ON LEDs on PORTD
}
TMR0L=250;
INTCON.B2==0;
}
Last edited by a moderator: