Jump to content
43oh

Timers with Interrupts of CC-3200 on Energia


Recommended Posts

Hi ,

I am unable to use the Timers of CC3200 on Energia. Kindly view my code snippet and see what errors have I made.I am getting the errors which I have mentioned at the last.

 

CODE:-

#include <driverlib/timer.h>

#include <inc/hw_timer.h>

void setup()
{
pinMode(2,INPUT_PULLUP);
pinMode(9,OUTPUT);
noInterrupts();
TimerIntStatus(TIMERA0_BASE,true);
TimerDisable(TIMERA0_BASE,TIMER_A);
TimerIntDisable(TIMERA0_BASE,TIMER_TIMA_MATCH);
TimerConfigure(TIMERA0_BASE,TIMER_CFG_A_PERIODIC_UP);
TimerPrescaleSet(TIMERA0_BASE,TIMER_A,32);
TimerMatchSet(TIMERA0_BASE,TIMER_A,7500);
TimerIntRegister(TIMERA0_BASE,TIMER_A,start);
TimerControlStall(TIMERA0_BASE,TIMER_A,false);
TimerControlLevel(TIMERA0_BASE,TIMER_A,false);
attachInterrupt(0,zeroCrossingInterrupt, RISING);
interrupts();
TimerIntEnable(TIMERA0_BASE,TIMER_TIMA_MATCH);
}

void loop()
{
}

void zeroCrossingInterrupt()

digitalWrite(9,LOW);
TimerEnable(TIMERA0_BASE,TIMER_A);
}

void start()

digitalWrite(9,HIGH);
TimerDisable(TIMERA0_BASE,TIMER_A);
}

 

Errors:-

In file included from sketch_aug17a.ino:1:0:
C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:164:31: error: 'tBoolean' has not been declared
tBoolean bInvert);
^
C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:168:31: error: 'tBoolean' has not been declared
tBoolean bStall);
^
C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:193:59: error: 'tBoolean' has not been declared
extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked);

 

Kindly help asap.

Link to post
Share on other sites

Thanks,

I myself included the correct header files and the code is now compiling and can be downloaded into the cc3200 board.Now the problem that I am facing is that I am using a zero crossing detector to detect rising edge and on detecting it generate a pulse.But using the code below I am able to trigger the zerocrossing interrupt when timer part is commented.When I use the entire code even the detection part is not working

.

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/hw_types.h"
#include "debug.h"
#include "interrupt.h"
#include "timer.h"
 
void setup()
{
pinMode(2,INPUT_PULLUP);
pinMode(9,OUTPUT);
noInterrupts();
timerinit();
attachInterrupt(2,zeroCrossingInterrupt, RISING);
interrupts();
//TimerIntEnable(TIMERA0_BASE,TIMER_TIMA_MATCH);
Serial.begin(9600);
}
 
void timerinit()
{
//TimerIntStatus(TIMERA0_BASE,true);
TimerDisable(TIMERA0_BASE,TIMER_A);
TimerIntDisable(TIMERA0_BASE,TIMER_TIMA_MATCH);
TimerConfigure(TIMERA0_BASE,TIMER_CFG_A_PERIODIC_UP);
TimerPrescaleSet(TIMERA0_BASE,TIMER_A,32);
TimerMatchSet(TIMERA0_BASE,TIMER_A,7500);
TimerIntRegister(TIMERA0_BASE,TIMER_A,start);
}
 
void loop()
{
}
 
void zeroCrossingInterrupt()
   {  
    digitalWrite(9,LOW);
    TimerEnable(TIMERA0_BASE,TIMER_A);
    Serial.println("0k");
   }
   
void start()
  digitalWrite(9,HIGH);
  TimerDisable(TIMERA0_BASE,TIMER_A);
  Serial.println("hi");
}
Link to post
Share on other sites

I have modified the code and now the zero crossing interrupt is occurring.But the timer is still not functioning.Can you see and tell whether I have configured it right?

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/hw_types.h"
#include "debug.h"
#include "interrupt.h"
#include "timer.h"
#include "driverlib/prcm.h"
#include "inc/hw_gprcm.h"
#include "wiring_private.h"
#include "driverlib/rom_map.h"
#include "driverlib/pin.h"

void setup()
{
pinMode(2,INPUT_PULLUP);
pinMode(4,OUTPUT);
noInterrupts();
MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0,PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralReset(PRCM_TIMERA0);
MAP_TimerConfigure(TIMERA0_BASE,TIMER_CFG_B_PERIODIC_UP);
MAP_TimerIntRegister(TIMERA0_BASE,TIMER_B,start);
MAP_TimerIntEnable(TIMERA0_BASE,TIMER_TIMB_MATCH);
MAP_TimerPrescaleSet(TIMERA0_BASE,TIMER_B,32);
MAP_TimerMatchSet(TIMERA0_BASE,TIMER_B,7500);
MAP_TimerLoadSet(TIMERA0_BASE,TIMER_B,0);
MAP_TimerEnable(TIMERA0_BASE,TIMER_B );
attachInterrupt(2,zeroCrossingInterrupt, RISING);
interrupts();
Serial.begin(9600);
}


void loop()
{
}

void zeroCrossingInterrupt()

digitalWrite(4,LOW);
MAP_TimerLoadSet(TIMERA0_BASE,TIMER_B,0);
MAP_TimerEnable(TIMERA0_BASE,TIMER_B );;
Serial.println("0k");
}

void start()

digitalWrite(4,HIGH);
MAP_TimerIntClear(TIMERA0_BASE,TIMER_TIMB_MATCH);
MAP_TimerIntDisable(TIMERA0_BASE,TIMER_TIMB_MATCH);
MAP_TimerDisable(TIMERA0_BASE,TIMER_B );;

Serial.println("hi");

}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...