garagedog
Newbie level 5
- Joined
- Jan 6, 2014
- Messages
- 10
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 88
Hi,
I'm currently trying to use timer0 and interrupts at the same time, what I basically needed was when I press the push button attached to INT2 pin of 18F452 and light an LED connected to DO pin for 1 second, I can do this but when I try to make TMR0IE_bit = 1; the LED keeps lit all the time. Here is my code:
It will be a great help if anybody could tell me how to get this right.
Thanks.
I'm currently trying to use timer0 and interrupts at the same time, what I basically needed was when I press the push button attached to INT2 pin of 18F452 and light an LED connected to DO pin for 1 second, I can do this but when I try to make TMR0IE_bit = 1; the LED keeps lit all the time. Here is my code:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 void interrupt(){ if(INTCON3.INT2IF = 1) { PORTD.LATD0 = 1; Delay_ms(1000); PORTD.LATD0 = 0; INTCON3.INT2IF = 0; } } void main() { T0CON = 0x82; TMR0H = 0x0B; TMR0L = 0xDC; GIE_bit = 1; PEIE_bit = 1; //TMR0IE_bit = 1; //when I uncomment this RD0 keeps high all the time INT2IE_bit = 1; TMR0IP_bit = 0; TRISD.LATD0 = 0; }
It will be a great help if anybody could tell me how to get this right.
Thanks.
Last edited by a moderator: