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

nrf52832 zephyr, critical section disable system interrupts

I am using an nrf52832 DK with Zephyr and I have a component that require a block of code to run uninterrupted.  Specifically I am using HX711 with four load cells, and the serial protocol for reading needs protection from system interrupts.  This is the comment in the Arduino API I am porting to Zephyr.

// Protect the read sequence from system interrupts. If an interrupt occurs during
// the time the PD_SCK signal is high it will stretch the length of the clock pulse.
// If the total pulse time exceeds 60 uSec this will cause the HX711 to enter
// power down mode during the middle of the read sequence. While the device will
// wake up when PD_SCK goes low again, the reset starts a new conversion cycle which
// forces DOUT high until that cycle is completed.

On my device I also have an I2c component and it also acts as a BLE peripheral.  Communication with the I2C component may be initiated by commands from the BLE central.  I need to protect the read sequence from all of that, including any log or print statements might be in the code.  I saw Atomic services, but I am not sure how I can use that to create an atomic block of code.

Parents Reply Children
Related