2020-04-10 03:55 AM
Hello,
I'm playing a little bit with your BLUETILE eval kit and with my own board using a BLUENRG-M2SA. both are running at 32Mhz.
Using the SensorDemo firmware from the BLUETILE DK, I noticed that the battery voltage sent by both modules were slowly decreasing, whereas both boards were plugged to my PC (so it is not a battery voltage that is discharging, voltage is constant).
I checked the device limitation here : https://www.st.com/resource/en/errata_sheet/dm00511358-the-bluenrg2-device-limitations-stmicroelectronics.pdf and I found that ADC is not working properly on 32Mhz so you patched it with the ADC_2411_WORKAROUND by switching clock to 16Mhz and then back to 32Mhz during ADC reading. So it is intended to work properly, isn't it ?
(EDIT) Workaround in BlueNRG1_ADC.c:
/* x = 1: Workaround for running ADC with 32 MHz clock - Run the APB bus @ 16 MHz;
x = 0: Restore the APB bus @ 32 MHz */
#define AHBUPCONV_STATUS ((volatile uint32_t *)0x40C00004)
static inline void ADC_2411_WORKAROUND(uint8_t x) {
if (x == 1) {
AHBUPCONV->COMMAND = 0x14;
while (((*AHBUPCONV_STATUS) & 0x01) != 0)
;
while ( AHBUPCONV->COMMAND != 0x10)
;
} else {
AHBUPCONV->COMMAND = 0x15;
while (((*AHBUPCONV_STATUS) & 0x01) != 1)
;
while ( AHBUPCONV->COMMAND != 0x11)
;
}
}
But it is not. The voltage returned by the single ended reading is SOMETIMES 600mV (raw data is 0) and then the interpreted battery voltage is 2616mV (against the 3300mV). So you added a filter that drifts slowly to an incorrect value (in sensor.c) :
batteryVoltage = batteryVoltage * 0.99 + ADC_ConvertBatterySensor(ADC_GetRawData(), ADC_ReferenceVoltage_0V6) * 0.01;
When the ADC reading works fine the value is very good and stable (about 3295mV on my boards).
Are you aware of this problem ? How could I fix it properly ?
Thanks in advance.
2020-04-23 02:36 PM
Any help ?
2020-07-06 06:24 AM
Hello Mathieu, are you find a solution ?
2020-07-06 06:58 AM
"The voltage returned by the single ended reading is SOMETIMES 600mV"
I have the same problem. When i used adc_init() , SOMETIMES CHSEL is not changed and in this situation I read a internal voltage value (0.6V, CHSEL = 6)
When adc_init() "works correctly" , CHSEL changed (CHSEL = 1 or 2 according to input choice) and i read a correctvalue !
2024-05-30 08:14 AM
Thanks for you post, this ADC_2411_WORKAROUND worked here.
I had the same issue and did not notice the BlueNRG-2 errata.
Thanks!