STM32CubeWBA BLE Timing Profiling

Revision as of 15:36, 5 July 2024 by Registered User

1. Introduction

The goal of this wiki page is to describe how the STM32WBA works to meet RF timing requirements and how to profile the system and link layer timing. These timing needs to be profile to avoid any RF missed event and to optimize the device power consumption.

To schedule a RF event, the BLE Link Layer (LL) starts a timer based on the event anchor point and on the LL process duration. In run mode, when this timer expired, the radio IRQ (HW signal) fired to execute three LL processes to manage the radio activity event. These LL processes are executed in ISR.

The margin M1 between the end of Hash IRQ handler and the radio activity allows the application / system to preempt the LL processes. Based on STM32CubeWBA v1.4.0 release, the application / system can preempt the LL processes up to 200 us. A preemption longer than 200 us might lead to an event missed (no radio activity on this event).

Constraints:

  • The sum of interrupts with priority lower than RADIO_INTR_PRIO_HIGH = 0 must not last more than 40us.
  • The sum of interrupts with priority lower than RADIO_INTR_PRIO_LOW = 5 must not last more than 200us.
Radio activity event management in run mode
Connectivity:Connectivity : Radio activity management run mode.png

2. Stop 1 low power mode

When stop1 low power mode is used, an additional system process need to be considered in addition of LL processes, it’s called the stop1 exit in the diagram above. The stop1 exit allows to restore the clock configuration when the system wakes up from stop1 low power mode and it’s performed under critical section. The critical section duration depends on the application, if using the system clock manager (SCM) or not, the code optimization… and delayed the process of the radio IRQ handler.

In BLE applications available in STM32CubeWBA package, the system clock manager (SCM) is used to restore the clock configuration. When exiting from stop1, the system is running on HSI at 16 MHz, thanks to the SCM module the execution of the application continue on HSI instead of waiting for HSE ready and then switch to HSE when it’s ready. In this case the duration of the critical section is very short and doesn’t impact the RF requirement timing.

But, if the application has a long critical section, for example if the SCM is not used and the wait for HSE ready is performed inside the critical section. The radio IRQ Handler will be delayed too much which can lead to BLE missed event. To avoid missed event, the critical section duration need to be considered in the DRIFT_TIME to meet RF requirement timing.

The DRIFT_TIME corresponds to the time between the Radio IRQ and the beginning of the LL Process 3. Find out in the next section how to profile and configure it.

Radio activity event management in stop1 low power mode
Connectivity:Connectivity : Radio activity management stop1 mode.png

2.1. GPIO configuration to measure the DRIFT_TIME

To profile the DRIFT_TIME, the following GPIO are needed:

  • RADIO_IRQ DTB – PA6: CN3 pin 30 on NUCLEO-WBA55CG
  • TX_ON DTB – PA1: CN3 pin 34 on NUCLEO-WBA55CG
  • DBG_IO_PROFILE_END_DRIFT_TIME debug GPIO of the RT Debug module

With STM32CubeWBA v1.4.0 release, follow these steps to enable the GPIO:

  • To enable the DTB signals (RADIO_IRQ and TX_ON) set to 1 the following define in app_conf.h file:
#define CFG_RT_DEBUG_DTB                 (1)
  • To enable DBG_IO_PROFILE_END_DRIFT_TIME debug GPIO of the RT Debug module, set to 1 the following define in app_conf.h file:
#define CFG_RT_DEBUG_GPIO_MODULE                              (1)

Then choose the GPIO you want to use (PA0 in this example) in debug_config.h file and enable it:

#define USE_RT_DEBUG_PROFILE_END_DRIFT_TIME                   (1)
#define GPIO_DEBUG_PROFILE_END_DRIFT_TIME                     {GPIOA, GPIO_PIN_0}  // CN3 pin 38 on NUCLEO-WBA55CG
Radio activity event management in stop1 low power mode
Connectivity:Connectivity radio activity management stop1 mode GPIO conf.png

2.2. How to measure the DRIFT_TIME

Depending on the device role, the DRIFT_TIME can be measured:

  • During an advertising event for broadcaster role
  • Before a scan window for observer role
  • During a connection event for peripheral and central role

Once the GPIO configured and the scenario executed, the DRIFT_TIME can be profiled as described below:

  • Identify the RF activity of the scenario and identify the foregoing RADIO_IRQ as shown below.
  • Start the measure at the rising edge of the RADIO_IRQ signal
  • Stop the measure at the falling edge of the DBG_IO_PROFILE_END_DRIFT_TIME signal
DRIFT_TIME measurement
Connectivity:Connectivity stop1 drift time measurement.png

2.3. How to set the DRIFT_TIME

Once the DRIFT_TIME measured in microseconds, the value will be computed to have the number of cycles required for the DRIFT_TIME, using the following formula:

V_drift_time = CEIL(T_drift_time / T_cycle) + V_margin

With:

  • V_drift_time: the value to set in the Link Layer and corresponds to the number of cycles required for the DRIFT_TIME.
  • T_drift_time: the DRIFT_TIME duration measured previously in microsecond.
  • T_cycle: the duration of the Radio sleep timer clock cycle (~30.52us for LSE clock at 32.768kHz)
  • V_margin: the number of cycles added to allow preemption of Link Layer process. The minimum margin recommended is 6 cycles (~183.1us).

Then with STM32CubeWBA v1.4.0 release call the following API in ll_sys_reset function to set the new DRIFT_TIME value:

