Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

read with SPI

read with SPI

2004-11-25 by dasbento@aeiou.pt

Hello,

I'm using SPI to read data of ADS7807U. My problem is not get to read
the last bit, i.e, bit0. How does the SCK work? 

Anybody already work with this and can I help me???

Thanks
      Domingos


IOCLR0 |= SSEL0; //select AD
IOCLR0 |= AD_RC; //(R/C = 0)

delay(2); //wait 50ns

IOSET0 |= SSEL0;
IOSET0 |= AD_RC;

while(!(IOPIN1 & busy_x)){} //wait for busy is 1

IOCLR0 |= SSEL0; //select AD


for(i=0;i<2;i++){
SPI0_SPDR = 0x10;

while(!(SPI0_SPSR & SPIF)){} //wait that transmit

if(i==0){
gyro_x = SPI0_SPDR; //save the 8 most significant bits

gyro_x = (gyro_x << 8);
}else{
gyro_x += SPI0_SPDR;
}
}

IOSET0 |= SSEL0; //deselect AD
_________________________________________________________
CEAC Cursos de forma\ufffd\ufffdo profissional - pe\ufffda informa\ufffd\ufffdes aqui.:
http://ceac.online.pt/

Re: read with SPI

2004-11-26 by mahlerweb

Hi,

I don't know about ADS7808, but i have done some work with MAX1271
and ADS8344, i think it similar.
I think you  started sampling every time by writing 0x10 to SPI,
so you got always only the high byte of conversion.

Try it like this :

 SPI0_SPDR = 0x10; // assumed this statement starts the sampling 
 while(!(SPI0_SPSR & SPIF)){} //wait that transmit
 gyro_x = SPI0_SPDR; //save the 8 most significant bits
 gyro_x = (gyro_x << 8);
 SPI0_SPDR = 0x0;  // do not start sampling anymore
 while(!(SPI0_SPSR & SPIF)){} //wait that transmit  
 gyro_x += SPI0_SPDR;

regards 

Peter

--- In lpc2000@yahoogroups.com, dasbento@a... wrote:
Show quoted textHide quoted text
> 
> Hello,
> 
> I'm using SPI to read data of ADS7807U. My problem is not get to read
> the last bit, i.e, bit0. How does the SCK work? 
> 
> Anybody already work with this and can I help me???
> 
> Thanks
>       Domingos
> 
> 
> IOCLR0 |= SSEL0; //select AD
> IOCLR0 |= AD_RC; //(R/C = 0)
> 
> delay(2); //wait 50ns
> 
> IOSET0 |= SSEL0;
> IOSET0 |= AD_RC;
> 
> while(!(IOPIN1 & busy_x)){} //wait for busy is 1
> 
> IOCLR0 |= SSEL0; //select AD
> 
> 
> for(i=0;i<2;i++){
> SPI0_SPDR = 0x10;
> 
> while(!(SPI0_SPSR & SPIF)){} //wait that transmit
> 
> if(i==0){
> gyro_x = SPI0_SPDR; //save the 8 most significant bits
> 
> gyro_x = (gyro_x << 8);
> }else{
> gyro_x += SPI0_SPDR;
> }
> }
> 
> IOSET0 |= SSEL0; //deselect AD
> _________________________________________________________
> CEAC Cursos de formação profissional - peça informações aqui.:
> http://ceac.online.pt/

Re: [lpc2000] read with SPI

2004-11-26 by FabioDB

Il giorno gio, 25-11-2004 alle 20:59 +0000, dasbento@... ha
scritto:
> 
> Hello,
> 
> I'm using SPI to read data of ADS7807U. My problem is not get to read
> the last bit, i.e, bit0. How does the SCK work? 

Have you tryed to change phase and polarity (CPOL and CPHA bits of SPI
Control Register)?

-- 
FabioDB <fabiodib@...>
Altraqua

Re: read with SPI

2004-11-26 by Gus

if your data is shifted by one bit that means you have the clock 
setup wrong. The easiest way is to scope CLK and SDO while you are 
sending 0x55 and then compare what you see to how the bus should be 
for ADS7807.
>How does the SCK work? 
Acoording to how you setup the SCK (in LPCxxx registers) data will 
be shifted in/out on rising/falling edge on the SCK and you can 
setup SCK to be idle low or high.

Gus
--- In lpc2000@yahoogroups.com, dasbento@a... wrote:
> 
> Hello,
> 
> I'm using SPI to read data of ADS7807U. My problem is not get to 
read
Show quoted textHide quoted text
> the last bit, i.e, bit0. How does the SCK work? 
> 
> Anybody already work with this and can I help me???
> 
> Thanks
>       Domingos
> 
> 
> IOCLR0 |= SSEL0; //select AD
> IOCLR0 |= AD_RC; //(R/C = 0)
> 
> delay(2); //wait 50ns
> 
> IOSET0 |= SSEL0;
> IOSET0 |= AD_RC;
> 
> while(!(IOPIN1 & busy_x)){} //wait for busy is 1
> 
> IOCLR0 |= SSEL0; //select AD
> 
> 
> for(i=0;i<2;i++){
> SPI0_SPDR = 0x10;
> 
> while(!(SPI0_SPSR & SPIF)){} //wait that transmit
> 
> if(i==0){
> gyro_x = SPI0_SPDR; //save the 8 most significant bits
> 
> gyro_x = (gyro_x << 8);
> }else{
> gyro_x += SPI0_SPDR;
> }
> }
> 
> IOSET0 |= SSEL0; //deselect AD
> _________________________________________________________
> CEAC Cursos de formação profissional - peça informações aqui.:
> http://ceac.online.pt/

Re: read with SPI

2004-11-26 by domingos_bento

Hello,
yes I tryed to change phase and polarity, but continue same.

