我在项目中使用spib与ads1259链接,希望读出1259的9个寄存器的内容,可是没有成功。
我的程序如下:
main(){
.....
spi_xmit(0x20);
spi_xmit(0x08);
for( i=0;i<9;i++){
spi_xmit(0x00);
while(SpibRegs.SPIFFRX.bit.RXFFST !=1) { }
rdata[i] = SpibRegs.SPIRXBUF;
}
}
void spi_init()
{
SpibRegs.***.all =0x0007; // Reset on, rising edge, 16-bit char bits
SpibRegs.***.all =0x0006; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpibRegs.SPIBRR =0x007F;
SpibRegs.***.all =0x0087; // Relinquish SPI from Reset
SpibRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
}
void spi_xmit(Uint16 a)
{
a<<=8;
SpibRegs.SPITXBUF=a;
}
void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpibRegs.SPIFFTX.all=0xE040;
SpibRegs.SPIFFRX.all=0x2044;
SpibRegs.SPIFFCT.all=0x0;
}