ll_intf_config_schdling_time( &event_time );

With the following parameters:

Evnt_timing_t event_time;
event_time.drift_time = xx;    // xx is the drift time measured in number of cycles
event_time.exec_time = 14;     // Should be set to 14 as is the default value in v1.4.0
event_time.schdling_time = 20; // Should be set to 20 as is the default value in v1.4.0


Warning white.png Warning
System interface to set the drift time value and a user section to call the API need to be implemented for v1.5.0 (Internal ticket)


3. Backup

4. Link Layer Timing

To adjust the BLE Link Layer timing with the right value, it requires a profile of specific timings called the DRIFT_TIME and EXEC_TIME.

The DRIFT_TIME corresponds to the time between the Radio IRQ and the beginning of the Link Layer event setup. It can be impacted by the system process and the active clock frequency.

The EXEC_TIME corresponds to the time required by the Link Layer to prepare the system to configure the next radio event. Please find below the step to follow to configure the DRIFT_TIME and EXEC_TIME values.

4.1. GPIO and signals setup

The DTB RADIO_IRQ, TX_ON and the debug IO of the RT Debug module DBG_IO_PROFILE_END_DRIFT_TIME and DBG_IO_SCHDLR_EXEC_EVNT_PROFILE.

  • The RADIO_IRQ GPIO indicates the beginning of the DRIFT_TIME
  • The DBG_IO_PROFILE_END_DRIFT_TIME indicates the end of the DRIFT_TIME.
  • The TX_ON GPIO indicates the RF activity. As the DRIFT_TIME to measure, is the one which occurs just before the RF Activity (TX_ON) (cf. figure 1)
  • The DBG_IO_SCHDLR_EXEC_EVNT_PROFILE rising edge indicates the beginning of the EXEC_TIME and the falling edge indicates the end of the EXEC_TIME.

(Please refer to the XXX note to setup configure those GPIOs)


4.2. Run Bluetooth scenario

For broadcaster role, the DRIFT_TIME and EXEC_TIME can be measured during an Advertising event.

For observer role, the DRIFT_TIME and EXEC_TIME can be measured before a Scan window.

For other roles, the DRIFT_TIME and EXEC_TIME can be measured during a connection event.

4.3. Measure the DRIFT_TIME duration

Once the GPIO configured and the scenario executed, the DRIFT_TIME can be profiled as described below.

  • Identify the RF activity of the scenario (detailed in the point 2.) and identify the foregoing RADIO_IRQ as shown in the figure 1.
  • Start the measure at the rising edge of the RADIO_IRQ signal
  • Stop the measure at the falling edge of the DBG_IO_PROFILE_END_DRIFT_TIME signal
Connectivity:STM32CubeWBA BLE Timing Profiling 1717763978699.png

Figure 1 : Signal identification

Connectivity:STM32CubeWBA BLE Timing Profiling 1717763990124.png

Figure 2 : DRIFT_TIME measurement


4.4. Define the DRIFT_TIME value

Once the DRIFT_TIME measured in microseconds, the value will be computed to have the number of cycles required for the DRIFT_TIME, using the following formula:

With:

-       T_drift_time is the DRIFT_TIME duration measured previously in microsecond.

-       T_cycle is the duration of the Link Layer sleep clock cycle ~30.52us (clock at 32.768kHz)

-       V_drift_time is the value to set in the Link Layer and corresponds to the number of cycles required for the DRIFT_TIME.

-       V_margin is the number of cycles added to allow preemption of the Link Layer setup. The minimum margin recommended is 7 cycles (~183.1us).

4.5. Measure the EXEC_TIME duration

Once the GPIO configured and the scenario executed, the EXEC_TIME can be profiled as described below.

- Identify the RF activity of the scenario (detailed in the point 2.).

- Start the measure at the rising edge of the DBG_IO_SCHDLR_EXEC_EVNT_PROFILE signal

- Stop the measure at the falling edge of the DBG_IO_SCHDLR_EXEC_EVNT_PROFILE signal

Connectivity:STM32CubeWBA BLE Timing Profiling 1717764026129.png

Figure 3: EXEC_TIME measurement

4.6. Define the EXEC_TIME value

Once the EXEC_TIME measured in microseconds, the value will be computed to have the number of cycles required for the EXEC_TIME, using the following formula:

With:

-       T_exec_time is the EXEC_TIME duration measured previously in microsecond.

-       T_cycle is the duration of the Link Layer sleep clock cycle ~30.52us (clock at 32.768kHz)

-       V_exec_time is the value to set in the Link Layer and corresponds to the number of cycles required for the EXEC_TIME.

Note: No margin needed for exec_time.

4.7. Set the DRFIT_TIME and EXEC_TIME

Call the XXX function with V_drift_time and V_exe _time as parameter in the ll_sys_reset function.

4.8. Example

For an application which supports Central or Peripheral Role :

Connectivity:STM32CubeWBA BLE Timing Profiling 1717763978699.png
Connectivity:STM32CubeWBA BLE Timing Profiling 1717764026129.png
  • T_drift_time = 186us
  • V_drift_time = CEIL(186 / 30.52) + 6 = 13
  • T_exec_time = 445us
  • V_exec_time = CEIL(445 / 30.52) = 15

Call the XXX function to set the new DRIFT_TIME value.

 void ll_sys_reset( void )
 {
 XXX( 10 );
 } 

Note :

  • Add note on default value.
  • problem with STOP MODE impact ?
No categories assignedEdit