Another thing that happen is that AD to give the double of the scale.
In the datasheet with 0V input would have in hex 0000, midscale (2.5V)
 should have 8000 and to 4.999924V should have FFFF. The results that
I 'm obtain are: 0V input has 0000, 2.5V has FFFF and 4.999924V has FFFE.

thanks
      Domingos

--- In lpc2000@yahoogroups.com, FabioDB <fabiodib@e...> wrote:
Show quoted textHide quoted text
> Il giorno gio, 25-11-2004 alle 20:59 +0000, dasbento@a... ha
> scritto:
> > 
> > Hello,
> > 
> > I'm using SPI to read data of ADS7807U. My problem is not get to read
> > the last bit, i.e, bit0. How does the SCK work? 
> 
> Have you tryed to change phase and polarity (CPOL and CPHA bits of SPI
> Control Register)?
> 
> -- 
> FabioDB <fabiodib@e...>
> Altraqua

Re: read with SPI

2004-11-28 by Richard

Analog supply pins hooked up correctly?



--- In lpc2000@yahoogroups.com, "domingos_bento" <dasbento@a...> 
wrote:
> 
> Hello,
> yes I tryed to change phase and polarity, but continue same.
> 
> Another thing that happen is that AD to give the double of the 
scale.
> In the datasheet with 0V input would have in hex 0000, midscale 
(2.5V)
>  should have 8000 and to 4.999924V should have FFFF. The results 
that
> I 'm obtain are: 0V input has 0000, 2.5V has FFFF and 4.999924V 
has FFFE.
> 
> thanks
>       Domingos
> 
> --- In lpc2000@yahoogroups.com, FabioDB <fabiodib@e...> wrote:
> > Il giorno gio, 25-11-2004 alle 20:59 +0000, dasbento@a... ha
> > scritto:
> > > 
> > > Hello,
> > > 
> > > I'm using SPI to read data of ADS7807U. My problem is not get 
to read
> > > the last bit, i.e, bit0. How does the SCK work? 
> > 
> > Have you tryed to change phase and polarity (CPOL and CPHA bits 
of SPI
Show quoted textHide quoted text
> > Control Register)?
> > 
> > -- 
> > FabioDB <fabiodib@e...>
> > Altraqua

Re: read with SPI

2004-11-28 by domingos_bento

Hello,
I have analog supply pins hooked up correctly!!! 

One the problem is the following:
the data are not read in the first rising edge. I already put CPHA=0
and CPHA=1 and the result is always the same, read ever SCK falling edge.

Anybody already have this problem??

Thanks
      Domingos







--- In lpc2000@yahoogroups.com, "Richard" <richas@y...> wrote:
Show quoted textHide quoted text
> 
> Analog supply pins hooked up correctly?
> 
> 
> 
> --- In lpc2000@yahoogroups.com, "domingos_bento" <dasbento@a...> 
> wrote:
> > 
> > Hello,
> > yes I tryed to change phase and polarity, but continue same.
> > 
> > Another thing that happen is that AD to give the double of the 
> scale.
> > In the datasheet with 0V input would have in hex 0000, midscale 
> (2.5V)
> >  should have 8000 and to 4.999924V should have FFFF. The results 
> that
> > I 'm obtain are: 0V input has 0000, 2.5V has FFFF and 4.999924V 
> has FFFE.
> > 
> > thanks
> >       Domingos
> > 
> > --- In lpc2000@yahoogroups.com, FabioDB <fabiodib@e...> wrote:
> > > Il giorno gio, 25-11-2004 alle 20:59 +0000, dasbento@a... ha
> > > scritto:
> > > > 
> > > > Hello,
> > > > 
> > > > I'm using SPI to read data of ADS7807U. My problem is not get 
> to read
> > > > the last bit, i.e, bit0. How does the SCK work? 
> > > 
> > > Have you tryed to change phase and polarity (CPOL and CPHA bits 
> of SPI
> > > Control Register)?
> > > 
> > > -- 
> > > FabioDB <fabiodib@e...>
> > > Altraqua

Re: read with SPI // Max voltage for ADC is 3.6V!

2004-11-28 by lpc2100_fan

Domingos,

the ADC does not support 5V reference. The max. voltage supported is
3.6V.  There is a good chance your device is gone for good.

Bob



--- In lpc2000@yahoogroups.com, "Richard" <richas@y...> wrote:
Show quoted textHide quoted text
> 
> Analog supply pins hooked up correctly?
> 
> 
> 
> --- In lpc2000@yahoogroups.com, "domingos_bento" <dasbento@a...> 
> wrote:
> > 
> > Hello,
> > yes I tryed to change phase and polarity, but continue same.
> > 
> > Another thing that happen is that AD to give the double of the 
> scale.
> > In the datasheet with 0V input would have in hex 0000, midscale 
> (2.5V)
> >  should have 8000 and to 4.999924V should have FFFF. The results 
> that
> > I 'm obtain are: 0V input has 0000, 2.5V has FFFF and 4.999924V 
> has FFFE.
> > 
> > thanks
> >       Domingos
> > 
> > --- In lpc2000@yahoogroups.com, FabioDB <fabiodib@e...> wrote:
> > > Il giorno gio, 25-11-2004 alle 20:59 +0000, dasbento@a... ha
> > > scritto:
> > > > 
> > > > Hello,
> > > > 
> > > > I'm using SPI to read data of ADS7807U. My problem is not get 
> to read
> > > > the last bit, i.e, bit0. How does the SCK work? 
> > > 
> > > Have you tryed to change phase and polarity (CPOL and CPHA bits 
> of SPI
> > > Control Register)?
> > > 
> > > -- 
> > > FabioDB <fabiodib@e...>
> > > Altraqua

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.