This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CMSIS RTOS with nRF51822 and S110

I'm looking into using the CMSIS RTOS on the nRF51822 with the S110 softdevice which I've used successfully with other Cortex M0 MCUs. I realize the S110 isn't well tested with various RTOS, but documentation indicates it should be possible.

When initializing the softdevice stack with the call to sd_softdevice_enable(), the return code is 0x0D which nrf_error.h indicates is NRF_ERROR_TIMEOUT. However, the documentation for this function in the header files doesn't indicated this is an expected error to be returned. I'm assuming there is some sort of conflict between the RTOS and the softdevice, but it's unclear what the nature of the timeout might be.

Any hints on where I can look to track down the cause of this issue?

Also, if I get the above issue worked out I'm a bit worried about a conflict between the SVC handling by the softdevice and the RTOS. Since the softdevice controls the SVC interrupt handler, I'm assuming it properly chains the SVC calls intended for the RTOS use. Or, is this a bad assumption on my part.

Thanks,

Mike

Parents
  • Hi Guys,

    I am just about to start a project with the 51822 and wanted to use the RTX RTOS. But I only have a couple of months for this project and wasn't too sure if I can pull it off in time. But seeing the kind of progress you are making is giving me hope that this could work. One thing I am still not too sure about is the interrupt latency. My understanding is that the max latency can be as high as 5ms+. Do your applications tolerate this latency or how did you deal with this?

    Thanks

  • Daniel,

    I indeed used RTC1 in place of SysTick. Basically, in the arm_startup_nrf51.s you need to import OS_Tick_Handler() that is provided by CMSIS RTOS in HAL_CM0.c and use it for the RTC1 IRQ handler. I then created an os_tick_irqack() function that handles the clearing the interrupt as shown below:

    // Acknowledge alternative hardware timer interrupt void os_tick_irqack (void) { // Is this a tick condition? if ((NRF_RTC1->EVENTS_TICK != 0) && ((NRF_RTC1->INTENSET & RTC_INTENSET_TICK_Msk) != 0)) { // Clear the interrupt? NRF_RTC1->EVENTS_TICK = 0; } }

    If you look in the CMSIS RTOS source in the file HAL_CM0.c you'll find the normal SysTick_Handler() function, but this function is not used on the Nordic so we use the alternate OS_Tick_Handler() in this file which calls the os_tick_irqack(). I think the SysTick_Handler() in the Nordic assembly file is just a legacy left from the standard CMSIS files. It was confusing to me as well.

Reply
  • Daniel,

    I indeed used RTC1 in place of SysTick. Basically, in the arm_startup_nrf51.s you need to import OS_Tick_Handler() that is provided by CMSIS RTOS in HAL_CM0.c and use it for the RTC1 IRQ handler. I then created an os_tick_irqack() function that handles the clearing the interrupt as shown below:

    // Acknowledge alternative hardware timer interrupt void os_tick_irqack (void) { // Is this a tick condition? if ((NRF_RTC1->EVENTS_TICK != 0) && ((NRF_RTC1->INTENSET & RTC_INTENSET_TICK_Msk) != 0)) { // Clear the interrupt? NRF_RTC1->EVENTS_TICK = 0; } }

    If you look in the CMSIS RTOS source in the file HAL_CM0.c you'll find the normal SysTick_Handler() function, but this function is not used on the Nordic so we use the alternate OS_Tick_Handler() in this file which calls the os_tick_irqack(). I think the SysTick_Handler() in the Nordic assembly file is just a legacy left from the standard CMSIS files. It was confusing to me as well.

Children
No Data
Related