[chbot] ADC on the DSPic

Andrew Errington chchrobotics@lists.linuxnut.co.nz
Tue, 26 Sep 2006 20:36:39 +1200


Well, all the register settings look correct at first glance.  The only one 
I am not sure about is ADCON3:SAMC<4..0>.  You have it at 00000, but there 
is a warning in the datasheet (70046E.pdf page 17-8) about this value only 
being permitted if you are using more than one sample/hold amp. for 
sequential conversions (I am paraphrasing here).  I assume that means you 
need to use MUXA and MUXB alternately.  AFAICS in your case you are only 
using MUXA, so maybe SAMC needs to be a value other than zero.

Hope this helps.  If not, further exploration is required...

Andrew

On Tue, 26 Sep 2006 20:10, you wrote:
> Further info: I can read the values from the other pins if I enable one
> at a time with the ADCSSL register.
> If I enable more than one of the pins, it only returns the value for the
> first one.
>
> Ive been debugging this and can confirm that its only changing the
> ADCBuf0 register.
>
> Carl Ranson wrote:
> > I'm tying to use AN4-AN7 as the analog input pins. I don't need fast
> > sampling so I though i'd set it up to cycle through those pins for
> > channel 0 rather than try to set up all 4 ADC channels.
> >
> > paraphrasing what the VDI generated...
> >
> > ; B15:0=CSSL15:0
> > ADCSSL = 0x00F0
> >
> > ; B15:14=CH123NB1:0 B13=CH123SB B12=CH0NB B11:8=CH0SB3:0
> > ; B7:6=CH123NA1:0 B5=CH123SA B4=CH0NA B3:0=CH0SA3:0
> > ADCHS = 0x0004
> >
> > ; B15:0=PCFG15:0
> > ADPCFG = 0x010F
> >
> > ; B12:8=SAMC4:0 B7=ADRC B5:0=ADCS5:0
> > ADCON3 = 0x0001
> >
> > ; B15:13=VCFG2:0 B12=OFFCAL B10=CSCNA B9:8=CHPS1:0
> > ; B7=BUFS B5:2=SMPI B1=BUFM B0=ALTS
> > ADCON2 = 0x0400
> >
> > ; B15=ADON B13=ADSIDL B12=ADSTBY B9:8=FORM
> > ; B7:5=SSRC B3=SIMSAM B2=ASAM B1=SAMP B0=CONV
> > ADCON1 = 0x8000
> >
> > My understanding from the documents is that this will scan the pins
> > specified by ADCSSL (An4-An7) on sucessive samples using CH0.
> >
> > To sample I'm using the simplest technique I can find which is
> >        // start sampling ...
> >        ADCON1bits.SAMP = 1;
> >        // wait for a bit...should be well over 100ms (i think)
> >        K_Task_Wait(50);
> >        // start Converting
> >        ADCON1bits.SAMP = 0;
> >        // conversion done?
> >        while (!ADCON1bits.DONE);
> >
> >        value = ADCBUF0; // yes then get ADC value
> >
> >
> > I probably just need to come back to it tomorrow and re-read the specs
> > Cheers,
> > CR
> >
> > Michael Pearce wrote:
> >> What 4 ADC channels are you using? RA0 to RA3 ?
> >>
> >> Are you using external reference or just Vdd?
> >>
> >> I will have a look tommorrow when I get some time.
> >>
> >> Mike
> >>
> >> On Sunday 24 September 2006 20:26, Carl Ranson wrote:
> >>> So I've got one of my Sharp range sensors working with
> >>> the dsPic's ADC. Now I'm trying to hook up all 4 and get
> >>> the thing to cycle the ADC sampling through 4 of the pins
> >>> but I cant work out how to set it up.
> >>>
> >>> Does anyone know how to do it?
> >>> Ta.
> >>> C
> >>>
> >>> _______________________________________________
> >>> Chchrobotics mailing list
> >>> Chchrobotics@lists.linuxnut.co.nz
> >>> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> >
> > _______________________________________________
> > Chchrobotics mailing list
> > Chchrobotics@lists.linuxnut.co.nz
> > http://lists.ourshack.com/mailman/listinfo/chchrobotics
>
> _______________________________________________
> Chchrobotics mailing list
> Chchrobotics@lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics