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

Supporting a real-time task

My 51822 needs to support some realtime control code that runs for about 75mS. During that time I need to mask all interrupts. With a logic analyzer I can see that my realtime code is getting interrupted every 25mS or so, I guess by the SoftDevice. I tried using CRITICAL_REGION_ENTER/CRITICAL_REGION_EXIT but that does not mask the interrupts.

  1. How can I mask interrupts so that my realtme code will not be interrupted no matter what the radio is doing?
  2. Is there a way to do this such that I don't unduly disturb the SoftDevice?

Regards, Bret

Parents
  • Hi Bret,

    in that case, you need to drop the connection or stop advertising. There are no mechanisms to forcibly skip radio events as far as I know.

    Stopping advertising is an immediate action, however there is a corner-case when a connection request is received at the same time as advertising is stopped. Doing a proper disconnect will take more than a couple of ms, so that's not an option. The only way to immediately halt all radio activity is to disable the softdevice using sd_softdevice_disable(). Note that the Central will consider the link active until the Supervision Timeout has expired, and will typically not attempt to reconnect until that happens.

  • I was a bit unclear regarding advertising and connections I think. What I meant was that there are two different states where the softdevice will interrupt the application: When advertising, and when in a connection.

    Advertising is stopped by sd_ble_gap_adv_stop(). When you are in a connection, with the MCP for example, sd_ble_gap_adv() won't do anything.

    A proper disconnect (sd_ble_gap_disconnect()) involves letting the peer device know that are disconnecting, which can take some time depending on the specific connection parameters.

    There's also a corner-case while advertising: if the peer device initiates a connection at the same time as you stop advertising you might actually be in a connected state instead of stopping all activity. The only way to be sure there's no radio interrupts is to disable the softdevice using sd_softdevice_disable()

Reply
  • I was a bit unclear regarding advertising and connections I think. What I meant was that there are two different states where the softdevice will interrupt the application: When advertising, and when in a connection.

    Advertising is stopped by sd_ble_gap_adv_stop(). When you are in a connection, with the MCP for example, sd_ble_gap_adv() won't do anything.

    A proper disconnect (sd_ble_gap_disconnect()) involves letting the peer device know that are disconnecting, which can take some time depending on the specific connection parameters.

    There's also a corner-case while advertising: if the peer device initiates a connection at the same time as you stop advertising you might actually be in a connected state instead of stopping all activity. The only way to be sure there's no radio interrupts is to disable the softdevice using sd_softdevice_disable()

Children
No Data
Related