Can the Ti BLE-Stack be used with a RTOS? Can you please point me to some examples or documentation of how one would use the stack in context of a larger, RTOS infrastructure on a CC2540?
Thanks.
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.
Hello pixbroker,
I wouldn't say that an RTOS cannot be used with the BLE-Stack. As YiKai mentioned, the BLE OSAL is basically an OS. It does have to perform certain operations in a specific time frame to maintain a connection and stay compliant with the BLE Standard. This means that execution of some of you events will be delayed and the smallest resolution it can be is 1ms
You could implement a RTOS, but it wouldn't be that straightforward and there are no documents or examples to my knowledge to do so. To get the OSAL to operate as an RTOS, you would have to be able to live with constant loss of connection between BLE Devices. The OSAL enters into "critical states" where interrupts are disabled. You would have to circumvent this by allowing your RTOS to supersede the critical state.
To be honest, unless you are performing something that really shouldn't be done on an 8-bit MCU running a BLE-Stack, you don't need an RTOS. As long as the input for your interrupt is held for a period greater than the the time it takes to execute the critical state, you will be able to perform your task. Keep the task executed in the interrupt routine to a few instructions and you ahouldn't have a problem.
Thanks,
Hello Adrian,
Thanks for the input. Indeed, the proper implementation of sensor input and utilization of DMA wherever possible should satisfy most requirements that you would use an 8-bit MCU on. Where you using the CC2540 for the Roland Project?
As for the OSAL, the good thing about it is that you can turn it off so to speak. To be more precise, you can use preemption as a way to yield to another scheduling method. You could also just disable all tasks. The problem as I had mentioned is that you will lose your current BLE connection.
If you really wanted to, I suppose you could just rewrite the scheduling and taskEvent process to suit your needs. The only issue there is that on the CC2540 you don't have access to the 24-bit timer and therefore you would be limited to using a 16-bit timer for your OS. (Unless you somehow get access to the ROM API or decode the library files)
One trick you can use is to not create an event and have a function (a small one) run in the _ProcessEvent routine. It will get called everytime this functions runs so you are no longer limited to the 1ms timer Event. I use this to test if there is data available from the USB so that data can be streamed through the USB.
There are many ways to get it to work. It just won't conform to BLE standards anymore.
Thanks,
I should have probably been a bit more descriptive with my original post. so i would like to provide some more details:
we are designing a system that is using BLE only "sometimes", i.e. about 5% of the total uptime of the system. while using BLE, we have no problem using the stack as is, with osal.
My question was more geared toward the other (majority) of the time where we would like to use the 2540 just as a plain old 8051 MCU and were wondering how an RTOS could be used for that portion of the runtime.
i.e. would it be feasible to "switch on the BLE stack" when we need it and otherwise run on some other code?
thanks
Check svendbt's FAQ sticky on the front of this forum: http://e2e.ti.com/support/wireless_connectivity/f/538/t/404236. The links have moved around a bit.