Open smdjeff opened 2 months ago
Hi @smdjeff
You are right, we already had this issue when we developed the CW mode. We are quite sure that this is a bug in the S2LP driver from ST.
Here is the function implementation (S2LP_Radio.c
file of ST repository):
void S2LPRadioSetPALeveldBm(uint8_t cIndex, int32_t lPowerdBm)
{
uint8_t address, paLevelValue;
s_assert_param(IS_PA_MAX_INDEX(cIndex));
s_assert_param(IS_PAPOWER_DBM(lPowerdBm));
if(lPowerdBm> 14)
{
paLevelValue = 1;
}
else {
paLevelValue = (uint8_t)((int32_t)25-2*lPowerdBm);
}
address = PA_POWER8_ADDR + 7 - cIndex;
*(uint8_t*)&g_xStatus = S2LPSpiWriteRegisters(address, 1, &paLevelValue);
}
As you can see, when the parameter is 13 or 14dBm, the formula gives a negative number, leading to an incorrect unsigned value and thus a very low output power. 12dBm gives 1, which is also incorrect because it corresponds to the maximum output power.
You can quickly patch the formula by replacing 25 by 29 at line 1217:
- paLevelValue = (uint8_t)((int32_t)25-2*lPowerdBm);
+ paLevelValue = (uint8_t)((int32_t)29-2*lPowerdBm);
But in order to have a calibrated value, you have to contact ST in order to get the accurate formula, which is not clearly explained in the datasheet.
Let me know if it solves your issue.
Does this actually work to adjust the power level to anything other than maxium?
https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/blob/417f31d94d4a95266c61f6b75f1cfa34a7fffe7e/src/manuf/s2lp_rf_api.c#L686