cancel
Showing results for 
Search instead for 
Did you mean: 

Is ADC_2411_WORKAROUND on BlueNRG2 running at 32MHz really working ?

Mathieu Garivet
Associate III

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.

3 REPLIES 3
Mathieu Garivet
Associate III

Any help ?

Aoruc.1
Associate II

Hello Mathieu, are you find a solution ?

"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 !