- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to achieve an interrupt timer, how to achieve it?
I have seen from the data that it can be implemented by GPIO interrupt, but it can't generate interrupt. Here is my code:
//Initialization code:
CyU3PGpioClock_ t gpioClock;
CyU3PGpioComplexConfig_ t gpioConfig;
CyU3PReturnStatus_ t apiRetStatus = CY_ U3P_ SUCCESS;
/* Init the GPIO module */
- gpioClock.fastClkDiv = 2;
- gpioClock.slowClkDiv = 0;
- gpioClock.simpleDiv = CY_ U3P_ GPIO_ SIMPLE_ DIV_ BY_ 2;
- gpioClock.clkSrc = CY_ U3P_ SYS_ CLK;
- gpioClock.halfDiv = 0;
apiRetStatus = CyU3PGpioInit(&gpioClock, CyFxGpioIntrCb);
CyU3PGpioComplexConfig_ t gpioComplexConfig;
- gpioComplexConfig.outValue = CyFalse;
- gpioComplexConfig.inputEn = CyTrue;
- gpioComplexConfig.driveLowEn = CyFalse;
- gpioComplexConfig.driveHighEn = CyFalse;
- gpioComplexConfig.pinMode = CY_ U3P_ GPIO_ MODE_ STATIC;
- gpioComplexConfig.intrMode = CY_ U3P_ GPIO_ INTR_ TIMER_ THRES;
- gpioComplexConfig.timerMode = CY_ U3P_ GPIO_ TIMER_ POS_ EDGE;
- gpioComplexConfig.timer = 0;
- gpioComplexConfig.period = 0x00000001; // Reset after each interrupt
- gpioComplexConfig.threshold = 0x00000001; //Generate interrupt every 125us
apiRetStatus = CyU3PGpioSetComplexConfig(GPIO_ TIMER, &gpioComplexConfig);
if (apiRetStatus != CY_ U3P_ SUCCESS)
{
vJackyTestPrintErr("CyU3PGpioSetComplexConfig failed: %d\n",apiRetStatus);
}
/*****************************************************/
//Interrupt callback function:
/****************************************************/
void CyFxGpioIntrCb (
uint8_ t gpioId /* Indicates the pin that triggered the interrupt */
)
{
if(GPIO_ TIMER == gpioId)
{
dwTimeCountNow++;
if(dwTimeCountNow>TIME_ COUNT_ MAX)
{
dwTimeCountNow = 0;
}
}
}
/*******************************************/
//How can timer interrupt be generated? If GPIO can interrupt timer, is there a problem with my code?
//I'm looking forward to the teacher's reply
Solved! Go to Solution.
- 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