Code not generating (Imput Capture) Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code not generating (Imput Capture) Interrupt

Jump to solution
2,801 Views
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.

Labels (1)
0 Kudos
Reply
1 Solution
1,610 Views
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

View solution in original post

0 Kudos
Reply
5 Replies
1,610 Views
AntE
Contributor I

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

 

Thanks a lot Tonyp and Kef.

0 Kudos
Reply
1,610 Views
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 Kudos
Reply
1,611 Views
kef
Specialist I

Aren't # missing ?

 

        MOV #$4C,TPMSC;

        MOV #$44,TPMC0SC

0 Kudos
Reply
1,610 Views
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 Kudos
Reply
1,610 Views
tonyp
Senior Contributor II
Can you post your code?
0 Kudos
Reply