Hello,
I have a really strange problem with the CC3200. I'm trying to measure the time between edges on a input port. As example I used the timer_cc. My code is nearly the same, but instead of measuring the edges on the input line it is measuring the RTC clock. (Measured with an osci this line, there is no RTC.) And I don't get how this is possible. Here the code:
volatile uint32_t captureValue = 0; volatile unsigned long debugReg = 0; void MyTimerHandler() { MAP_GPIOPinWrite(GPIOA0_BASE, GPIO_INT_PIN_0, 0); unsigned long ulTimerState = MAP_TimerIntStatus(TIMERA1_BASE, 1); if (ulTimerState & TIMER_CAPA_EVENT) { captureValue = MAP_TimerValueGet(TIMERA1_BASE,TIMER_A); MAP_TimerIntClear(TIMERA1_BASE, TIMER_CAPA_EVENT); MAP_GPIOPinWrite(GPIOA0_BASE, GPIO_INT_PIN_0, 1); } else { __asm("nop"); } } void BoardInit(void) { MAP_IntMasterEnable(); MAP_IntEnable(FAULT_SYSTICK); PRCMCC3200MCUInit(); } int main(int argc, char * argv[]) { BoardInit(); /* Debug LED */ MAP_PRCMPeripheralClkEnable (PRCM_GPIOA0, PRCM_RUN_MODE_CLK); MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false); MAP_GPIODirModeSet (GPIOA0_BASE, GPIO_INT_PIN_0, GPIO_DIR_MODE_OUT); /* timer cc */ MAP_PRCMPeripheralClkEnable( PRCM_TIMERA1, PRCM_RUN_MODE_CLK); MAP_PRCMPeripheralReset( PRCM_TIMERA1); MAP_PinTypeTimer(PIN_02, PIN_MODE_12); MAP_TimerIntRegister( TIMERA1_BASE, TIMER_A, MyTimerHandler); MAP_TimerConfigure( TIMERA1_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME)); MAP_TimerControlEvent(TIMERA1_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE); MAP_TimerLoadSet(TIMERA1_BASE, TIMER_A, 0xFFFFuL); MAP_TimerIntEnable( TIMERA1_BASE, TIMER_CAPA_EVENT); MAP_TimerEnable( TIMERA1_BASE, TIMER_A); while(1) { debugReg = MAP_TimerIntStatus(TIMERA1_BASE, 1); __asm("nop"); } }
The edge it not detected at all. When I uncomment the line MAP_PinTypeTimer(PIN_02, PIN_MODE_12); the behavior doesn't change at all. The interrupt is coming in like as a RTC would be connected. But real edges on the Pin2 Port are not triggering an interrupt at all.
Then I tried to use the GPIO instead of the timer. I just wanted to have an interrupt on each edge. In that case the interrupt was not coming at all. But when I used the polling mode in the while loop, that was working fine. Here the code:
void MyGpioHandler() { MAP_GPIOPinWrite(GPIOA0_BASE, GPIO_INT_PIN_0, 0); unsigned long ulPinState = GPIOIntStatus(GPIOA1_BASE,1); if(ulPinState & GPIO_PIN_3) { MAP_GPIOIntClear(GPIOA1_BASE,GPIO_INT_PIN_3); MAP_GPIOPinWrite(GPIOA0_BASE, GPIO_INT_PIN_0, 1); } } int main(int argc, char * argv[]) { BoardInit(); /* Debug LED */ MAP_PRCMPeripheralClkEnable (PRCM_GPIOA0, PRCM_RUN_MODE_CLK); MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false); MAP_GPIODirModeSet (GPIOA0_BASE, GPIO_INT_PIN_0, GPIO_DIR_MODE_OUT); MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK); MAP_PRCMPeripheralReset( PRCM_GPIOA1); MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, true); MAP_GPIODirModeSet(GPIOA1_BASE, GPIO_PIN_3, GPIO_DIR_MODE_IN); MAP_GPIOIntTypeSet(GPIOA1_BASE, GPIO_INT_PIN_3, GPIO_FALLING_EDGE); MAP_IntPrioritySet(INT_GPIOA1, INT_PRIORITY_LVL_1); MAP_GPIOIntRegister(GPIOA1_BASE, MyGpioHandler); MAP_GPIOIntClear(GPIOA1_BASE,GPIO_INT_PIN_3); MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_3); while(1) { debugReg = GPIOIntStatus(GPIOA1_BASE,1); #if 0 if(ulPinState & GPIO_PIN_3) { MAP_GPIOIntClear(GPIOA1_BASE,GPIO_INT_PIN_3); MAP_GPIOPinWrite(GPIOA0_BASE, GPIO_INT_PIN_0, 1); } #endif __asm("nop"); } }
So my questions are why is the timer cc measuring the RTC? And why is the GPIO interrupt not coming?
Thank you in advance.
Daniel