Hello, I am trying to blink an led every second using timer 0 of pic18f4550. I am using 16 Mhz crystal and mplab xC8 compiler for programming. The program compiles successfully but the led keeps turned off. I double checked the led, there is nothing wrong with led. Any Idea?
Thanks in advance!
#include <xc.h>
#include <p18f4550.h>
#include <stdint.h>
#define _XTAL_FREQ 16000000 //20 for the Delays
#pragma config FOSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config BOR = OFF
#pragma config MCLRE = ON
#pragma config PWRT = ON
#pragma config PBADEN = OFF
uint8_t tmr0l;
uint8_t tmr0h;
int main(void)
{
INTCON = 0x20;
TMR0H = 0x7a;
TMR0L = 0x12;
tmr0l = TMR0L;
tmr0h = TMR0H;
T0CON = 0x8e;
while(1)
{
while(TMR0IF != 1); {
TMR0IF = 0;
TMR0L = 0x12;
TMR0H = 0x7a;
PORTBbits.RB0 ^= 1;
}
}
return;
}