1. Introduction
The purpose of this section is to demonstrate how to use some 802.15.4 PHY commands in higher layer protocols (MAC, Zigbee, Thread, etc…) that are normally only available using the PHY coprocessor binary (stm32wb5x_Phy_802_15_4_fw.bin) and their dedicated applications.
Warning: these PHY commands are intended for test purposes only (unitary or production line testing for example). They shouldn’t be used during the final product’s life, and a MCU reset should be made before using the final application.
2. Prerequisite
- Any STM32WB55xx MCU
- Include phy_test.h and the .c test file according to the used protocol, available here: STM32Cube_FW_WB_Vx.xx.x\Middlewares\ST\STM32_WPAN\phy
3. Available PHY features
- test_mode
Available through the following API/** * @brief PHY test enable or disable test mode * * @param enableDisable: 1 to enable PHY test mode, 0 to disable PHY test mode * @retval 0 if successful, 0xFF otherwise */ uint8_t phyTestMode(uint8_t enableDisable)
Note: contrary to other commands described in this document, this PHY command is not standard, it is used to put the radio in a particular mode that enables PHY testing, regardless of the upper layer protocol used.
- set_channel
Available through the following API:/** * @brief PHY test set channel * * @param channel_nb: channel to set (11 to 26) * @retval 0 if successful, 2 if bad argument, 0x92 if radio is not initialized */ uint8_t phyTestSetChannel(uint8_t channel_nb)
- set_power
Available through the following API:/** * @brief PHY test set Tx power * * @param tx_power: transmission power to set in dBm, in the range [-21, +6] * @retval 0 if successful, 2 if bad argument */ uint8_t phyTestSetTxPower(int8_t tx_power)
- cw_start
Available through the following API:/** * @brief PHY test continuous wave start * * @param frq_mhz: the frequency of the continuous wave (2400 <= frq_mhz <= 2482) * @retval 0 if successful, 2 if bad argument */ uint8_t phyTestContinuousWaveStart(uint16_t frq_mhz)
- cw_stop
Available through the following API:/** * @brief PHY test continuous wave stop * * @param None * @retval 0 if successful, 0xFF otherwise */ uint8_t phyTestContinuousWaveStop(void)
- rx_start
Available through the following API:/** * @brief PHY test Rx start * * @param None * @retval 0 if successful, 0xFF otherwise */ uint8_t phyTestRxStart(void)
- rx_stop
Available through the following API:/** * @brief PHY test Rx stop * * @param None * @retval the number of packets received */ uint32_t phyTestRxStop(void)
- tx_start
Available through the following API:/** * @brief PHY test Tx start * * @param nb_frames: number of frames to send * @param size_of_frame: number of bytes in the frame (maximum 20 bytes) * @param tx_frame: the frame to transmit * @retval 0 if successful, 0xFF otherwise */ uint8_t phyTestTxStart(uint32_t nb_frames, uint8_t size_of_frame, uint8_t *tx_frame)
- tx_start_continuous
Available through the following API:/** * @brief PHY test continuous Tx start on the current channel * * @param none * @retval 0 if successful, 2 if bad argument */ uint8_t phyTestContinuousTxStart(void)
- tx_stop_continuous
Available through the following API:/** * @brief PHY test continuous Tx stop * * @param None * @retval 0 if successful, 0xFF otherwise */ uint8_t phyTestContinuousTxStop(void)
4. Compatible binaries
- MAC & BLE-MAC
- stm32wb5x_Mac_802_15_4_fw.bin
- stm32wb5x_Mac_802_15_4_rfd_fw.bin
- stm32wb5x_BLE_Mac_802_15_4_fw.bin
- Zigbee & BLE-Zigbee
- stm32wb5x_Zigbee_FFD_fw.bin
- stm32wb5x_Zigbee_RFD_fw.bin
- stm32wb5x_BLE_Zigbee_FFD_dynamic_fw.bin
- stm32wb5x_BLE_Zigbee_RFD_dynamic_fw.bin
- stm32wb5x_BLE_Zigbee_FFD_static_fw.bin
- stm32wb5x_BLE_Zigbee_RFD_static_fw.bin
- Thread & BLE-Thread
- stm32wb5x_Thread_FTD_fw.bin
- stm32wb5x_Thread_MTD_fw.bin
- stm32wb5x_BLE_Thread_dynamic_fw.bin
- stm32wb5x_BLE_Thread_static_fw.bin
5. Stack configuration
- MAC & BLE-MAC
- Initialize and configure the stack as in the examples but do not start the stack using
APP_FFD_MAC_802_15_4_SetupTask()
orAPP_RFD_MAC_802_15_4_SetupTask()
. - For BLE-MAC static mode, do not switch to BLE.
- Use any of the PHY commands.
- Initialize and configure the stack as in the examples but do not start the stack using
- Zigbee & BLE-Zigbee
- Initialize and configure the stack as in the examples but do not start the stack using
UTIL_SEQ_SetTask(1U << CFG_TASK_ZIGBEE_NETWORK_FORM, CFG_SCH_PRIO_0)
inAPP_ZIGBEE_StackLayersInit()
. - For BLE-Zigbee dynamic mode, do not initialize the BLE stack using
APP_BLE_Init()
andAPP_BLE_Init_App()
. - For BLE-Zigbee static mode, do not switch to BLE.
- Use any of the PHY commands.
- Initialize and configure the stack as in the examples but do not start the stack using
- Thread & BLE-Thread
- Initialize and configure the stack as in the examples but do not start the stack using
APP_THREAD_DeviceConfig()
. - For BLE-Thread dynamic mode, do not initialize the BLE stack using
APP_BLE_Init_Dyn_1()
andAPP_BLE_Init_Dyn_2()
. - For BLE-Thread static mode, do not switch to BLE.
- Use any of the PHY commands.
- Initialize and configure the stack as in the examples but do not start the stack using
6. Example codes
- test_mode:
uint8_t enable = 1; uint8_t result = phyTestMode (enable);
- set_channel:
uint8_t channel = 14; uint8_t result = phyTestSetChannel (channel);
- set_power:
int8_t tx_power = -20; uint8_t result = phyTestSetTxPower (tx_power);
- cw_start:
uint16_t frq_mhz = 2400; uint8_t result = phyTestContinuousWaveStart(frq_mhz);
- cw_stop:
uint8_t result = phyTestContinuousWaveStop();
- rx_start:
uint8_t result = phyTestRxStart();
- rx_stop:
uint32_t nb_rx_frames = phyTestRxStop();
- tx_start :
// 1st byte : number of bytes in the frame + 2 (for the 2 bytes of CRC that are // automatically added), without including this byte itself. uint8_t tx_frame[] = { 0x0F, 0x01, 0x08, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x13, 0x12, 0x12, 0x03, 0x06, 0x15 }; uint8_t size_of_frame = sizeof(tx_frame)/sizeof(tx_frame[0]); uint32_t nb_frame_to_send = 1000; uint8_t result = phyTestTxStart(nb_frame_to_send, size_of_frame, tx_frame);
- tx_start_continuous:
uint8_t result = phyTestContinuousTxStart();
- tx_stop_continuous:
uint8_t result = phyTestContinuousTxStop();
7. Tips, known restrictions and issues
- Test_mode must always be the first command to be issued to enable PHY test mode.
- cw_start must always be followed by cw_stop before using any other commands.
- tx_start_continuous must always be followed by tx_stop_continuous before using any other commands.
- rx_start must always be followed by rx_stop before using any other commands.
- tx_start is limited in number of bytes to 19 bytes (including the 1st byte that indicates the size of the frame). An error (0xFF) will be returned if this limit is exceeded.
- The number of frames to send can go up to the maximum size of a uint32_t. The inter-frame spacing is reduced to the minimum and the frames are sent as soon as possible.
- Some options to the commands normally available when using stm32wb5x_Phy_802_15_4_fw.bin are not available and have been set to their default value.
- After using any of the PHY commands, it is highly recommended to reset the MCU before using any other protocols, as some radio registers may be put in a state that is incompatible with higher layer protocols.
- When using dynamic concurrent mode binaries (BLE running with another protocol), it is recommended to not initialize the BLE stack as it is not designed to work along with it.