W = w*2 ?
Ok, in my code, I was hoping for a 1 byte instruction that would be equivalent to W = W*2
Thoughts that came to mind are "RL W" and "ADD W,W", however both of these are not possible unless W is mapped to fr=1.
I can work around this of course by using another temporary memory location, however I feel like I'm missing something?
BTW, interestingly, "RL W" gets encoded as "RL IND" (0x360 or %001101100000)·so I didn't catch this until tracing through the simulator.
·
Thoughts that came to mind are "RL W" and "ADD W,W", however both of these are not possible unless W is mapped to fr=1.
I can work around this of course by using another temporary memory location, however I feel like I'm missing something?
BTW, interestingly, "RL W" gets encoded as "RL IND" (0x360 or %001101100000)·so I didn't catch this until tracing through the simulator.
·
Comments
-Phil
-Phil
When using any rotate instruction, like rl wreg, or mov wreg, <<reg, keep in mind that this only works correctly when the carry flag is clear, so for security reasons you should execute a clc instruction before which requires another clock cycle. So add w, wreg will be faster.
The fact that SASM generates "RL IND" for "RL W" is a bug in my opinion because this is not the expected result. It should generate a warning or error in this case.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
There's a couple of caveat's on this project which has me reading RTCC...
In the general design, I have a "start" interrupt occuring (RB.6) and a "stop" interrupt occuring (RB.7). Between these two events I want an accurate time that must have high precision and resolution.
Ok, what does this mean? I have interrupts coming in from RTCC, RB.6 and RB.7.
With the "RTCC interrupt", I need to increment on roll-over RTCC_1, and when that roll's over, RTCC_2. If RTCC was the only interrupt, this is very trivial to do.
Also using the time-base interrupt, I refresh 4 7-seg displays based on DISP_0 .. DISP_3 (and every second, alternate with a second set of display registers DISP_4 .. DISP_7).
Now, when you introduce RB.6 and RB.7 to the mix, things get more interesting on the SX28 because it has no indicator that the interrupt is time based vs RB.x (the two co-incide, and obviously you can't asusme RB.x means it wasn't time-based).
I solve this with a little trick. When RTCC is < 128, I assume that the clock rolled over, and use RETIW to add 128 to RTCC. This means I get the interrupt twice as fast of course, but means I can accurately determine RTCC has rolled over even with other interrupts coming in. I have RTCC scaled enough so that the max interrupt time is < RTCC interrupt period. I happen to also use RTCC_1 and RTCC_2 in the ISR to feed my display refresh clocks.
When I need to snapshot my time, I use RTCC (7 bits) combined with RTCC_1 and RTCC_2 to give myself a 23-bit time-base.
Now one option in the code is to avoid ever using WREG, another option I'm entertaining is to modify OPTION.7 whenever I need to use RTCC register, and modify it back when I don't.
· This has turned into an interesting thread. Cool.
· The WKPND_B register indicates if the interrupt was caused by a Port B wake-up.
· In SX/B use:
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
I like your technique for dealing with the SX's lack of an interrupt pending bit for the timer rollover. That annoying little quirk in the SX's architecture has bedeviled me in the past; and, although I've come up with a solution, yours is more elegant. In essence, you've created a timer interrupt pending flag (inverted) in RTCC.7. You do have to be careful with your timing, though, to make sure RTCC is either over 128 or significantly less than 128 when you check it. If it's 127, say, it'll be over 128 by the time you get to the RETIW 128, which will cause a rollover. Although the docs do not make it clear whether or not an artficial rollover, such as this, will cause an interrupt, I suspect that it will not.
-Phil
· Just for the record, the SX48 does have an RTCC rollover bit. It is "RTCCOV" bit 7 of T1CNTB register.
· It is only available on the SX48 though.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Yup, something for which we can all be thankful!
BTW, here's my ISR code for mixed interrupts on the SX28 family chips. As I said, it's less elegant than NetHog's solution, but it works:
This code, incidentally, used an RTCC prescalar rate of 1:4. Other prescale rates will entail different constants for detecting or anticipating an RTCC interrupt.
-Phil
may be of help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
Check out:
http://www.sxlist.com/techref/ubicom/sxints.htm
and especially the comments of Alexey Vladimirov near the bottom of the page:
The page at:
http://www.sxlist.com/techref/ubicom/rtcc.htm ·also points out some little known information, although it only applies to the use of RTCC with an external clock signal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
Phil: you are correct about using RTCC.7 as a pseudo interrupt pending flag, and that you have to be very careful with how long you spend in the interrupt routine due to these concerns. Things should be more than fine if the max ISR timing is less than 64 RTCC increments (enough time for ISR to run to completion twice). With some forethought in the logic, capturing RTCC at the start and end of the ISR, you can push max ISR time to be closer to 128 RTCC increments.
Bean: Yup, about the SX48, sadly I have SX28's in my bucket [noparse]:)[/noparse] BTW, feel free to change the topic title to reflect the prominant subject matter of the thread since we've veered off from the original subject.