Hi guys,
Thank you for your replies!
Richard,
Untill now the interrupts have always been enabled though obviously the PWM timebase interrupt isn't generated if the timebase isn't running. What I've done since yesterday is to add code to main routine which once every 1600ms prints the content of DFLTCON, this doesn't work if the PWM timebase isn't on because the 1600ms "tick" is based on that. When the program starts the DFLTCON is set to what is stored in EEPROM (as expected) then the ResetServo routine is called, where DFLTCON somehow gets changed, and then is stays at that value for as long as I leave it on. I've left it for 20min, and at an interrupt rate of 1500Hz that's 1.8 million interrupts, the content of DFLTCON stayed intact.
After those 20 minutes I manually called the ResetServo via the serial console, as Before the content of DFTLCON changed while that routine executed and then it reamains at that new value - whatever it is.
None of the other 20 values I can change via the serial console is misbehaving as far as I've been able to tell - it's only the setting for DFLTCON and again, it's not my variable that's changing it's the actual SFR.
What I've also tried is adding something like the following to main loop:
Code:
If DFLTCON <> EncFilter THEN 'DFTLCON is the SFR, EncFilter is my variable.
Toggle PortC.2
DFLTCON = EncFilter ' Force DFLTCON back to correct value
ENDIF
I've yet to see PortC.2 toggle anytime EXCEPT when ResetServo is called and DFLTCON is NOT written to (by me) from that routine at all - yet it changes.
At this point I'm tempted to just add DFLTCON = EncFilter at the end of the ResetServo subroutine and then just forget about it but there's something strange going on and I don't like it.
The actual interrupt code is a mix between PBP and ASM, it's all "treated" as pure ASM interrupts and I've manually examined the generated .lst file to figure out which system variables needs saving and restoring. The interrupt code itself has NOT been changed at all. With that said agree that it has to be something.....
/Henrik.
Bookmarks