Rockbox mail archiveSubject: Re: Rombox: won't charge when batteries are dead
Re: Rombox: won't charge when batteries are dead
From: Magnus Holmgren <lear_at_algonet.se>
Date: Tue, 15 Jul 2003 13:30:02 +0200
Magnus Holmgren wrote:
> There's a reason for having power_init that late: the registers it uses
> aren't fully set up until after mpeg_init has been called (at least not
> on a player). When it was placed earlier (after adc_init, IIRC), the
> initial setup of the power history was wrong, and it would take about 30
> minutes before the battery meter showed the correct value.
> So, just moving power_init might not help. Maybe it can be fixed by
> moving some initializations, or maybe it is simply a matter of time.
It turned out to be quite simple, once I spent a minute or two
understanding what happens in adc.c. It is a matter of time: power_init
must be called at least 80 ms after adc_init returns, otherwise it will
get incorrect data.
Each tick adc.c reads one of 8 possible values and triggers conversion
of the next. Battery power is the 7:th value, but it could be a full
tick after adc_init returns until the first conversion takes place, thus
the need to wait 80 ms (8 ticks).
I tried putting power_init after button_init, and after a sleep(8). It
-- Magnus HolmgrenReceived on 2003-07-15