Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
xDot ADC problem when coming out of sleep mode
Hi there,
I have a function that reads 3 ADC pins: PA_4, PA_5 and PB_0. This function is called periodically, in between calls to sleep();
The analogue inputs are declared as follows:
AnalogIn ain0(PA_4); AnalogIn ain1(PA_5); AnalogIn ain2(PB_0);
They are read in the called function as follows:
analogue[0].raw = ain0.read(); analogue[1].raw = ain1.read(); analogue[2].raw = ain2.read();
The initial call (before the first sleep()) returns valid ADC readings. After the first sleep(), subsequent reads of the ADCs return 0.000000V.
Sleep() call is as follows:
dot->sleep(10, mDot::RTC_ALARM, false);
Note: the code is built with libxDot-Custom (this application requires the AS923 custom channel plan).
Does anyone have a fix for this?
Thanks very much!
1 Answer
7 years, 4 months ago.
Oh, it seems like reseting the HSI clock did the trick. https://developer.mbed.org/questions/78300/xDot-ADC-problem-when-coming-out-of-slee/
However wouldn't be a good idea to add this piece of code to the utils examples?
// Enable the HSI (to clock the ADC) RCC_OscInitTypeDef RCC_OscInitStruct; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; HAL_RCC_OscConfig(&RCC_OscInitStruct);
Hi, I have the same problem. Notice that if you use deep sleep, the problem is not occurring.
I thought initially that was something wrong with sleep_save_io/sleep_restore_io https://developer.mbed.org/teams/MultiTech/code/Dot-Examples/file/f8c29f84178b/examples/src/dot_util.cpp
But it seems there is something wrong with the `sleep` method. https://developer.mbed.org/teams/MultiTech/code/libxDot-dev-mbed5/file/28f05671c7f1/mDot.h
I'm using this libxDot: https://developer.mbed.org/teams/MultiTech/code/libxDot-mbed5/#5351293b3c55
Going to check with the latest version and report back.
posted by Lucian Corduneanu 20 Jul 2017Tested with the latest dev lib https://developer.mbed.org/teams/MultiTech/code/libxDot-dev-mbed5/rev/28f05671c7f1
And mbed-os 5.4.7 https://github.com/ARMmbed/mbed-os/#fc1836545dcc2fc86f03b01292b62bf2089f67c3
The same problem! :(
posted by Lucian Corduneanu 20 Jul 2017