AnsweredAssumed Answered

S12X output compare

Question asked by Robert Hiebert on Jan 30, 2018
Latest reply on Feb 5, 2018 by Robert Hiebert

MC9S12XEP100 112LQEP. Programming in assembler.

I want all port P pins to be output compare, but I am having some difficulty in making them work. I suspect it may be something I’ve done in my set up. Does anyone see anything wrong with this?


movb #$FF,DDRP       ; (all port P pins outputs)

movb #$FF,TTIOS       ; TTIOS equ $03D0 (all channels outputs)

movb #$98,TTSCR1   ; TTSCR1 equ $03D6 (timer enabled, no stop in wait,

                                       ; no stop in freeze, fast flag clear, precision timer)

movb #$00,TTOV       ; TTOV equ $03D7 (Toggle OC pin on overflow disabled)

movb #$55,TTCTL1   ; TTCL1 equ $03D8 (toggle output line Ch7,6,5,4)

movb #$55,TTCTL2   ; TTCL2 equ $03D9 (toggle output line Ch3,2,1,0)

movb #$00,TTCTL3   ; TTCL3 equ $03DA (capture disabled Ch7,6,5,4)

movb #$00,TTCTL4   ; TTCL4 equ $03DB (capture disabled Ch3,2,1,0)

movb #$00,TTIE         ; TTIE equ $03DC (interrupts disabled)                                  

movb #$07,TTSCR2   ; TTSCR2 equ $03DD (timer overflow interrupt disabled,

                                       ; timer counter reset disabled, prescale divide by 128)                            

movb #$FF,TTFLG1   ; TTFLG1 equ $03DE (clear all flags)

movb #$FF,TTFLG2   ; TTFLG2 equ $03DF (clear all flags)

movb #$00,PACTL     ; PACTL equ $03F0 (Pulse accumulator disabled)

movb #$02,PAFLG     ; PAFLG equ $03F1 ( Clear pulse accumulator flags)

movb #$00,TOCPD     ; TOCPD equ $03FC (Enable all timer channel pins)              

movb #$7F,TPTPSR     ; TPTPSR equ $03FE (prescale 128, 2.56us resolution,

                                       ; max period 167.7696ms)