I needed to use external clock to count up/down the timer for my CC3200 project. CC3200 support this as I can see in the section 18.104.22.168 "Input Edge Count Mode" of CC3200 technical reference manual. The implementation was not so difficult, and here is how I tested it.
- Assign GPIO pin and CCP/timer
I decided to use GPIO0 pin (PIN_50) on CC3200 launchpad, and use the pin as GP_CCP00 that is assigned as timer0 clock input. Refer to technical reference manual for "pin mux config mode value". In my case, Pin 50 should be "7" to configure it as timer capture port.
You can also refer to the same manual to see which timer that GP_CCP00 is connected. GT_CCP00 I use is for 16-bit timer 0 as below.
The block diagram shown before the above table is quite useful to understand how it is internal connected.
Based on above configuration, I added following lines in the pin configuration file.
// Enable Peripheral Clocks
// Configure PIN_50(GPIO00) for EXTCLK GPIOInput
MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false);
MAP_GPIODirModeSet(GPIOA0_BASE, 0x01, GPIO_DIR_MODE_IN);
// Configure PIN_50 for TIMERCP0 GT_CCP00
MAP_PinTypeTimer(PIN_50, PIN_MODE_7); // refer to datasheet pin list
- Configure Timer and Interrupt registers
This is the configuration for my edge count timer and timer interrupt.
void EXTCLKInit(P_INT_HANDLER EXTCLKInterruptHdl)You can change MAP_TimerMatchSet parameter to tune the timing. My setting is "374".
// Register timer interrupt hander
// Configure the timer in edge count mode
// Set the detection edge
// Set the reload value
// Set Match Count Value for Timer Interrupt
- Configure Interrupt handler
This is the interrupt handler that is called by the above timer interrupt.
For the quick test purpose, you can just add LED toggle function.
//Clear EXTCLK Timer Interrupt Flag
ClearEXTCLKInt(); // Toggle LED
//LED1 = 1; //LED on
//LED1 = 0; //LED off
CC3200 Technical Reference Manual