In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Vertex78 wrote: Sure, I welcome the help. This is causing me a big headache trying to figure out! [code] ;DEVICE SX52, OSC4MHZ DEVICE SX52 IRC_CAL IRC_SLOW DEVICE OSCHS3 ; High-speed external oscillator RESET initialize FREQ 80_000_000 ;********** ; EQUATES ;********** ;timer1 rT1CPL EQU $00 rT1CPH EQU $01 rT1R2CML EQU $02 rT1R2CMH EQU $03 rT1R1CML EQU $04 rT1R1CMH EQU $05 rT1CNTB EQU $06 rT1CNTA EQU $07 wT1R2CML EQU $12 wT1R2CMH EQU $13 wT1R1CML EQU $14 wT1R1CMH EQU $15 wT1CNTB EQU $16 wT1CNTA EQU $17 ;timer2 rT2CPL EQU $00 rT2CPH EQU $01 rT2R2CML EQU $02 rT2R2CMH EQU $03 rT2R1CML EQU $04 rT2R1CMH EQU $05 rT2CNTB EQU $06 rT2CNTA EQU $07 wT2R2CML EQU $12 wT2R2CMH EQU $13 wT2R1CML EQU $14 wT2R1CMH EQU $15 wT2CNTB EQU $16 wT2CNTA EQU $17 FLAG1 EQU %00001000 FLAG2 EQU %00010000 org $0a d1 ds 1 d2 ds 1 d3 ds 1 org $0 isr reti initialize mov !rb, #%00001111 ;timer 1 mov !rc, #%11110000 ;timer 2 ;---------------------------------------------------- ; timer 1 setup ;---------------------------------------------------- ;setup for prescale of 1:64 and pwm mode mov w,#wT1CNTB ;16 mov m,w mov w,#%00011001 mov !rb,w ;setup interrupts(turned off) mov w,#wT1CNTA mov m,w mov w,#%00000000 mov !rb,w ;r1 ;load t1 compare register1 mov w,#wT1R1CML ;14h mov m,w mov w, #96 mov !rb,w mov w,#wT1R1CMH ;15h mov m,w mov w,#4 mov !rb,w ;r2 ;load t1 compare register2 mov w,#wT1R2CML ;12h mov m,w mov w, #96 mov !rb,w mov w,#wT1R2CMH ;13h mov m,w mov w,#4 mov !rb,w ;---------------------------------------------------- ;timer2 setup ;---------------------------------------------------- ;clear timer 2 mov w,#$10 mov m,w mov !rc,w ;setup for prescale of 1:64 and pwm mode mov w,#wT2CNTB ;16 mov m,w mov w,#%00011001 mov !rc,w ;setup interrupts(turned off) mov w,#wT2CNTA mov m,w mov w,#%00000000 mov !rc,w ;r1 ;load t2 compare register1 mov w,#wT2R1CML ;14h mov m,w mov w, #96 mov !rc,w mov w,#wT2R1CMH ;15h mov m,w mov w,#4 mov !rc,w ;r2 ;load t2 compare register2 mov w,#wT2R2CML ;12h mov m,w mov w, #96 mov !rc,w mov w,#wT2R2CMH ;13h mov m,w mov w,#4 mov !rc,w ;---------------------------------------------------- ;clear timers ;---------------------------------------------------- mov w,#$10 mov m,w mov !rb,w ;delay here to cause timer 2 to be out of phase with timer 1(but does not work for some reason) ;14us delay mov w, #$9F mov d1, w mov w, #$01 mov d2, w Delay_0: decsz d1 jmp $+2 decsz d2 jmp Delay_0 ;6 cycles jmp $+1 jmp $+1 ;clear timer2 mov w,#$10 mov m,w mov !rc,w mov w,#$1f mov m,w main jmp main [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=152979#m153218 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)