Using SXSim and the SX Multipurpose Timers
JDOhio
Posts: 72
I have a simple program here to help me learn how to use the timers.· The intent of the program is to set up a port as outputs, set up a timer, and toggle the port when the timer overflows.· I am trying this SXSim but it never reaches my interrupt.· Even at divide by three at·4 MHz, I would expect to enter the interrupt at least once if I wait long enough.· Any ideas?
Joe
;
DEVICE DIRECTIVES
··DEVICE··SX48,OSC4MHZ
··IRC_CAL··IRC_4MHZ
··RESET··Main
;
CONSTANTS
T1CNTA··EQU·$17···;write T1 Control A
T1CNTB··EQU·$16···;write T1 Control B
;
DEBUG SETTINGS
··FREQ·4_000_000
;
INTERRUPT ROUTINE
··ORG·0
Interrupt
··mov·W,$05···;toggle LEDs
··xor·RA,W
··retiw
;
MAIN PROGRAM
Main
··mov·W,#$1f
··mov·M,W
··mov·W,#$00
··mov·!RA,W···;RA is all outputs
··mov·W,T1CNTA
··mov·M,W
··mov·W,#$01
··mov·!RB,W···;interrupt on overflow
··mov·W,T1CNTB
··mov·M,W···;set up to write timer 1 B
··mov·W,#$02···;divide by 1, capture/compare
··mov·!RB,W
··mov·W,#$03···;turn on LEDs
··mov·$05,W
loop:··jmp ·loop
Joe
;
DEVICE DIRECTIVES
··DEVICE··SX48,OSC4MHZ
··IRC_CAL··IRC_4MHZ
··RESET··Main
;
CONSTANTS
T1CNTA··EQU·$17···;write T1 Control A
T1CNTB··EQU·$16···;write T1 Control B
;
DEBUG SETTINGS
··FREQ·4_000_000
;
INTERRUPT ROUTINE
··ORG·0
Interrupt
··mov·W,$05···;toggle LEDs
··xor·RA,W
··retiw
;
MAIN PROGRAM
Main
··mov·W,#$1f
··mov·M,W
··mov·W,#$00
··mov·!RA,W···;RA is all outputs
··mov·W,T1CNTA
··mov·M,W
··mov·W,#$01
··mov·!RB,W···;interrupt on overflow
··mov·W,T1CNTB
··mov·M,W···;set up to write timer 1 B
··mov·W,#$02···;divide by 1, capture/compare
··mov·!RB,W
··mov·W,#$03···;turn on LEDs
··mov·$05,W
loop:··jmp ·loop
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"Sometimes it is better to remain silent and be thought a fool, than to speak and remove all doubt."
·
unfortunately, Bean is right - the current version of SXSim does not support the hardware timers.
This feature is no my TODO list since a while. but I fear that it'll take me more time before I can address that matter due to other "mouth-feeding" business. Nevertheless, I will not forget about it, so please be patient and stay tuned...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Joe