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:
>
> 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/Message
Re: read with SPI
2004-11-26 by mahlerweb
Attachments
- No local attachments were found for this message.