This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Application with optionally run TI-RTOS/BLE

Part Number: CC2640R2F
Other Parts Discussed in Thread: SYSBIOS

Hello,

I would like to develop an application which runs BLE (using TI-RTOS) optionally, based on a certain condition at startup. For example, a gpio status - if a given pin is held high at startup, the application will run BLE, otherwise not. I need to run a precisely timed task (e.g. 1KHz) and I noticed that during SYSBIOS execution a clock timed routine has some jitter (toggling a GPIO from this routine I see the square wave period is not always exaclty the same).

I thought to run SYS-BIOS only when BLE is required, and in this scenario the timed task is not required, so they are mutually exclusive and should not bother each other.

I wrote some code to run a timer with interrupt routine attached, like this:

TimerDisable(GPT1_BASE, TIMER_A);
TimerConfigure(GPT1_BASE, TIMER_CFG_A_PERIODIC_UP);
TimerLoadSet(GPT1_BASE, TIMER_A, TIMER_LOADSET);
TimerMatchSet(GPT1_BASE, TIMER_A, TIMER_MATCH);
TimerIntRegister(GPT1_BASE, TIMER_A, timerCallback);

TimerEnable(GPT1_BASE, TIMER_A);

but the TimerDisable function hangs:

__STATIC_INLINE void
TimerDisable(uint32_t ui32Base, uint32_t ui32Timer)
{
// Check the arguments.
ASSERT(TimerBaseValid(ui32Base));
ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
(ui32Timer == TIMER_BOTH));

// Disable the timer module.
HWREG(ui32Base + GPT_O_CTL) &= ~(ui32Timer &
(GPT_CTL_TAEN | GPT_CTL_TBEN));
}

at the HWREG execution; CCS shows the message:

No source available for "xdc_runtime_Timestamp_get32__E() at D:/personal\elettronica\progetti\msp430\wsp\ble_demo\debug\ble_demo.out:{3} 0x1001c904{4}" 

sometimes other messages related with SYS BIOS are shown. It looks like there is something hidden, related with SYSBIOS, which is running before BIOS_start() is called, or even before main().

The above code is the only code in the main() function, no BIOS_start() is called (just experimenting right now).

The project is derived from project zero using Simplelink 5.10.0.2

Thanks in advance

Fabio

  • Another example of message shown by CCS debug when the TimerDisable function is executed:

    No source available for "ti_sysbios_hal_Hwi_HwiProxy_Module__startupDone__S__mangled__() at D:/personal\elettronica\progetti\msp430\wsp\ble_demo\debug\ble_demo.out:{3} 0x1001b988{4}"

  • Hi Fabio,

    No source available for "xdc_runtime_Timestamp_get32__E() at D:/personal\elettronica\progetti\msp430\wsp\ble_demo\debug\ble_demo.out:{3} 0x1001c904{4}" 

    This message is expected and normal. Some functions are only provided as libraries. Here these functions are in ROM. As a consequence the debugger cannot interpret the code stored and send you this message.

    When it comes to the timer question, please verify the code works when the BLE stack is not used. Then verify there is no resources conflict (e.g. you use the timer used by another thread or the BLE stack).

    Last but not least, you may want to review a post I have written.

    Best regards,

  • Hello Clement,

    thanks for the reply.

    The above code to setup and run the timer is the only one executed in main(). No BLE stack is run, no SYSBIOS, nothing else. Basically my main is:

    void main(void)

    {

    TimerDisable(GPT1_BASE, TIMER_A);
    TimerConfigure(GPT1_BASE, TIMER_CFG_A_PERIODIC_UP);
    TimerLoadSet(GPT1_BASE, TIMER_A, TIMER_LOADSET);
    TimerMatchSet(GPT1_BASE, TIMER_A, TIMER_MATCH);
    TimerIntRegister(GPT1_BASE, TIMER_A, timerCallback);

    TimerEnable(GPT1_BASE, TIMER_A);

    while(1);

    }

    plus of course a basic timerCallback to check that timer is running, and the needed #defines.

    I will test your 1ms example.

    Best regards

    Fabio

  • Hello, I tryied to integrate your example in my project_zero (to start from scratch with a clean BLE application) but link fails with this error message:

    "configPkg/linker.cmd", line 701: error #10099-D: program will not fit into available memory. placement with alignment fails for section ".resetVecs" size 0x3c , overlaps with ".intvecs", size 0xc8 (page 0)

    I made the following modifications to project_zero:

    • added the relevant code to init and start the timer, taken from your timer example.
    • added the nortos_cc26x0r2.aem3 library to linker options
    • added the call to NoRTOS_start() to main() code, before timer initialization and start.

    Before that I successfully run the timer example to get a 1KHz square wave using a no rtos environment. Now I need to mix no-rtos and rtos/BLE code in order to run the same firmware in one of the two possible modes, depending on a GPIO status.

    Thanks

    Fabio

  • Hi Fabio,

    The link issue is due to a conflict between NORTOS and TIRTOS - I guess both of them are trying to right the reset vectors.

    The code I have pointed you to should work with TIRTOS too.

    Generally speaking, TIDrivers are not meant to be executed before turning on the RTOS (i.e. NoRTOS_start() or BIOS_start()). In other words, I would recommend to write the code into an actual task rather than in the main function.

    Best regards,

  • Hello, I understand that the two environments (NORTOS and TIRTOS) are meant to be mutually exclusive, it is quite reasonable.

    The timer code runs with TIRTOS too but the timer callback execution has a jitter that is clearly visible on the oscilloscope toggling a pin from the callback.

    Basically I need a way to run a piece of code on a timed basis with the same precision of the NORTOS mode, but during the RTOS execution. I think that the jitter is due to interrupts disabled by TIRTOS in some circumstances, and this result in a slightly variable timer period (or, to say better, some effect due to latency before timer interrupt are served while SO is running).

    As alternative I tried to run the timer code without running BIOS_start() but I could not find a stable solution, since the timer callback sometimes is executed, sometimes not, without a clear reason why this happens. At least I was not able to get a reliable code. From other forum posts I got the idea that this is not possible but I'm not sure. If you confirm I will consider a different architecture where the timed code (an ADC conversion and GPIO set/reset based on some algorithm) is executed by Sensor Controller, that should be independent from TIRTOS.

    Best regards.

    Fabio

  • Hi Fabio,

    Actually if jitters is important for you, then you should run this code on the Sensor Controller. As the Sensor Controller is an independent core, the other interrupts won't interfere. 

    You can review our documentation here to get started with the Sensor Controller. I will kindly ask you to open a new thread if you need assitance iwth it.

    Best regards,