- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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