This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352R: DMM: the BLE cancels sub-GHz command when the radio is requested

Other Parts Discussed in Thread: SYSCONFIG, BLE-STACK

Hi Expert,

Setup:

  • SDK:                 simplelink_cc13x2_26x2_sdk_5_30_01_01
  • Sysconfig:        sysconfig_1_10_0
  • Devices:           LAUNCHXL-CC1352R1F3

We are developing a sub-GHz protocol. During the Rx event, we need to start listening at a very specific time (a few milliseconds after the radio Rx settings).

As a result, the Rx procedure is as follow:

  1. Set the frequency synthesizer settings
  2. Post the Rx command with triggerType == TRIG_NEVER
  3. Reserve the radio with RF_requestAccess for Xms
  4. Waiting for Rx event
  5. At the Rx event, we run RF_runDirectCmd for executing the pending command

A) Everything works fine in single protocol mode (BLE disabled). However, when the BLE is enabled, I notice that the system hangs only when the BLE calls RF_scheduleCmd between 3) and 5)

In fact:

/*
 *  ==================== RF_scheduleCmd ============================
 *  Process request to schedule new command from a particular client
 */
RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent)
{
...

    /* If client h2 already has, reject any new commands from h. */
    if (h2 && (ClockP_isActive(&h2->state.clkReqAccess)))
    {
        /* Set the status value to schedule_error if we could not allocate space. */
        cmdHandle = (RF_CmdHandle) RF_ScheduleStatusError;

        /* Store the reason and the handle why the callback is being invoked. */
        RF_Sch.issueRadioFreeCbFlags |= RF_RADIOFREECB_CMDREJECT_FLAG;
        RF_Sch.clientHndRadioFreeCb   = h;
        
        /* ISSUE:  1) The radio is reserved by our sub-GHz protocol with RF_requestAccess
         *         2) But as soon as RF_scheduleCmd returns 'RF_ScheduleStatusError',
         *            the BLE tries again by calling RF_ratDisableChannel following by RF_scheduleCmd 
         */
    }
    else
    {

    ...     
    }
    
    ...
}

B) Also, if the radio is reserved, the BLE calls RF_ratDisableChannel for discarding our pending command:

/*
 *  ======== RF_ratDisableChannel ========
 *  Disable RAT channel
 */
RF_Stat RF_ratDisableChannel(RF_Handle h, RF_RatHandle ratHandle)
{

...

    /* If the provided handler is valid. */
    if (ratCh && ratCh->status && (ratCh->pClient == h))
    {
        /* If the RF core is active, abort the RAT event. */
        if (RF_core.status == RF_CoreStatusActive)
        {
            /* Calculate the configuration field of command (the channel we disable). */
            uint16_t config = (uint16_t)(RF_RAT_CH_LOWEST + ratCh->handle) << RF_SHIFT_8_BITS;

            /* Disable the channel within the RF core.
               It has been checked that RAT channel to be disabled is owned by the input handle h.
               Call the function that executes the disabling with RF_currClient as input argument in
               instead of h in order to force the function to accept the disable request. This is
               required in the case where the client that will disable a RAT channel is not the same
               client as currently controlling the radio.
            */
            
            /*
             * ISSUE: If the previous BLE command was graceffuly rejected, our pending command is disabled here! 
             */
            status = RF_runDirectImmediateCmd(RF_currClient, ((uint32_t)CMDR_DIR_CMD_2BYTE(CMD_DISABLE_RAT_CH, config)), NULL);
            ...
            }
        }
    }
}

As a result, the system crashes when these specific sequences occurred:

  1. Set the frequency synthesizer settings
  2. Post the Rx command with triggerType = TRIG_NEVER
  3. Reserve the radio with RF_requestAccess for X ms
  4. Waiting for Rx event ~(X-1)ms later
  5. BLE tries to schedule its command with RF_scheduleCmd, but this is logically rejected (radio access requested)
  6. The BLE calls RF_ratDisableChannel for discarding the pending command without notifying the command owner.
  7. At the Rx event, we run RF_runDirectCmd with an invalid command handle (since the command does not exist anymore)

