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.
9 years, 7 months ago.
KL05 deep sleep mode with analog in pin
I have a circuit which uses an analog input pin but then during deep sleep that pin needs to be set as a digital output low to prevent leakage current into another device. I tried adding the following code
AnalogIn conn(PTA12);
- define setRegBits(reg, mask, bits) { reg &= mask; reg |= bits; }
PTA->PDDR |= 1<<12; output PTA->PCOR |= 1<<12; low setRegBits(PORTA->PCR[12],0x0700,0x0100); gpio
This method worked fine for converting serial port pins to output low, but for analog there is still an extra 100uA of current over the normal deepsleep current. Is there something I have to shut down in the analog configuration to get to the minimum current?
Thanks, Tom
1 Answer
9 years, 7 months ago.
It should not be required to put it as GPIO: AnalogIn is high impedance, so it should not be able to create any current which can go into another device.
However your 100uA is familiar: The Freescale ADC consumes roughly that in deepsleep when it is set at its high speed mode. I consider this to be a bug, since it should be disabled in deepsleep, but I don't know if Freescale agrees with me. However something like 2 months ago I submitted pull request that fixes this (not that nicest code, but deepsleep code now checks if it is in this high speed mode, if yes, it disables it before entering deepsleep, and restores it afterwards).
In addition to this there is also that the ADC can make its own clock, even though it was not used this was still enabled in the code. That same pull request also fixed that.
So my guess is that you do not have the latest mbed lib (at least I am pretty sure that fix was rolled out to all KLXX and K20 devices): Can you right click your mbed lib, click update, and test again? (Unless you are sure you got the latest version).
Sorry, I forgot to put the code tags around the code.