Problem configuring xDot analogIn pin
- This topic has 10 replies, 4 voices, and was last updated 7 years, 10 months ago by Chad Goyette.
-
AuthorPosts
-
January 10, 2017 at 1:40 pm #16262Chad GoyetteParticipant
I am currently using the dot examples auto_ota as a template for my new code and am having trouble getting my Analog inputs configured properly. The issue occurs when trying to connect to the lora network in if the xDot fails to connect it goes to sleep and retries a few seconds later. after this happens the AnalogIn object fails to properly read the ADC (all i read is 0). if i disable the sleep function in dot-util.cpp in the join_network() funtion and just replace it with a wait(delay_s) the AnalogIn object works properly when read and everything is great. what should i do to fix this? The AnalogIn object is assigned to PB_0.
January 10, 2017 at 1:42 pm #16263Mike FioreBlockedChad,
Try deleting the AnalogIn object before going to sleep and creating a new one after waking up.
Cheers,
MikeJanuary 10, 2017 at 6:18 pm #16266Chad GoyetteParticipantI tried this and this doesnt seem to work. It seems that once the xdot goes to sleep i lose the ability to configure the pins to use the adc.
January 11, 2017 at 8:19 am #16272Mike FioreBlockedChad,
That is strange. Can you post or link to code that demonstrates the issue? It would also be good to know some more about your setup:
* is your xDot an xDot-DK or on a custom board?
* how is it getting powered?
* what’s hooked up to the analog input?
* anything else you think might be helpfulCheers,
MikeJanuary 11, 2017 at 8:55 am #16273Chad GoyetteParticipant*xDot is on a custom board.
*the device is being powered with 3.3v from a test power supply.
*This particular input is connected to a 10k thermistor with a voltage divider circuit.
*I have tried additional unused pins that where left floating (open) with same result.For code I am using the dot examples auto_ota as a template (basically using all the startup stuff and then replacing the “guts with my code”. My custom board uses two inputs PB_0 on the ADC, and PB_14 as a digital in. The digital in object works fine.
if the board doesn’t go to sleep the ADC works as expected, once it sleeps i only get 0. I have tried what you suggested creating and destroying the object before and after sleeping but that is not changing the result.January 11, 2017 at 9:47 am #16275Chad GoyetteParticipantI just created very simple helloworld program that is demonstrating the issue. on the first loop i am reading the ADC correctly, on the second loop and then on it will read 0. I am using libxDot-mbed5 revision 7:aff2c05 and all the dot examples supporting files.
————————————————————
#include “dot_util.h”
#include “RadioEvent.h”
#if ACTIVE_EXAMPLE == HELLOWORLD//AnalogIn tmp3(PB_0);
mDot* dot;main()
{
dot = mDot::getInstance();
int a = 0;
while(1)
{
AnalogIn tmp3(PB_0);
a++;
uint16_t TC = tmp3.read_u16();
printf(“Raw thermistor reading is %i\r\n”, TC);
printf(“Hello World this is the Target Device %i\r\n”, a);
//wait(1);
delete &tmp3;
dot->sleep(5, mDot::RTC_ALARM, false);
}
}
#endif
—————————————————————-January 11, 2017 at 9:55 am #16276Jason ReissKeymasterTry to allocate the pin object dynamically.
AnalogIn *tmp3 = new AnalogIn(PB_0);
…
uint16_t TC = tmp3->read_u16();
…
delete tmp3;January 11, 2017 at 10:03 am #16277Chad GoyetteParticipantI just tried this with no luck.
January 11, 2017 at 10:06 am #16278Peter FerlandBlockedHi Chad,
Do you have deep_sleep set to true or false? If you have it set to “true” can you see if there is a different behavior for false?
What version of libxDot mbed-os are you using?There is an old mbed bug for the STM32L1 series related to improper clock setup after restart from deep sleep. More detail including a resolution can be found on the mbed forum here: https://developer.mbed.org/questions/52467/Cant-read-ADC-after-WakeUp-from-deepslee/
Can you try putting the commands for manually resetting the HSI clock from the answer in that thread after the sleep command?January 11, 2017 at 10:15 am #16279Chad GoyetteParticipantI have tried both deepsleep true and false with no change.
mbed-os version 2246:a6f3fd1 which should be 5.1.5.January 11, 2017 at 10:23 am #16280Chad GoyetteParticipantOk i tried the HSI clock restart and that worked. is there a more permanent fix for this or is this the best we have at the moment?
-
AuthorPosts
- You must be logged in to reply to this topic.