Capture module in Timer only interrupt once

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi all, I'm using PSoC to calculate the time interval between the transmitted and received pulse in ultrasonic sensor. I'm using trigger pin in timer module to start the timer and trigger "capture" when the output from ultrasonic RX exceed a certain voltage using VDAC.

However, the module only interrupt once and it doesn't interrupt anymore. Attached is the picture of the top design.

Thanks.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

CY_ISR(Ultrasonic_Timer_Handler){
    Ultrasonic_Interrupt_ISR_ClearPending(); // You don't need that
    Capture_Count=0; // (double)((uint16)65535-Ultrasonic_Timer_ReadCounter());
    sprintf(UART_line,"Count: %4.2f\r\n",Capture_Count);
    UART_1_PutString(UART_line); // No lengthy code in a handler

   

Ultrasonic_Timer_ReadStatusRegister(); // Will clear the interrupt flag, See datasheet
}

   

 

   

Bob

View solution in original post

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It is always better to post the complete project when you want some help.

   

Use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

Just a guess: You may have forgotten to reset the interrupt cause in your capture isr.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi, I have attached the project. The top design is in "Ultrasonic" page.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

CY_ISR(Ultrasonic_Timer_Handler){
    Ultrasonic_Interrupt_ISR_ClearPending(); // You don't need that
    Capture_Count=0; // (double)((uint16)65535-Ultrasonic_Timer_ReadCounter());
    sprintf(UART_line,"Count: %4.2f\r\n",Capture_Count);
    UART_1_PutString(UART_line); // No lengthy code in a handler

   

Ultrasonic_Timer_ReadStatusRegister(); // Will clear the interrupt flag, See datasheet
}

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob, thanks for the reply, fixed the problem with ReadStatusRegister. However for the ClearPending(), under what kind of condition do I need to execute ClearPending() when interrupt happens? I read the datasheet and it said some interrupts are clear-on-read like GPIO,UART.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I only used ClearPending() outside an interrupt handler to make sure that there was not an "old" interrupt waiting before I enabled / started the isr component.

   

 

   

Bob