pebe
Advanced Member level 4
- Joined
- Dec 1, 2008
- Messages
- 116
- Helped
- 18
- Reputation
- 36
- Reaction score
- 18
- Trophy points
- 1,298
- Location
- Scotland
- Activity points
- 1,893
I want to PWM a port of a PIC 12F629. I need a fairly high repetition rate so decided to do it within the timer interrupt sequence.
When the timer interrupt occurs, early in the procedure I turn on the port. Then I compare TMR0 with a reference number (ref) and when they are equal, the port is turned off. Then I exit the routine. As soon as TMR0 overflows there will be another interrupt and the port will turn on again. In that way the on/off ratio is determined by the value of ref/256.
Unfortunately, TMR0 does not seem to change once inside the interrupt routine. Looking at the block diagram in the 12F629 data sheet, I can see no reason why it shouldn’t.
Any ideas?
When the timer interrupt occurs, early in the procedure I turn on the port. Then I compare TMR0 with a reference number (ref) and when they are equal, the port is turned off. Then I exit the routine. As soon as TMR0 overflows there will be another interrupt and the port will turn on again. In that way the on/off ratio is determined by the value of ref/256.
Unfortunately, TMR0 does not seem to change once inside the interrupt routine. Looking at the block diagram in the 12F629 data sheet, I can see no reason why it shouldn’t.
Any ideas?