SX/B and SXList sasmdel MACRO
PLJack
Posts: 398
I'm trying to use the SXList delay macro.
I don't seem to understand the syntax.
I keep getting the delayhelp "ERROR 'USAGE: delay value, [noparse][[/noparse]usec,msec,sec,cycles]'"
message or a "Files\test.SRC(251) Line 263, Warning 58, Pass 1: Division by zero"
error.
Could someone give me an example of a 1000 usec and 100 msec delay.
So, what am I doing wrong.
I don't seem to understand the syntax.
I keep getting the delayhelp "ERROR 'USAGE: delay value, [noparse][[/noparse]usec,msec,sec,cycles]'"
message or a "Files\test.SRC(251) Line 263, Warning 58, Pass 1: Division by zero"
error.
Could someone give me an example of a 1000 usec and 100 msec delay.
So, what am I doing wrong.
' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 include "sasmdel.src" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- LED VAR RB.0 ' LED pin ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- OnDelay CON 200 ' time LED is on OffDelay CON 200 ' time LED is off CpuMhz CON 4_000_000 ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: HIGH LED ' turn LED on \delay 100, msec ' PAUSE OnDelay ' delay LOW LED ' turn LED off ' PAUSE OffDelay ' delay \delay 100, msec GOTO Start ' repeat forever
Comments
If not
http://www.sxlist.com/cgi-bin/delay.exe
You enter clock speed, requested delay and it spits out the code.
and
·
And for all of you just learning ASM, as I am, make sure you
"call" the delay and not "jmp". [noparse]:)[/noparse]
That will save you about an hour of watching the debug window.
Jack
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
I knew that Pause would not have the resolution for microseconds.
Forgot that I was dealing with Parallax, of course there is a microsecond
version of pause for SX/B. What was I thinking. [noparse]:)[/noparse]
Thanks Jon.
Although I am having a love/hate good time learning ASM.
The CPUMHz that you set is interesting... How will you run your SX at 4,000,000 MHz? I could understand 4,000,000 Hz, but I usually set CPUMHz to just 4. Also, 4_000_000 is not a valid number as far as I know... It might work for the FREQ directive, but as an actual number SASM wants 4000000 for hertz and just 4 for MHz.
That macro is also designed to work as a part of a template called sasmtemp.src. It sets up a few things that the delay macro needs to work. For delays of more than a few cycles, it expects an ISR that will increment a set of registers and clear a flag when they overflow. This is all setup in the sasmtemp.src file, but you can't use that in SX/B.
I would probably be possible to come up with a version of the macro that could work in SX/B, but as others have mentioned, PAUSE and PAUSEUS are probably your best bet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!