Questions:

1) Could you please confirm the BLE stack behavior by specifically checking how the RF_scheduleCmd error code is handled?

2) Since this behavior happens even if the BLE is paused with DMMSch_setBlockModeOn(DMMPolicy_StackRole_BlePeripheral); What's the best way for blocking any BLE radio access for a short period or until the TRIG_NEVER command is executed?

3) Why does the BLE call RF_ratDisableChannel when its command is gracefully rejected? Is there a way to avoid this from happening, eventually with a DMM/BLE stack configuration?

4) How could we be aware that our command has been discarded by RF_ratDisableChannel?

Thanks,

  • Hi,

    Do you have any suggestions?

    Thanks in advance

  • Hi Jo,

    1) Are you using an SDK DMM example as the basis of your development? Which one?

    2) What stack state is the BLE-Stack in when this happens? Advertising?

    3) What are the priorities of the BLE and Proprietary RF stack roles with the DMM when this happens?

    If I understand you correctly, the problem arises since both a BLE command and a Prop RF command want to use the radio at the same time, both stack roles are scheduling "timing critical" commands for the same time?

    Cheers,

    Marie H

  • Hi Marie,

    Apparently the function DMMSch_rfRequestAccess can't be used in the DMM mode:

    /**
     *  @brief Request access RF API that should not be used in DMM <br>
    */
    extern RF_Stat DMMSch_rfRequestAccess(RF_Handle h, RF_AccessParams *pParams);

    Therefore this RF API always returns an error when the DMM is enabled.

    A)

    f I understand you correctly, the problem arises since both a BLE command and a Prop RF command want to use the radio at the same time, both stack roles are scheduling "timing critical" commands for the same time?

    No, the problem arises when the BLE advertising schedules a command AFTER the PostCmd(TRIG_NEVER) but BEFORE its execution.

    So without using DMMSch_rfRequestAccess, Is there a method for reserving a Radio time slot during a short period of time?

    In other words, when a TRIG_NEVER command is successfully scheduled, how could we reserve the radio until its execution?

    B)

    3) What are the priorities of the BLE and Proprietary RF stack roles with the DMM when this happens?

     If a command TRIG_NEVER is already scheduled (Head of the queue) but not executed... Does a new command with lower priorities stay behind? 

    C) Also, what's the purpose of DMMSch_setBlockModeOn(DMMPolicy_StackRole_BlePeripheral) if the BLE can still have access to the radio scheduler? What are we exactly blocking?

    note: my project is based on dmm_wsnnode_ble_sp_oad_app_CC1352R1_LAUNCHXL_tirtos_ccs

  • Hi Jo,

    a) I'm not sure I fully understand your situation or why you want to reserve the radio in the future. Instead I would put the prop RF application task in a dedicated stack state with high or urgent priority and schedule the command as regular. If the BLE-Stack schedules an advertisement, the DMM scheduler will run the advertisement after the prop RF command has finished.

    b) Priorities are not considered unless there is a conflict. Thus a conflict would not be resolved until the command has a trigger time and that time is approaching. 

    More about scheduling in the User's Guide: https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_6_10_00_29/docs/dmm/dmm_user_guide/html/dmm/scheduling.html 

    c) If the BLE stack role is blocked, it can still schedule commands. When the time comes to run the command, the DMM scheduler will check whether the stack role is blocked. If it is indeed blocked, the command will not run and DMM will pass an error to the stack role. So it's the block state at the time the command is executed that determines whether the command is run.

    User's Guide on Block mode: https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_6_10_00_29/docs/dmm/dmm_user_guide/html/dmm/states-and-policies.html#block-mode 

    Cheers,

    Marie H