Shop OBEX P1 Docs P2 Docs Learn Events
How to access OPTION register and RTCC register? — Parallax Forums

How to access OPTION register and RTCC register?

basicstampedebasicstampede Posts: 214
edited 2008-09-08 16:09 in General Discussion
Hello.· I want to use the RTCC pin as an external interrupt source.· When a switch connected to the RTCC pin sees High to Low transition, I want to enter the ISR.

In order to do this, I want RTCC set up as external event counter.
And I want my program to pre-load RTCC register with $FF (so that interrupt occurs on next 1 to 0 transition).·

Can someone please share a shell program that sets RTCC pin and pre-load the RTCC counter?

Thanks.·

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-08 14:55
    All the information you needed to write this program could be found in the SX/B help file under INTERRUPT.
  • basicstampedebasicstampede Posts: 214
    edited 2008-09-08 15:33
    JonnyMac, thank you very much. I will try it tonigh when I get a chance (probably tonight).

    Is there a way to watch the value of RTCC via SX Key debugger?

    When I tried it before, RTCC always showed 0 for some reason, even though it was supposed to count internal cycle.

    I tried SX Sim also, but RTCC always shows 0 also (even with OPTION = %1101_1000 or %0101_1000)

    Thanks.
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-08 16:09
    I don't know that this kind of program lends itself to watching the RTCC with the debugger. I did changed the program run a periodic interrupt at 40_000 Hz and put the debugger in Walk mode; this let me see the value of RTCC as it changed (I put the WATCH [noparse][[/noparse]for RA] and BREAK statements in the ISR). Once it hit the interrupt things went as they should but the debugger had to be restarted in Walk mode after the BREAK. Again, this may be asking too much of the debugger but, as a person who rarely uses it, I'm not the guy to provide the best guidance.

    The program above does run properly in SX/Sim. Open the IO panel and click the RTCC input -- and give it a little time to simulate the action; you'll see the RTCC change from 0 back to 255.
Sign In or Register to comment.