Hi Dave,
Yes, the LED would toggle every 16384uS, in other words it would blink at rougly 30.5Hz, youll be hard pressed to see that. If you change the prescaler to 1:256 you'll get 4000000/4/256/256/2 = 7.62Hz.
The problem with PBP's way of handling interrupts is that it can not interrupt the command/statement that it is currently executing. Lets say for example that your main routine looks something like this:
Code:
Main:
GPIO.0=1
Pause 500
GPIO.0=0
Pause 500
Goto Main
This would blink a LED connected to GPIO.0 at 1Hz and you would think that the TMR0 interrupts would blink the other LED at 7.62Hz, unfortunatley that's not the case....
In the above code the interrupts generated by TMR0 would only get served between each statement. In other words, during the 0.5 second pauses the 7.62Hz blink would stop.
Basically, what PBP does, under the hood, is to add check after each statement, like:
Code:
Main:
GPIO.0=1
IF Interrupt goto TLOOP 'This is not the actual code it adds, it's just to illustrate the principle
Pause 500
IF Interrupt goto TLOOP
GPIO.0=0
IF Interrupt goto TLOPP
Pause 500
IF Interrupt goto TLOOP
Goto Main
IF Interrupt goto TLOOP
As you can see, if an interrupt occurs in the middle of a Pause it won't get serviced until the Pause statement has finished so if you're using PBP's ON INTERRUPT you need be aware of this. There are other ways to do it which doesn't suffer from the issue described above (Darrels Instant Interrupt routines obviously).
Hope it helps.
/Henrik.
Bookmarks