dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: Rombox: won't charge when batteries are dead

Re: Rombox: won't charge when batteries are dead

From: Nix <>
Date: Thu, 17 Jul 2003 00:09:21 +0100

On Wed, 16 Jul 2003, uttered the following:
>> > Alternatively, you could initialize current_channel to 7, not 0; or read
>> > the lot at once in adc_init() to initialize properly without an 8 tick
>> > delay.
>> Nope, you can't read it directly. The ADC needs some time to convert the
>> value (I think it takes about ~28 Ás with the current code). That's one
>> reason for doing one conversion per tick (which is a simple, and for
>> most purposes, good enough solution).
> I think adc_init() should do initial measurements, so after that's been
> called you can query the values right away. I'm not concerned about this function
> blocking for 8 * ~28 Ás, that's still way better that waiting for 8 ticks.

Er, I must be missing something. The first time adc_tick() is called, it
tells the ADC to get channel 1 --- but it reads the contents of channel
0 before that, before ADCSR has been assigned to at all.

What does this read into adcdata[0]? My guess is `garbage' or `nothing
useful', but I'm just guessing here.

The patch below assumes that the initial value of current_channel is the
*last* read in because of this bug:

Index: rockbox-devel/firmware/drivers/adc.c
RCS file: /cvsroot/rockbox/firmware/drivers/adc.c,v
retrieving revision 1.2
diff -u -r1.2 adc.c
--- rockbox-devel/firmware/drivers/adc.c 1 Jul 2002 10:55:47 -0000 1.2
+++ rockbox-devel/firmware/drivers/adc.c 16 Jul 2003 23:03:36 -0000
_at__at_ -51,7 +51,7 _at__at_
 void adc_init(void)
     ADCR = 0; /* No external trigger */
- current_channel = 0;
+ current_channel = ADC_UNREG_POWER - 1;

(We seem to need ADC_EXT_POWER initialized really soon, too, so we
might have to wait for a single tick to let both get worked out. Hm,
perhaps aggressively initializing the lot *would* be simpler.)

`We cannot get a new line down the pipe due to a blockage and we cannot
 dig up the road to clear the blockage because it is covered with the
 wrong type of tarmac.' --- British Telecom, via Mark Lowes
Received on 2003-07-17

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy