UselessPickles
Active Member
I'm using C. I don't really understand what you mean by "all the interrupt saving issues are taken care of" in C. Just to clarify, I'm talking about the interrupt enable bits; not the interrupt "occurred" flag bits. My problem was that something was always immediately waking the MCU immediately after putting it to sleep. I still don't know what it was, but the simplest and most reliable solution I found was to disable ALL interrupts except the one I want to wake from sleep. I'm not sure how this could be done more simply than storing a copy of all the interrupt enable registers before clearing them, so that I can restore them to their previous state when waking.Are you programming in assembler or C?
STM L7805. And now I know I know what "quiescient current means" and that I should pay attention to it. It's listed as 4.3 mA for this partWhat 5V regulator are you using,
Thanks for the tip on MCP1702-5002. It's a reduction of output current compared to my current part, but 250 mA is more than enough for what I need. The L7805 was overkill. I wish I didn't have to pay $5-8 in shipping and wait up to a week for delivery every time I find another $0.64 part I want to test.
I tried that already, but apparently the opamp I somewhat arbitrarily selected is a very power hungry part. It draws about 1 mA, which is not much less than a simple voltage divider that stays within the 10kOhm max impedance recommendation for the ADC input of the MCU.Battery monitoring is an issue, but can easily taken care of by a buffer opamp
I guess I need to dig into understanding opamp specs more and test with some other parts (I also had issues with the output being non-linear with respect to input as the input approached Vdd)
So basically, have the low power 5V regulator feeding the PIC, and then an FET switch feeding the 5V to everything else - switched ON and OFF by the PIC
I'm already doing this for switched power to the handset and all audio circuitry that isn't used when "off", but with reed relays (partially because I understand how those work and got a bit overwhelmed why trying to research all the different kinds of transistors and FETs).
I want battery voltage available while "off" so that I can avoid attempting to turn on if battery level is low, so I currently have the battery level voltage divider powered by the same "constant" +5V as the MCU. It would just be a matter of adding a bit more complexity so that I can control power to the voltage divider independently of the rest of the circuit to get a voltage reading before deciding whether to power everything else on.
I actually considered this already, but decided it wasn't worth the extra complexity for now, and using up the one remaining unused I/O pin on the MCU that I may want to use for another purpose in the future.
One point to watch is what peripherals are doing while the PIC is in sleep - if you're not careful things like serial ports can draw draw current out the pin while it's sleeping, to cure that, disable the serial port, and set the pin LOW.
Thanks. I'll review what state all my I/O pins at the time I'm going to sleep and see if I need to do anything more than I already am. I already saw significant decreases in current draw by disabling the UART peripherals when I don't need them, which I think accomplished what you are saying, because UART wants to hold the TX line high at all times when not sending data. I never manually set the output value of those pins, so they should default back to low when the UART peripheral is not controlling them. I'll check if I have any other I/O pins held high by default that I should set low when sleeping.
Yeah, I knowI'm quite horrified by 1.22mA just for battery monitoring.
The original car phone with its battery charging circuitry for NiCad batteries draws 159 mA when the batteries are fully charged. My complete project should now be below 40 mA when off and fully charged. So I'm not concerned about it draining my car battery while parked, even for weeks at a time.
I think for now I'll definitely try the voltage regulator you suggested, because that is an easy change with a proportionally huge reduction in power consumption when sleeping. Just that change alone should get me down to about 1.22 mA (voltage divider) + a handful of uA for the MCU and voltage regulator. That's plenty efficient for my needs and keeps battery voltage detection simple.
I could maybe even try doubling the values of my resistors (or more) beyond recommended max impedance for the ADC input. I think I would just have to increase the amount of time I configure to allow for sampling, because it will just take longer for the sampling capacitor to charge (or add an external capacitor to the ADC input pin to act as a "reserve" to allow the sample and hold capacitor to charge quickly)? I'm only reading the voltage once every 5 seconds. I don't need a high sample rate and fast samples
Last edited: