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

Know when the softdevice / Interrupt took control

Hi,

I'm developing a unit which i need from time to time to send a packet throw I/O lines (F.E.virtual uart)

However the packet bit timing is very critical.

As far as i understand, when using a softdevice, the softdevice can interrupt me whenever he needed (& also, other interrupts)

that's ok,  but i need to know that the softdevice interrupted me (or other interrupts occered), ruined my packet timing and i'll take care of it and resend the packet again.

What i thought of is making a flag and check at the end of my packet transmition it's status (if it still 0 - then no interrupt were made)....

So, Where shoud i put the "flag=1" ? is there a centrer place that i can raise this flag and know that the soft device / Other interrupt took control/were made ?

B.R

Yuval

  • Hi Yuval,

    Interrupts for the SoftDevice are not propagated to the application, except for in cases where the SoftDevice notifies the application about something in the form of an event by calling the registered event handler(s). Therefor the method of setting a flag in the application indicating that the SoftDevice has interrupted you will not work. However, that may not be needed as there are a few other options worth considering:

    • The application can use the Timeslot API to obtain a timeslot where it is guaranteed to not be interrupted by the SoftDevice. This API is intended to be used for implementing a second concurrent radio protocol, but it can be used for any situation where the application needs full control for a limited duration of time with a guarantee that there will be no SoftDevice interrupts.
    • The UART peripheral support DMA, so a SoftDevice interrupt will not affect an ongoing transaction. The CPU is only needed to set up the transaction. If I understood your use case correctly, this will circumvent the whole problem.

    Br,

    Einar

  • Thanks,

    But this not working for me since i'm the slave and not the master, so i don't know when the other transmitter sends it's data....(And i act according to the data)

    Another question,

    If i set a timer event for every 200 micro seconds, (f.e. Inside the event i have 1 line of code - advancing  a counter)

    How much time will be spent in going into the event, advancing the counter and return back to the regular program?

    B.r, Yuval.

  • Hi Yuval,

    Why do you absolutely need to handle the UART transaction immediately? Does the master device not support flow control?

    I don't have numbers for how long time your timer event would take, but it should not take many instructions per time.

  • Hi,

    No, There is no flow control. I can't know when it transmit to me.

    About the 2nd question: what do you meen by "not take many instruction"?

    Is it up to 10us? 50us? 100us?  I don't need very aqurate number from you but i need to know more or less how much time it will take...

  • Hi,

    What I meant is that reading the timer value and setting a variable does not take many CPU instructions. Then you have the interrupt latency which adds a bit. We are definitely talking about far less than 10 μs in this case.

Related