How to use FREQ alias, ISR rate alias (or computed), etc.?
Zoot
Posts: 2,227
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
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
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
·
Post Edited By Moderator (Bean (Hitt Consulting)) : 11/22/2007 12:42:52 AM GMT
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
·