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/