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

nRF52 scheduler

I am creating a system (nRF52 SDK11.0.0 s132) that will get a data ready interrupt on a GPIO (configured via GPIOTE with a handler) from a sensor every 4ms. The sensor has an SPI slave interface for reading the data. The handler will either set a flag for that will trigger an SPI data read in the main superloop, use the scheduler to trigger an SPI data read, or trigger an SPI data read directly.

After a number of samples, a data processing function will be run on these samples that takes 10ms to run (a double buffer scheme will be used). Hence the data processing function needs to run in a lower priority context than the data reads, otherwise I will miss samples.

Can I use the scheduler in this scheme, and if so, how do I set the priorities of the data read versus the algorithm tasks? If not, what's the simplest (and robust) way to do this without RTOS?

Parents
  • The way I understand it, the main point is that your algorithm "task" needs to run with a lower priority than the sampling. The scheduler from the SDK does not have a concept of priorities, but you could for example use the scheduler (or another custom mechanism) to move the algorithm to the main context. The sampling and SPI read could be in a higher interrupt priority context, where you handle it directly in the interrupt routine / event handler. Typically you would use the application timer to sample at a regular interval, and the priority would be APP_LOW.

  • GPIOTE uses _PRIO_APP_HIGH (=2). If I call the blocking SPI read directly from the GPIOTE handler, will SPI function properly with _PRIO_APP_LOW (=6)? And even if it matches the GPIOTE priority, will it still work since it cannot preempt another interrupt of the same priority? Would the similar concept apply if using the application timer, except that in this case the SPI priority could be set higher than the timer priority?

Reply
  • GPIOTE uses _PRIO_APP_HIGH (=2). If I call the blocking SPI read directly from the GPIOTE handler, will SPI function properly with _PRIO_APP_LOW (=6)? And even if it matches the GPIOTE priority, will it still work since it cannot preempt another interrupt of the same priority? Would the similar concept apply if using the application timer, except that in this case the SPI priority could be set higher than the timer priority?

Children
No Data
Related