Aaron Greer

HCS08GB60 timer output compare interrupt

Discussion created by Aaron Greer on Feb 11, 2006
Latest reply on Feb 17, 2006 by Pavel Lajsner
I have the HCS08GB60 demo board and am using the serial monitor functionality to program and debug my code via Codewarrior.
I have had several problems doing things that are relatively straightforward, at least they have been on the handful of other chips I've worked with.

First of all, I am unable to make the external oscillator work. Secondly, as I've recently learned, the RTI functionality does not work alongside the serial monitor.
As a result of not having RTI capability, I'm trying to setup a timer to generate a periodic interrupt as a pseudo-RTI.

Here is how I'm initializing the timer:
;;;;;;;;;;; INIT CODE
;; setup timer 1 module
; use system clock, prescale by 128
lda #(mCLKSB+mPS2+mPS1+mPS0)
sta TPM1SC

; setup timer 1 channel 1
; for output compare (used for periodic interrupt)
; output compare mode, software only, enable interrupt
lda #(mMS1A+mCH1IE)
sta TPM1C1SC

; reset the channel count value
; calculate the current counter value + delay value
; do: ix = ix + cnt (ix = RTIDelayH:RTIDelayL)
; current counter value ( cnt = TPM1CNTH:TPM1CNTL )
lda #RTIDelayL
add TPM1CNTL ; a = RTIDelayL + TPM1CNTL
tax ; x = a

lda #RTIDelayH
adc TPM1CNTH ; a = RTIDelayH + TPM1CNTH + c
pulh ; h = a

; store ix in channel value reg (TPM1C1VH:TPM1C1VL)
sthx TPM1C1VH

; clear the channel flag
; read flag CH1F in TPM1C1SC
lda TPM1C1SC
; to clear flag, write zero to CH1F
bclr CH1F, TPM1C1SC
;;;;;;;;;;; END INIT CODE

Because of post size constraints, I will continue with the ISR code in my next post.