timeslot parameter setting and softdevice hang

Hi:

   when i set the timeslot parameter see below:I found it will run.However, after running for a few seconds, the program hangs. Debugging found that the softdevice hangs.(see the picture below).

my questions is:

1.why the "timeout_us"  parameter setting is too small, the program will hang instead of reporting an error state and let the program continue?

2.For app code that needs to be executed during a timeslot session, is there any requirement to put it in which function. My understanding is: as long as it is judged that the "NRF_RADIO_CALLBACK_SIGNAL_TYPE_START" signal is triggered, a global variable can be set, and my app will monitor this global variable. If the global variable is set, my program will be executed immediately.

3.If there is BLE network communication during the request timeslot (for example, I request a 100ms timeslot), will BLE data packets be lost at this time?

void configure_next_event_earliest(void)
{
    m_slot_length                                  = 80000;
    m_timeslot_request.request_type                = NRF_RADIO_REQ_TYPE_EARLIEST;
    m_timeslot_request.params.earliest.hfclk       = NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED;
    m_timeslot_request.params.earliest.priority    = NRF_RADIO_PRIORITY_HIGH;
    m_timeslot_request.params.earliest.length_us   = m_slot_length;
    m_timeslot_request.params.earliest.timeout_us  = 10000*100;
}

my SDK:15.0.0

softdevice:S132

IC:nrf52832

  • Hi Zjw, 

    I would suggest to have a look at the blog here and the source code here. It's an example of how to use the radio timeslot to do ESB protocol. 

    Regarding your question: 

    1. I'm not so sure what you showed in the screenshot meant that the softdevice hang. It can be a hardfault from the softdevice not "hang". Which  timeout_us did you use ? Did you base your implementation on one of our example ? 

    2. The way we do it is to trigger a lower priority interrupt when we receive NRF_RADIO_CALLBACK_SIGNAL_TYPE_START event. Like in the example I pointed to we trigger TIMESLOT_BEGIN_IRQn. This way we don't need to have a loop in the main loop to wait for the global variable to change. 

    3. Please have a look at chapter 15 Scheduling in the S132 v7.0 specification: 

    The role that has higher priority can preempt the role that has lower priority. If they are at the same priority and if the timeslot has already secured the slot with the scheduler , the BLE event will be dropped. However, it doesn't mean the BLE packet will be lost. By design, BLE packets will be retransmitted if it's not ACKed by the other side. So there will be latency introduced by the 100ms timeslot, but data will be retransmitted afterward. 

  • Hi Hung Bui

        Thanks. I now have a deeper understanding.

         But I haven't found the reason why my program hangs. Attached I uploaded the minimal code of my full project.

        The program applies for a timeslot of 100 ms with a timeout of 120 ms. When the timeslot is about to expire, it will apply for another timeslot of 100 ms, and so on.

       the log output see below.

    Meanwhile, I have two questions.

    1. The code in the blog, executing your own code in the timeslot is the way of using the interrupt.

    For example, "NVIC_SetPendingIRQ(TIMESLOT_BEGIN_IRQn);" The interrupt number used by TIMESLOT_BEGIN_IRQn is COMP_LPCOMP_IRQn. This is an interrupt number for existing hardware.

    My understanding is whether the interrupt number borrowed by timeslot can use the hardware interrupt number that is not used in the project。

    2.If my project uses BLE mesh. Is it not possible to use timeslot. Because I found that mesh itself also used timeslot. A timeslot session can only be opened once.

    nRF5_SDK_15.0.0_myTest.7z

  • Hi Zjw, 

    I haven't got time to look into  your code yet. I would suggest to use one of our example and modify it for your use. Our example have very similar mechanism where it request a timeslot and then try to expand it before it is expired. 

    Regarding your questions: 

    1. Correct, you can use the interrupt that is not used by the hardware for your own use. The main point here is to trigger an interrupt that has a lower priority than your current interrupt. So that you don't stay in the high priority interrupt handler for too long. 

    2. It can be a challenge to implement timeslot protocol with the mesh stack. As you mentioned the mesh stack also use timeslot. You may want to choose to pause the mesh stack for a period of time when you do your own timeslot. Could you give more information about your application ? 

  • Hi Hung Bui

       The project is already using mesh stack.

       At present, it is necessary to capture the time of each pulse width in a signal with a length of 2ms in real time. So my current idea is to use ppi to trigger timer capture. And let the CPU record the capture time. But because mesh will preempt the interrupt. result in the loss of a pulse, which is unacceptable in this project.

      So I was wondering if I could use timeslot to ensure that when a pulse comes over, I can completely capture this pulse.

  • Hi Zjw, 

    If you simply want to capture the actual length of a pulse, aren't the PPI captures enough ? 
    The CPU doesn't need to run in real time to calculate the distance between two capture registers ? 

    I'm not so sure I understand what you meant by "CPU record the capture time" and by "mesh will preempt the interrupt" . 
    As far as I know mesh shouldn't preempt the PPI that trigger the capture task. 

Related