Trouble resetting the RTCC timer
baba40
Posts: 13
HI to all those whose skill sets exceed mine (suspect that's just about everyone on this forum.)
I have created some SX/B code that starts a one minute timer using·the RTCC timer.· I attempted to write
the code so that when the minute elapses, the RTCC is reset and the whole process starts over again.· While
the process works for one pass, it does not loop and start again.· It just appears to stop.· I have added
and LED based trace (which is included in the attached file), and it appears the second pass stops at the
OPTIONS=$88·command at the end of the "start:" routine.
I suspect there is register (or some other basic housekeeping chore that has escaped me) that needs to be
reset that I am missing as I can restart the process by hitting the reset button.· Ideally, I would like to reset
and restart·the RTCC timer without going through a full cold start.
Any help or insights would be greatly appreciated!
Best
Nimbus43
I have created some SX/B code that starts a one minute timer using·the RTCC timer.· I attempted to write
the code so that when the minute elapses, the RTCC is reset and the whole process starts over again.· While
the process works for one pass, it does not loop and start again.· It just appears to stop.· I have added
and LED based trace (which is included in the attached file), and it appears the second pass stops at the
OPTIONS=$88·command at the end of the "start:" routine.
I suspect there is register (or some other basic housekeeping chore that has escaped me) that needs to be
reset that I am missing as I can restart the process by hitting the reset button.· Ideally, I would like to reset
and restart·the RTCC timer without going through a full cold start.
Any help or insights would be greatly appreciated!
Best
Nimbus43
Comments
In SX-Key Help, There is a SX/B Example: Clock / Timer .
5ms
www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol8/col/nv152.pdf
INTERRUPT 100_000
... where the rate is 100,000 interrupts per second.
I want to thank those who have responded to my query.· While the idea of converting my timer to a task based process
is something I never considered, in looking at Jon's code, the program that will incorporate the timer can't suffer the fair
amount of additional code. I will, however,·keep the task concept in mind for other adevntures.
I am investigating the rate parameter suggestion, but wonder just how big the value could be?· for example would a 10
minute timer using a value of 1,000,000 be too large.· Put another way, is there any documentation around covering the
use of the interrupt·rate parameter?
And finally,·could 5ms? tell my where I can·find his reference to SX-Key help.
You guys have been great and have vastly expanded my horizons.· I didn't expect to be taken to the places·referenced
in your responses.· I·look forward to your comments to the above.
Best,
Nimbus43
·
Regarding the help file:
1 - Start the IDE.
2 - Open the menu Help->SX/B Help.
3 - Expand the section that says "Example Projects" in the help file.
4 - Locate the project and read it.
Thanks,
PeterM
The point is that you can do what you want to do -- you just need to think it through and find the lowest common denominator. Remember, the faster your INTERRUPT rate, the less time you have between interrupts which means you limit the amount of code you can place in the ISR. My suggestion is that you make the ISR rate as low as possible to do what you want to do. And avoid tasks if possible as they add a GIGANTIC amount of [noparse][[/noparse]necessary] overhead to the ISR.
I’m not sure about some of the things you’re doing with the RTCC settings…based on the delay length you want I would think you would set the prescaler to RTCC rather than WDT and you would set a higher prescaler value instead of 1:2/1:1. In any event I see where you’re enabling the RTCC in your main code and I see where it is being disabled in the interrupt code. Unfortunately I don’t see anywhere where you’re attempting to re-enable it. This would support the idea of the loop running once and not again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
I agree with Chris; there seems to be no re-enable.
Just curious about this too:
Was the goto start there when you tried the RETURNINT 50?
cheers,
- Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
recent contributions.
I hope it is not premature to say that I am somewaht releaved to learn that I am not going nuts!
The logic is so simple that I originally thought I was over looling something obvious (may not be out
of the woods on that, yet).
Just a brief note on the use of assembler for the ISR return.· While the SX/B compiler allows you to
to replace "retiw" and the use of the offset (in this case -50), when I tried it, it did not work properly.
While the code executed, it appeared that the timing loop slowed down by one or two orders of
magnitude so that instead of executing:
if minutes<>1 then iout················ 'set for a one minute period for debugging
and causing the process to fall out of the interrupt after one minute, it would take over 10
minutes.· By replacing "RETURNINT" (supposedly you do not need to include the offset value[noparse][[/noparse]-50] as
with "retiw") with the following snippet of assember, I was·able to restore the correct timing created
by the interrupt code.
iout:
ASM
mov·w,#-50···················· 'Interrupt very 1us
·retiw
ENDASM
I look forward to the continuing dialogue·on this issue and want to thank Chris (and perhaps others withing Parallax), Howard and
all those who have and may add their insights going forward.· Thanks for your help with this and the restoration of my mental
health (I hope).
Baba40
An additional brief note to my last response. It appears from traces I have run that the OPTION=$C8 does execute as I can validate proper
sequecing both after the "if minutes<>1 then iout 'set for a one minute period for debugging" instruction (i.e. the program correctly
jumps to start after the prior OPTION command, and that the init code carried in "start" routine executes properly UP TO the OPTION=$88
statement.
Hope this helps.
Baba40
So after removing the GOTO in your ISR you’re still having problems?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
If you are referring to the GOTO in the following snippet, yes.
' minutes roll over to main program
OPTION=$C8
p=1
goto Start
The program appears to successfully jump to "Start" (so I assume that the OPTION=$C8 is
executing properly and disables the RTCC timer). From the LED trace it also appears the the
"Start" sequence executes properly UP TO the OPTION=$88 (RTCC enable) where the program
stops. If I hit reset on the dev. board the program commences at start and the the OPTION=$88
does execute causing the program to jump to org 0 initiating the interrupt timer routine.
So, at the end of 1 or 10 minutes, depending on how I set the value in the loop, the sequence falls
through the loop executing the OPTION=$C8 and the jump to "Start". Consequently, it appears that
either the OPTION=$C8 or OPTION=$88 or both do not execute and that the only way to force the a
second or n number of enablings of the timer is to hit reset.
I hope this clear. As I said before, this coding sequence is not rocket science, so I am at a loss to
under stand why only a hard reset is the only way to relaunch the timer.
As always, I appreciate your continuing help.
Nimbus43
The attached program works the same, toggling an LED every 10 minutes. Looking at the compiled output I determined that no __PARAMx vars are used in the ISR so the NOPRESERVE option is fine.
Post Edited (JonnyMac) : 7/11/2009 8:05:44 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering