GPIO bit-banging and BLE radio activity

Hello,

I'm using nrf52840 together with HX711 24bit ADC. My application samples the ADC every 12.5ms (80Hz rate) and the sample is sent out via BLE notification.
The HX711 uses non-standard SPI like interface that has strict timing requirements.

When the high priority radio interrupt is triggered, it leads to stretching the clock pulse beyond the 50us limit. After 60us, the ADC goes into power-down mode.

   

The driver continues to read the remaining bits and it results to:
1) Garbage data
2) Delayed next reading by 50ms (settling time of the ADC after reset sequence)

See this captured recording from a logic analyzer:

When interrupts are disabled just for the conversion period (~50us), the app crashes.
We're using nRF Connect SDK v2.4.2

What do you suggest to resolve the situation apart from moving to a dual core mcu?

I can think of 2 approaches here:
1) Rewrite the HX711 driver to use SPI with DMA - not sure how feasible this way is, but this seems like a more robust and preferred solution
2) Use the timeslot API

Can you provide your point of view on this topic?
Thank you in advance.

Jan

Related