retiw and "negative" w
I am learning to program the SX and I have a question about the following code
I struggle as to what "-" means here. There is no sign bit in the registers (that I see) so is this just a special case for using such a thing? Is what is really happening here is you are "adding and rolling over" the correct value to rtcc to make it look like you subtracted 100 from it and doing it without causing another rollover interrupt?
Thanks,
Jim
mov w, #-100 retiw
I struggle as to what "-" means here. There is no sign bit in the registers (that I see) so is this just a special case for using such a thing? Is what is really happening here is you are "adding and rolling over" the correct value to rtcc to make it look like you subtracted 100 from it and doing it without causing another rollover interrupt?
Thanks,
Jim
Comments
-Phil
The OPTION register is set for 1:64 for the rtcc.
In the interrupt PWM_SPEED is always 0 so _ISR_PWM_RUN is never called.
I run it in SxSim and break on the first line of the interrupt.
Loop 1 = 2498 cycles
Loop 2 = 2495 cycles
Loop 3 = 2495 cycles
Loop 4 = 2498 cycles
Loop 5 = 2495 cycles
Loop 6 = 2495 cycles
....
I thought this was suppose to be jitter free interrupts
Thanks,
Jim
Understood. Thanks.
Jim
I deleted the post you responded to, since I wasn't yet sure it was the right explanation. But now I'm convinced it was. Your RTCC period is 2496 cycles which, although it's divisible by three, causes interrupts in the middle of your JMP. So the JMP must run to completion before the interrupt can be serviced. On average the cycle length you experience will be 2496, but any instruction-length jitter is inevitable.
As a test, you could simulate your code in non-turbo mode, wherein JMPs are two cycles long. The jitter you see should be no longer than two cycles in that case.
-Phil
I think maybe it is SX-Sim that is giving the cycle count incorrectly.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
You're right. I found this bit of info here, quoting an old Parallax press release:
So it must be the simulator.
-Phil
Jim