Shop OBEX P1 Docs P2 Docs Learn Events
How to use FREQ alias, ISR rate alias (or computed), etc.? — Parallax Forums

How to use FREQ alias, ISR rate alias (or computed), etc.?

ZootZoot Posts: 2,227
edited 2007-11-22 00:42 in General Discussion
When using SX/B, and mixing SX/B and ASM, I want to set up my code so that the rate of the ISR is dependent on the freq setting. I don't want to use a lot of '{$IFDEF}s -- is this info aliased or set up as a constant by SX/B?

The help file says that computed constants can not be used for ISR rates? I want to able to just change the freq. directive and have the change cascade throughout the code without adjusting other constants by hand.

I.E., I would like to do something like:

DEVICE OSCHS2
FREQ 20_000_000

and then later on in the program use something like

IsrRate CON __freq / 4
INTERRUPT IsrRate

and

val1 = __freq * val2

and

val1 = val2 / IsrRate

etc.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

Comments

  • BeanBean Posts: 8,129
    edited 2007-11-22 00:02
    Zoot,
    Don't use the INTERRUPT rate parameter, just use "RETURNINT value". That will give you an interrupt routine that runs every "value" cycles.

    SX/B creates a variable named "__FREQMHZ" that holds the frequency in megahertz.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • ZootZoot Posts: 2,227
    edited 2007-11-22 00:07
    So RETURNINT can be computed constant? var too?



    Post Edited By Moderator (Bean (Hitt Consulting)) : 11/22/2007 12:42:52 AM GMT
  • BeanBean Posts: 8,129
    edited 2007-11-22 00:42
    Oops, I accidently edited your post instead of making a new post.

    RETURNINT can use a variable, but I don't think you can use a computed constant...

    If you want an interrupt to execute the same times per second, use "INTERRUPT rate" if you want an interrupt to execute the same number of cycles, use "RETURNINT constant".

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.