Shop OBEX P1 Docs P2 Docs Learn Events
Interrupts in SX/B — Parallax Forums

Interrupts in SX/B

Invent-O-DocInvent-O-Doc Posts: 768
edited 2008-11-09 20:38 in General Discussion
I've ready that using interrupts in SX/B, it is necessary to

1) put the interrupt code in first before the main code, so it is in the first memory page and

2) specify the amount of time (or cycles) the interrupt routine will take to execute

Assuming the above assumptions are correct, what is a straightforward way to find out how long the interrupt code takes to execute so as to provide that information in the SX/B INTERRUPT command.

Any help with this is most appreciated!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thomas Talbot, MD
Gunpowder, MD, USA

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-11-08 02:25
    You can save yourself a ton of trouble by using a good template -- like the one that's attached. Put it into the SX/B templates folder and clicking on File-->New (SX/B) will load it for you. It's organized and puts things in the right order.

    It's easier to specify interrupt rate and you can do that right on the INTERRUPT declaration line. You don't need to find out how long an interrupt takes, you decide how frequently you want it to execute. You just have to make sure that any code you put into the interrupt doesn't run longer than the period you've specified.
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2008-11-08 17:40
    Thats good news, I already do use your template and find it to be very helpful.. What is the function of {cycles} after the RETURNINT?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thomas Talbot, MD
    Gunpowder, MD, USA
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-11-08 18:00
    Please use the template I attached above -- that has a subtle update over older templates (START directive is moved).

    While not frequently used, you can manually set the interrupt rate by leaving off the information after INTERRUPT and then using the cycles parameter after RETURNINT. If you do this then you'll need to set the OPTION register as well (usually at the beginning of your program). For the most part, using the Rate parameter of INTERRUPT will be the easiest way to go. The nice thing about using the Rate parameter is that it does the calculations for Cycles and sets the Option register appropriately (use Ctrl-L to look at the List File and you'll see these things in the Start and Interrupt code).
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2008-11-09 00:43
    Ok, I get it and I now see that the new template is different. Thanks for explaining this to me. I thought that both methods were necessary, and now that I understand that it is an either/or Ill just specify rate parameter of INTERRUPT, that should be simpler. THanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thomas Talbot, MD
    Gunpowder, MD, USA
  • $WMc%$WMc% Posts: 1,884
    edited 2008-11-09 20:38
    JonnyMac

    Thanks for the Template. Jon W.,,, My Son and I have been playing w/ the SX/B useing the Program from Your N/V's Mag. Artc. ...Not only can We both spell "Interrupt", But We can use Them as well,,,,"After A brief Forum discussion"...Looking foward to the next Artc. In Jan."We hope Santa C. will bring it sooner".......................This is A neat lil. chip,And it's dirt cheap$

    ______________didn't mean to "Interrupt" this Post_______________$WMc%______________
Sign In or Register to comment.