Part Number: CC3200-LAUNCHXL-RD
Hello,
My objective is to use implement a Timer to document the frequency of a TSL235R Light to Frequency detector using my board which is based on the LaunchXL RD. I have been able to get lots of code to work and have a functioning board until now.
I have been unable to properly configure the timer_cc example to work for GPIO Pin 12 / Package Pin 3. Below is my code for implementing the timer and trying to map it to this pin.
I am using ENERGIA but I also cannot get it to work in CCS with the SDK timer_cc example code.
I know I am connected to the GPIO_12 Package pin 3 and can only get an interrupt to fire if I use the two lines of code that are commented out. When I dont use them and try to get the timer to fire the interrupt the TimerISR() is never accessed. I have tried so many different combinations from the Pin and GPIO.c to try and get the interrupt/timer to work but to no avail.
I feel I am missing something when creating the PinMux mapping and I am just not triggering the TimerISR(). Right now my code just prints out :
0.00
0.00
to the serial and I never see the YELLOW_LED go Low indicating i have an interrupt. Using PIN_03 instead of PIN_05 does not correct the issue.
#include "timer.h"
#include "prcm.h"
#include "pin.h"
#define TIMER_FREQ 80000000
int count = 0;
float r = 0;
void setup()
{
Serial.begin(9600);
delay(100);
pinMode(YELLOW_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
PinConfig();
TimerConfig();
//Using these two following lines of code makes the interrupt work properly therefore I know my TSL235R is connected to PIN_05. And using any other Peripheral Clock other than TIMERA1_BASE stops the code from working. All these point to the fact I am at the correct PIN_05 and looking to map to CCP03 GPIO PIN 12 Pkg Pin 3.
//pinMode(PIN_05, INPUT_PULLUP);
//attachInterrupt(PIN_05, TimerISR, FALLING);
}
void loop()
{
while(1){
digitalWrite(YELLOW_LED, HIGH);
delay(1000);
float v = 80000000/count;
Serial.println(v);
Serial.println(r);
count = 0;
}
}
void TimerISR()
{
digitalWrite(YELLOW_LED,LOW);
TimerIntClear(TIMERA1_BASE,TIMER_CAPB_EVENT);
//Serial.println("Interrupt Hit");
r = TimerValueGet(TIMERA1_BASE, TIMER_B);
count++; //count how many times the interrupt fires before the loop Serial print
}
void PinConfig(){
digitalWrite(YELLOW_LED, HIGH);
delay(100);
PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
MAP_PinDirModeSet(PIN_05, PIN_DIR_MODE_IN); //PIN_05 is Pkg Pin 3 and GPIO PIN 12 and is linked to the CCP03 Timer
MAP_PinTypeTimer(PIN_05, PIN_MODE_12);
MAP_PinConfigSet(PIN_05, PIN_TYPE_STD_PU, 0x00); //I want the pin to be an input and should not need an output drive strength.
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED,HIGH);
}
void TimerConfig(){
digitalWrite(YELLOW_LED, LOW);
delay(100);
MAP_TimerIntRegister(TIMERA1_BASE, TIMER_B, TimerISR);
MAP_TimerConfigure(TIMERA1_BASE, (TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_CAP_TIME));
MAP_TimerControlEvent(TIMERA1_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE);
MAP_TimerLoadSet(TIMERA1_BASE, TIMER_B, 0XFFFF);
MAP_TimerIntEnable(TIMERA1_BASE, TIMER_CAPB_EVENT);
MAP_TimerEnable(TIMERA1_BASE, TIMER_B);
digitalWrite(RED_LED, LOW);
digitalWrite(GREEN_LED,LOW);
}
Many Thanks,
Sam