WStevens_sa
Member level 2
- Joined
- Jan 5, 2011
- Messages
- 47
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- South Africa
- Activity points
- 1,695
Hi Guys
Some where I am doing something wrong. I am trying to get TMR0 interrupt to trigger. RA0 Flashes constantly. When TMR0 triggers it makes RA5 turn on and off then returns back to continue flashing on RA0. At the moment only RA0 is flashing.
Please tell me what I am missing and also what code I dont need.
Some where I am doing something wrong. I am trying to get TMR0 interrupt to trigger. RA0 Flashes constantly. When TMR0 triggers it makes RA5 turn on and off then returns back to continue flashing on RA0. At the moment only RA0 is flashing.
Please tell me what I am missing and also what code I dont need.
Code:
void interrupt(void) {
if(INTCON.T0IF == 1)
{
RA5_bit=1; //To see if interrupt is triggered
Delay_ms(2000);
INTCON.INTF = 0; //You HAVE to clear interrupt flag
}
}
void main()
{
TMR0 = 0; //Clear timer 0
INTCON.T0IF = 0; //clear the interrupt flag
INTCON.T0IE = 0; //enable tmr0 interrupt
INTCON.GIE = 1; //Enable Global Interrupt
OPTION_REG.INTEDG = 1; //Interrupt on rising edge
INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
PORTA = 0; /*set RA0-RA5 low */
TRISA = 0; /*set PORTA to output*/
PORTD = 0; /*set RA0-RA5 low */
TRISD = 0; /*set PORTA to output*/
while(1)
{
RA0_bit=1;
Delay_ms(200);
RA0_bit=0;
Delay_ms(200);
};
}