Hi Kevin --
--- In Kevin Cozens <> wrote:
>
> charliem_1216 wrote:
> > (Stupid question first :)
> > * Is your 'myapp' program calling EEPROM_Init() and ADC_Init()?
>
> I have no problem accepting stupid questions at this point. The
answer is
> likely to be some stupid little thing I'm overlooking.
>
> Yes, I do call both of those routines. The first thing my app does
is call a
> master initialization routine. That routine calls EEPROM_Init()
right before
> ADC_Init().
>
> > * You changed the original usleep(10000) to usleep(2000). Why?
> > Maybe more settling time is needed?
>
> The docs I read said the A/D converters need a 2mS settling time after a
> channel change. That should be eaten up by the two dummy channel
reads (the
> ones where the result is tossed away) plus the 2mS delay.
OK, but I have a healthy skepticism of docs sometimes :)
>
> > for (j = 0; j < NUM_OF_SAMPLES; j++)
> > avg = adc_result[i][j] + avg;
> >
> > avg = avg / NUM_OF_SAMPLES;
> >
> > if (avg < 0x7000)
> > avg = avg + 0x10000;
> > * What's this check doing, an underflow or overflow check? Original
> > example code was hardcoded to average 10 samples. Maybe the 0x7000
> > is related (or should be) to NUM_OF_SAMPLES. What happens if you
> > change NUM_OF_SAMPLES from 1 back to 10?
>
> I don't know what the check is doing. It is part of the original
sample A/D
> reading routines. Changing NUM_OF_SAMPLES doesn't help. See below for
> additional comments.
I looked into the cirrus ep9302 datasheet after I posted: it's the
transfer function between reading and voltage (Fig 21). It was
clearer to me once I flipped the axes of the graph.
>
> > * In your ADC_ReadChannel, you do:
> > val = PEEK32(adc_page + DATA_OFFSET);
> > and then loop with:
> > while (((val = PEEK32(adc_page + ADCRESULT_OFFSET)) &
> > SDR_MASK) == SDR_MASK)
> > ;
> > * How do you get the new data after your loop ends?
>
> ADCRESULT_OFFSET (0x0008) and DATA_OFFSET (0x08) have the same
value. The
Wonder why they are separately defined then?
> ts-7250 manual says that reading the result register sets the SDR
>
SDR bit is cleared when a result is read. It's set when the
conversion is complete and ready to read (Cirrus ep9301 User's Guide).
> > The example
> > code does it the other way around: loop until the SDR bit is set in
> > ADCResult, _then_ read the data:
>
> I'm doing what the code did. It calls the busy check and loops until it
> returns false to indicate its not busy. The one change I was trying
was to use
> the value from the read of the result register when the SDR bit
first clears.
Yes, I think you had the right idea. Actually reading it again will
start another conversion, which according to the data sheet, should
not be done without a delay.
>
> > Still no idea why your code works when TEST_PROGRAM is defined
> > though, unless you are missing the init code.
>
> I didn't until about 5pm Friday. Finally tracked it down. See next
message for
> details.
Where did you find the mention of the input impedance?
In any case, I'm glad you worked it out. The ep9302 built-in A/D has
come up before in the forum, and the more working code examples the
better! Maybe you should post your test program to the files section
of the forum?
Regards, ......... Charlie
>
> --
> Cheers!
>
> Kevin.
>
> http://www.ve3syb.ca/ |"What are we going to do today, Borg?"
> Owner of Elecraft K2 #2172 |"Same thing we always do, Pinkutus:
> | Try to assimilate the world!"
> #include <disclaimer/favourite> | -Pinkutus & the Borg
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|