Other Parts Discussed in Thread: SYSBIOS, CC3200
Tool/software: TI-RTOS
Hi,
I'm a newbie to TI-RTOS and I'm having trouble getting my blinky to work on my CC1310 Launchpad.
I think I am missing something about the periodicity or something is pre-empting my HWI.
-----
app.cfg
***
(Other settings excluded, I am using a clean TI .cfg from a template)
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
Clock.tickPeriod = 10;
Clock.tickMode = Clock.TickMode_PERIODIC;
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
*****************
Application:
/* XDC Module Headers */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
//#include <xdc/runtime/Types.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
/* BIOS Module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/hal/Timer.h>
//#include <ti/sysbios/hal/Hwi.h>
#include <ti/sysbios/knl/Queue.h>
/* Example/Board Header files */
#include "Board.h"
/* NOTE: See tistdtypes.h, for data types */
Timer_Handle timerHandle;
/* Create Timer Parameters object */
Timer_Params timerParams;
Void tickFxn(UArg arg0)
{
static Uint16 cTimerInterrupts;
cTimerInterrupts++;
if(cTimerInterrupts == 100)
{
/* Turn on user LED */
GPIO_toggle(Board_GPIO_LED0);
GPIO_toggle(Board_GPIO_LED1);
cTimerInterrupts = 0;
}
}
/*
* ======== main ========
*/
int main()
{
/* Set Error Blocks */
Error_Block eb;
/* Initialize Error Block */
Error_init(&eb);
/* Initialize Board */
Board_initGeneral();
/* Initialize GPIO */
GPIO_init();
/* Configure the LED pin */
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
/* Initialize Timer */
Timer_Params_init(&timerParams);
timerParams.period = 5000; /* 5ms seconds timer (1 = 1us) */
timerParams.periodType = Timer_PeriodType_MICROSECS;
timerHandle = Timer_create(Timer_ANY, tickFxn, &timerParams, &eb);
if (timerHandle == NULL)
{
System_abort("Timer create failed");
}
/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON);
BIOS_start(); /* does not return */
}
*************************
-------------------------------------
When I debug this function using breakpoints, I see the LEDs toggling correctly off of cTimerInterrupts.
When I run the function I don't see the LEDs toggling.
Here is my understanding of what I have set up.
In app.cfg, I have the Clock tick period set to 10us. That is actually an HWI that is hard posting. You should use that clock tick to trigger SWIs?
Regardless of the clock period, I have set another HWI that is set to go off every 5ms. With my LED timer variable, I should see the LED toggles every 500ms?
A few question:
1)In general practice should I be using the Clock module and SWIs like in the SYS_BIOS example to toggle an LED like this? Is the periodicity actual 10us?
2)What is going on with the Timer tickFxn task (ISR?)? Why do not I see the led blinking every 500ms? Am I incorrect about the period of the timer I setup in main? Is this HWI getting pre-empted with the 10us Clock module running?
I think the context here isn't so much to get the LED blinking, but my concern is more like when we have HWIs (GPIO callbacks on button presses, or incoming driver inputs that need an HWI to service them) how do I make sure I'm not goofing up the priority. (For this example, I would probably blink the LED based on the SYS/BIOS clock examples type approach if this was the whole application).
Thanks,