#include <device.h>
uint32 InterruptCnt;
/*******************************************************************************
* Define Interrupt service routine and allocate an vector to the Interrupt
********************************************************************************/
CY_ISR(InterruptHandler)
{
/* Clear Inerrupt */
Timer_ClearInterrupt(Timer_INTR_MASK_CC_MATCH);
/* Increment the Counter to indicate the keep track of the number of
* interrupts received */
InterruptCnt++;
}
void main()
{
CyDelay(50);
/* Enable the global interrupt */
CyGlobalIntEnable;
/* Enable the Interrupt component connected to interrupt */
CC_ISR_StartEx(InterruptHandler);
/* Start the components */
Timer_Start();
LCD_Start();
/* Display Timer on LCD */
LCD_Position(0u, 0u);
LCD_PrintString("Timer");
for(;;)
{
/* To display Period on LCD */
LCD_Position(0u, 7u);
LCD_PrintInt16(Timer_ReadPeriod());
/* To display Capture value on LCD */
LCD_Position(0u, 12u);
LCD_PrintInt16(Timer_ReadCapture());
/* To display count on LCD */
LCD_Position(1u, 0u);
LCD_PrintInt16(Timer_ReadCounter());
/* To display Interrupt count on LCD */
LCD_Position(1u, 5u);
LCD_PrintString("IntCnt:");
LCD_PrintInt16(InterruptCnt);
CyDelay(100u);
}
} |