AnsweredAssumed Answered

Handling multiple interrupts

Question asked by Vignesh M S on Dec 1, 2017

Hi All,
I have a custom designed PCB with STM32L073RZ + SX1276 LoRa transceiver + LIS2DH12 MEMS accelerometer. LoRa chip uses SPI2 and sensor uses SPI1 interfaces.
Interrupts for the sensor are not being used. The sensor is set to bypass mode at 50 Hz ODR and the data is read by polling.

Following is the sequence happening in the main loop:

while(1)
1)enter stop mode
2)wake-up by rtc after 20 ms
3)read sensor data (x,y,z)
4)accumulate the data
5) do processing
6)sendData(processed data);
7)delay for 3 seconds
8)go to step 1

While functionality is working fine, this doesn't seem to be a power efficient method. LoRa follows class 1 device architecture where two rx slots will open after the end of TX which is purely interrupt based events.
So I had to add a delay of 3 seconds after the sendData() so that the MCU doesn't go back to step 1 until end of RX2 is completed.
Is there a way to make use of the sensor interrupt to wakeup the MCU from stop mode instead of using RTC and make the MCU sleep-wakeup operation dependant on the end of RX2/RXtimeout/RXerror interrupts without using RTOS?
Any help in this regard is much appreciated.

Outcomes