Hi, we've been debugging our application that is based on CC1310 and we've had issues with the GPTM. It appears as if the RTOS scheduler interferes with the timer interrupts. I was able to write a very small program in which there is just one task that sleeps for about 30 ms, wakes up, turns on/off the board LED_2 and continues the cycle. The periodic timer generates an interrupt every 1.67ms (an arbitrary number) and turns on/off another board LED - LED_3. The program runs on the SmartRF06 dev board and is based on an example program - rfPacketTx_CC1310DK.
The complete source code of the main file is below.
/***** Includes *****/
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Mailbox.h>
#include <ti/sysbios/knl/Event.h>
/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <driverlib/timer.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
/* Board Header files */
#include "Board.h"
#include "smartrf_settings/smartrf_settings.h"
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;
PIN_Config pinTable[] =
{
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
#define TASK_STACK_SIZE 1024
#define TASK_PRIORITY 2
static void waitingTaskFunction(UArg arg0, UArg arg1);
static Task_Params waitingTaskParams;
Task_Struct waitingTask;
static uint8_t waitingTaskStack[TASK_STACK_SIZE];
void interruptTimerA(void)
{
uint32_t status = TimerIntStatus(GPT0_BASE, true);
PIN_setOutputValue(ledPinHandle, Board_LED3,1);
if (TIMER_TIMA_TIMEOUT & status) {
TimerIntClear(GPT0_BASE, TIMER_TIMA_TIMEOUT);
}
PIN_setOutputValue(ledPinHandle, Board_LED3,0);
}
void timerInit(void)
{
Power_setDependency(PowerCC26XX_PERIPH_GPT0);
TimerDisable(GPT0_BASE, TIMER_A);
TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
TimerPrescaleSet(GPT0_BASE, TIMER_A, 255); // prescaler is 256 - 187.5 kHz
// register ISR and enable NVIC interrupt for timer
*((uint32_t *)(0x20000000 + 31*4)) = (uint32_t)interruptTimerA;
IntEnable(31);
TimerLoadSet(GPT0_BASE, TIMER_A, 313); // a random number
TimerIntClear(GPT0_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable(GPT0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(GPT0_BASE, TIMER_A);
}
void WaitingTask_init(void)
{
Task_Params_init(&waitingTaskParams);
waitingTaskParams.stackSize = TASK_STACK_SIZE;
waitingTaskParams.priority = TASK_PRIORITY;
waitingTaskParams.stack = &waitingTaskStack;
Task_construct(&waitingTask, waitingTaskFunction, &waitingTaskParams, NULL);
}
static void waitingTaskFunction(UArg arg0, UArg arg1)
{
timerInit();
for (;;) {
// Task_sleep(30000/Clock_tickPeriod); // 30 ms wait
PIN_setOutputValue(ledPinHandle, Board_LED2, 1);
PIN_setOutputValue(ledPinHandle, Board_LED2, 0);
}
}
int main(void)
{
Board_initGeneral();
ledPinHandle = PIN_open(&ledPinState, pinTable);
if (!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}
WaitingTask_init();
BIOS_start();
return (0);
}
When the Task_sleep is commented out, as above, the system runs as expected - the task continuously executes, toggling LED_2. The timer interrupt happens every 1.67ms and pulses LED_3. See the logic analyzer capture below.
Figure 1 - no task scheduling. The one and only task is constantly ready and executes as LED_2 shows The timer interrupt happens every 1.67ms as can be seen by observing LED_3.
But the moment the Task_sleep is uncommented, the system starts working unexpectedly. The logic analyzer capture below shows the start of the program on the dev board. For a few first milliseconds you can see the timer interrupts every 1.67ms and then they stop. From that moment on, the timer interrupt would still happen, albeit sporadically. See figure 3. Strangely enough, the subsequent timer interrupts would always coincide with the time when the task wakes up.
Figure 2. - starting the application with RTOS switching. The timer ISR runs for a short while but then breaks.
Figure 3 - the same trace as in figure 2, but zoomed out.
We suspect that there is a problem with TI-RTOS and would like to hear a comment from TI people.
Thank you,
Sergey









