Code not generating (Imput Capture) Interrupt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Code not generating (Imput Capture) Interrupt

ソリューションへジャンプ
1,757件の閲覧回数
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 解決策
566件の閲覧回数
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

元の投稿で解決策を見る

0 件の賞賛
5 返答(返信)
566件の閲覧回数
AntE
Contributor I

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

 

Thanks a lot Tonyp and Kef.

0 件の賞賛
566件の閲覧回数
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 件の賞賛
567件の閲覧回数
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

0 件の賞賛
566件の閲覧回数
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 件の賞賛
566件の閲覧回数
tonyp
Senior Contributor II
Can you post your code?
0 件の賞賛