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

impossible to get out of the poll during an interruption (manages the interruption and goes back to sleep)

Hello,

I am on a NRF9160-DK and I am using SDK 1.3.0
I am working on the AWS_FOTA project.
I'm trying to configure the sending of a message in MQTT when pressing a button.
However, I ran into a problem with the poll which causes the processor to sleep. When I press a button, the interrupt is triggered but does not allow you to get out of the poll. So when I try to verify that the press lasts more than 500ms, the processor in the main remains in the poll and makes the verification impossible.

Eventually I would also like to manage interrupts by timer but also by arrival of GPS frame.

Is poll the right solution or is there a way out of this during an interruption? Can I set it to react to the button or to a GPS frame? Is there another solution than the poll which would remain interesting on the energy plan?

Thank you in advance for your help,

best regards,

lecozahu

  • When I press a button, the interrupt is triggered but does not allow you to get out of the poll.

    Is the callback handler for the interrupt triggered? Try to add some logging or toggle a pin in the interrupt handler to verify this. What do you mean by "get out of the poll"? An interrupt should not cause the program execution to go past poll() onto the next line. It should only handle the interrupt by executing the handler and go back to poll() and wait for events.

    One approach could be to use Work Queues and when the button interrupt is triggered, you add the message you want to send to the Work Queue.

    Best regards,

    Simon

  • Thank your for your help,

    the interrupt is triggered, because I pass a variable (flag to 1) during the interrupt and everything works.
    This flag is used when I return to the main to process the function I request, if the flag is activated then I execute a function.

    Getting out of the poll means getting out of sleep / waiting for me.
    Currently it falls asleep then processes the interrupt returns to sleep and performs the rest of the function then returns to the main. However, I would like the interruption to wake him from his sleep, process what he has to process in the poll and return in the main (without going back to sleep).
    (I have the impression that it goes back to sleep because the processing of the functions requested in the main is done a long time after and when I decrease the value of the variable the mqtt_keepalive variable the reaction is done very quickly)

    When there is a new message on the queue could it wake up the processor and ask it to process functions? do you have an example or a link to a documentation?

    Best regards,

    Lecozahu

  • lecozahu said:
    When there is a new message on the queue could it wake up the processor and ask it to process functions? do you have an example or a link to a documentation?

     I think Workqueue Threads might be a good option for you.

    Best regards,

    Simon

Related