Hello, Im new in this forum, I have several monts of experienece with microcontrollers (the HCS08QG8 only in assembler), and I have a problem: I need to measure the width of an external pulse generated by a sensor (the ultrasonic sensor SRF05), I have configured the TPM channel 0 as Input Capture with event on Rising Edge, enabled the interrupt in this source, enabled the global mask interrupt, configured the pin 2 of port A (TPM channel 0) as input, but the signal provided by the sensor doesn´t generate the interrupt, and the pulse of the sensor is ok. Debugging I discovered that the flag of the associated port doesn´t get set (reading directly the port with LDA TPMC0SC), tried generating a Timer interrupt and this is neither genereated. I don´t know how to get the interrupt. Any help will be appreciated.
解決済! 解決策の投稿を見る。
Yes.... That was the problem, I added the "#" and the interrupt happened.
Thanks a lot Tonyp and Kef.
Of course. The whole code is large (the interrupt is only apart of the program), but this is the part relevant of the problem:
; **** main system initialization *******
main:
_Startup:
SEI ; disable interrupts before system initialization
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
JSR MCU_init
JSR INITLCD
JSR INITTPM
JSR INITADC
CLI ; enable interrupts
;******** TPM initialization *********
;*
;**************************************
;* INITTPM *
;* *
;* TPMSC *
;* (Timer Overflow interrupt enable) disabled, *
;* bus rate clock (4Mhz), prescaler = 16 *
;* *
;* TPMC0SC *
;* input capture, interrupt enable, Capture on rising *
;* edge *
;***************************************
INITTPM
MOV $4C,TPMSC;
MOV $44,TPMC0SC
RTS
;****** main body ********
SEN_ACT ;**** this pulse send a "woke up" request to the sensor ****
BSET ENREV,PTAD ; PTA4 <-- 1 Start sensor trigger
JSR DLY10U ; Delay 10uS aprox
BCLR ENREV,PTAD ; PTA4 <-- 0 Endof trigger pulse
JSR DLY100 ; Waits for sensor pulse and interrupt (0.1 seg)
.....
..... ; //this part process the width obtained
BRA
Aren't # missing ?
MOV #$4C,TPMSC;
MOV #$44,TPMC0SC
On first look, everything seems correct.
So, with the exception of the remaining code disabling the TPM at some other place by mistake, I can only think of priority issues. For example, you probably have AD0 or ACMP functionality enabled.