Hi....
These are the codes that i have written..doesnt seem rite though..
org flash ;start main code at the beginning of flash
init
mov #$01,config2 ;Osc disable on stop, SCI clock source internal
mov #$31,config1 ;COP disabled, all other default
ldhx #$0240 ;load HX with the end of memory location
txs ;put the stack pointer at the end of memory
clra ;clears A, X, and H regs
clrx
clrh
**************** memory definitions *****************************
jsr duty_80
*Timer initialization subroutine for 80% duty cycle(20% of C)
duty_80:
lda t1sc
lda #$70
sta t1sc
lda t1sc0
mov #$1e,t1sc0
ldhx #$bfff
sthx t1modh
mov #$a0,t1ch0h
mov #$00,t1ch0l ; duty cycle
bclr 5,t1sc
clr count
jsr ISR_routine
rts
*Interrupt service routine for Various Duty Cycle with internal Timer
ISR_routine:
cli
here:
bra here
rts
*timer counter overflow
outov inc count
ldhx #!10000
cphx count
beq new_duty
rti
new_duty mov #$20,t1ch0h
mov #$00,t1ch0l ; duty cycle
bset 6,t1sc0
rti
Do i use Buffered or unbuffered PWM ???
this is my initial working pwm code....how do i vary the duty cycle with an interval of 5 Minutes..using this way?
*main
org $8000
init
mov #$31,config1
again:
lda #$80
sta duty
nop
jsr pwmd4
bra again
*tim initialization
pwmd4:
lda t1sc
lda #$73
sta t1sc
lda t1sc0
mov #$5a,t1sc0
ldhx #$00ff
sthx t1modh
mov #$00,t1ch0h
mov #$d0,t1ch0l ; duty cycle
bclr 5,t1sc
cli
here:
bra here
rts
* output compare
outcp bclr 7,t1sc0
rti
*timer counter overflow
outov bclr 7,t1sc
rti