Code not generating (Imput Capture) Interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Code not generating (Imput Capture) Interrupt

跳至解决方案
2,802 次查看
AntE
Contributor I

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.

标签 (1)
0 项奖励
回复
1 解答
1,611 次查看
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,611 次查看
AntE
Contributor I

Yes.... That was the problem, I added the "#" and the interrupt happened.

 

Thanks a lot Tonyp and Kef.

0 项奖励
回复
1,611 次查看
AntE
Contributor I

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

 

 

 

 

 

0 项奖励
回复
1,612 次查看
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

0 项奖励
回复
1,611 次查看
tonyp
Senior Contributor II

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.

0 项奖励
回复
1,611 次查看
tonyp
Senior Contributor II
Can you post your code?
0 项奖励
回复