Hello everyone, I am trying to program a continuous 100Hz 50% duty cycle signal on pin 16 (TPMCH0) using the 9s08qg8 in assembly. I am using the internal oscillator (FBI mode) f=16kHz. I observe some strange behavior. As soon as power is supplied to the MCU, pin 16 illuminates for about 3.5 seconds at what appears to be full duty. Even after changing various variables, this behavior continues. Can anyone help me please? Thanks.
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; export symbols to be refer. in the linker .prm file
XDEF _Startup, main
XREF __SEG_END_SSTACK
; symbol defined by the linker for the end of the stack
; variable/data section
MY_ZEROPAGE: SECTION SHORT
; no variables defined
; Code section
MyCode: SECTION
_Startup:
main: LDHX #__SEG_END_SSTACK ; init stack pointer
TXS
CLI ; enable interrupts
LDA #%01110011
STA SOPT1
MOV #%01000100,ICSC1
MOV #%00000000,ICSC2
MOV #%00001000,MTIMCLK ;timer not necessarily used.
MOV #62,MTIMMOD
MOV #%00000000,MTIMSC
MOV #156,TPMMODL ;Bus clock / TPMMODL = 15625/156=100Hz
MOV #156,TPMC0VL ;100% duty, but tried 0-100%
MOV #$28,TPMC0SC ;no interupt, edge aligned, high-true pulse
MOV #$08,TPMSC ;Edge aligned, no interupt, using bus clock, prescale=1
LOOP BRA LOOP ;run forever
SWI
;*****************************************************
; ROUTINES
;*****************************************************
;timer not necessarily used.
TIMER BRCLR 7,MTIMSC,TIMER ;WAIT FOR TOF
BCLR 7,MTIMSC ;CLEAR TOF
RTS