I did some power measurements. They agree with the published values on the datasheet. The LED backlight can add another 2 - 5mA depending on brightness setting.
To converse battery life, the firmware can optionally drops the clock speed to 12MHz. This should allows for a battery life of 10+ hours with the larger LiPo and 5+ hours for the smaller one (vs 2+ and 1+ hours at full speed.) The actual current consumption may vary depending on the amount of time the CPU is active vs sleep.
The firmware has to be able to detect if a charger or USB is present. If so, it can run at the full clock speed of 72MHz
The STM32F103 is quite old and does not have a charger detection hardware built-in. The USB data pin on the STM32F103 can be used as GPIO and is able to detect USB connection. and some of the more common chargers.
Silicon Labs EFM8UB1 on the other hand can detect the complex charging protocol in USB spec. Apple chargers can also be detected as it USB pins can also function as ADC inputs.
Charger Detection
For the STM32F103 FT (5V tolerant) at VDD = 3.3V, the VIH threshold is0.42*(3.3V - 2V) + 1V = 1.546V (min)
STM32F103 I/O Static characteristics |
The voltage at the D- is 3.3V * 50K/(50K+1.5K) = 3.2V which is a logic '1'.Apple chargers uses a resistor network to encode the current capacity. For the 1A chargers, they use a 43K/ 51K voltage divider on the D- pin.
Apple 1A charger resistor networks |
5V * 25K/(25K+43K) = 1.84V which is a logic '1'. This is also treated as a charger.For Apple 0.5A charger, the voltage is at 1.25V which is within undefined area and cannot be read reliably.
USB detection
There are 15K pull down resistors on the USB port. The firmware detect that by configuring the input pin with an internal pull-up resistor.The voltage at the D- is 3.3V * 15K/(50K+15K) = 0.76V which is a logic '0'.If the pin is a '1', then it could mean that the input is floating or that it is connected to an Apple 0.5A or 2.1A charger. I came up with a way to detect whether a pin is floating a while back, but I won't bother here.
The detection code is listed below. I added in Delay(0x80000) for the connector contact debouncing. The smaller Delay(0x200) is there to give a bit for parasitic capacitor to charge up and stabilize.
Status is set to Pwr_Unknown as further detection is needed by secondary mean. If the Battery voltage is above 4.3V that means that the Power Switch is in the On position and external power source is present.
Note: Blogger messes up my code each time I go into the editor. It is too much work to fix their problem. I am giving and switching to using screen captures.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.