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

Softdevice crashes with PPI

Hi

I've made a small application on a NRF51422 device. It's is loaded with the newest version of S320 and the newest API from you homepage.

In my application i need a couple of PWMs to trigger some external hardware. These PWMs are created using Timer2 and some PPI events/tasks Without the Softdevice enabled this works flawless. However, if the Softdevice is enabled the application crashes into a hard as soon as I set up the first CH it will jump into the HardFault handler.

I've stolen some code for setting up the Softdevice from one of the example projects (\Nordic\nrf51422\Board\nrf6310\s310\ble_app_hrs), so I'm pretty sure that part is correct - even though it's not really that platform I'm working on. I'm calling the function ble_stack_init() to initialize everything.

My set-up of the PPI channels is as so:

NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0]; // event when reaching the duty cycle value
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->CH[1].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[1]; // event when reaching the max counter value
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];

As far as I can see from the debugger the app will chrash as soon as i execute the first line above. I've tried changing the channel numbers around a bit, but I get the same result.

I've tried switching the order around, so I'll enable the Softdevice first, and then set the PPI channels. This appear to be working - atleast it doesn't chrash. However(!): If I then enable Timer2, as I need it for the PWM, during the PPI set-up (before enabling the SD) the SD enabling will throw the "NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION" error.

So I guese my questions are: 1: Are there any kinds of rules I'm not aware of saying you are not allowed to change the PPI while the SD is enabled. 2: How do I fix the interrupt error thrown?

The hardware is one of Dynastreams eval boards, but I don't think it's an hardware issue.

Best regards

Parents
  • Hi,

    Since the softdevice uses parts of the NRF_PPI peripheral, it protects the whole peripheral, so that the application cannot access it directly (if you try, you'll end up in HardFault). So, using this protection, the only way we're allowed to access it is through the nrf_soc API (sd_ppi-prefixed functions). If you set up the PPI before starting the softdevice, the softdevice will only care about the PPI channel it needs and leave the others untouched. BTW: I'll send you a PM regarding your last question:)

  • Hi Håkon. Follow up question.

    We tried changing the SD to S110-SD-v7 from S310 and updated the SDK to 6.0.0 by overwriting the /Source/ and /Include/ folders in our project folder. The IROM and RAM adresses has been updated as specified in the v7 migration guide.

    Now we get some wierd error when initializing the GAP. The init code is pretty much the same as the one in the gap_params_init(void) function in the nrf51-ble-app-lbs project on your github. But our sd_ble_gap_device_name_set() function returns BLE_ERROR_INVALID_ATTR_HANDLE (0x3001) and the program keeps rebooting as a result.

    Any ideas? We looked through all of the documentation, but there's no mention of anything we should be aware of in this regard.

Reply
  • Hi Håkon. Follow up question.

    We tried changing the SD to S110-SD-v7 from S310 and updated the SDK to 6.0.0 by overwriting the /Source/ and /Include/ folders in our project folder. The IROM and RAM adresses has been updated as specified in the v7 migration guide.

    Now we get some wierd error when initializing the GAP. The init code is pretty much the same as the one in the gap_params_init(void) function in the nrf51-ble-app-lbs project on your github. But our sd_ble_gap_device_name_set() function returns BLE_ERROR_INVALID_ATTR_HANDLE (0x3001) and the program keeps rebooting as a result.

    Any ideas? We looked through all of the documentation, but there's no mention of anything we should be aware of in this regard.

Children
No Data
Related