Hi,
I need a one shot 30 sec timer in my project with an interrupt on terminal count.
I think the timer component is configured correctly and it works as expected (counts for 30 sec and fires interrupt), when I attach the interrupt component to the "tc" output of the timer.
However, if I attach the interrupt component to the "interrupt" output, the interrupt never get fired (the ISR method is never being entered) although the counter counts down to zero and stops counting as expected being a one shot timer.
What do I miss?
Here is my design (part): https://www.dropbox.com/s/1ndrfp3wzxlobil/one-shot-timer.png?dl=0
Here is my timer config: https://www.dropbox.com/s/zx4625z1thdabub/one-shot-timer-conf.png?dl=0
Here is my code, attached you will find my test project as well:
#include <stdio.h>
#include "project.h"void readData();
void logMsg();
static char logMsgLine[255];
static uint8 isr_flag_timer_tc = 0;/**
* Timer ISR
*/
CY_ISR( Timer_Int_Handler )
{
if (Timer_ReadStatusRegister() & Timer_STATUS_TC_INT_MASK) {
isr_flag_timer_tc = 1;
}
sprintf(logMsgLine, "Interrupt %d looking for %d\n\r", Timer_ReadStatusRegister(), Timer_STATUS_TC_INT_MASK);
logMsg( logMsgLine );
}int main(void)
{CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start();
Timer_Int_StartEx( Timer_Int_Handler );
for(;;)
{
readData();
}}
void readData(){
// Start the 30 sec timer
isr_flag_timer_tc = 0; // will be set to 1 on tc interrupt
Timer_Start();
Timer_Trigger_Write( 1 );// loop until 30 sec timer terminal count
while(!isr_flag_timer_tc){
// do something until 30 sec are over
sprintf(logMsgLine, " timer count %d\n\r", Timer_ReadCounter());
logMsg( logMsgLine );
CyDelay(1000);
}if (isr_flag_timer_tc) {
isr_flag_timer_tc = 0;
// stop timer
Timer_Stop();
}}
/**
* write a message to some terminal/chanel
*/
void logMsg(char* msg)
{
UART_UartPutString( msg );
}/* [] END OF FILE */