Hardware:
Custom DA14683 Board
Latest SDK = 1.0.14.1081 (Last updated in 2018)
Situation:
This question applies to any demo, but lets take the BMS demo for an example.
From hw_rf.h, I can see where the tx power levels are defined in this enum:
typedef enum { HW_RF_PWR_LUT_0dbm = 0, /**< TX PWR attenuation 0 dbm */ HW_RF_PWR_LUT_m1dbm = 1, /**< TX PWR attenuation -1 dbm */ HW_RF_PWR_LUT_m2dbm = 2, /**< TX PWR attenuation -2 dbm */ HW_RF_PWR_LUT_m3dbm = 3, /**< TX PWR attenuation -3 dbm */ HW_RF_PWR_LUT_m4dbm = 4, /**< TX PWR attenuation -4 dbm */ } HW_RF_PWR_LUT_SETTING;
From hw_rf.c, I can see the function that sets the TX power level:
void hw_rf_set_tx_power_ble(HW_RF_PWR_LUT_SETTING lut) { RFCU->RF_TX_PWR_BLE_REG = lut; rf_tx_power_luts.tx_power_ble = lut; }
...But the "hw_rf_set_tx_power_ble()" function does not appear to be called anywhere.
...Also none of the enums from "HW_RF_PWR_LUT_SETTING" appear anywhere in the project.
It is unclear where the TX power is being defined. It is also unclear at what point in the power up sequence the TX power is being set.
Questions:
1) Where is the default TX Power level defined? (file and line please)
2) At what point in the BLE radio initialization sequence is the TX power level set? (file and line please)
3) If I wanted to change the BLE radio TX power level, what is the correct sequence of operations to do so? (do I need to power down the radio first?, just stop advertising?, etc)
Hi Nathan,
1. The TX power attenuation setting is applied by the hw_rf_set_tx_power_ble() function in hw_rf.c and as you correctly mentioned the aforementioned function takes the HW_RF_PWR_LUT_SETTING enum as an input parameter.
The default parameter that the hw_rf_set_tx_power_ble() is configured is 0, and according to HW_RF_PWR_LUT_SETTING enum means 0dBm:
HW_RF_PWR_LUT_0dbm = 0, /**< TX PWR attenuation 0 dbm */
In file hw_rf.f, in line 107 :
hw_rf_tx_power_luts_t rf_tx_power_luts __RETAINED;
In sdk_defs.h, the __RETAINED stores zero-initialized data retained memory :
#define __RETAINED __attribute__((section("retention_mem_zi"))) // RetRAM0
This means that the rf_tx_power_luts struct is zero-initialized.
2. The hw_rf_set_tx_power_ble() is called in hw_rf_request_recommended_settings(), which is called in ad_rf_request_recommended_settings(). Please search into the SDK to find how the ad_rf_request_recommended_settings() is executed.
---------------------------------------------------------------
******* IGNORE THIS *******
3. I am checking this internally but a possible solution would be to use the __RETAINED_RW attribute which does not zero-initialize the data in the Ret-RAM :
hw_rf_tx_power_luts_t rf_tx_power_luts __RETAINED_RW ;
And then set the rf_tx_power_luts.tx_power_ble item to your preferred value.
Regards,
PM_Renesas