本人新手,用2809芯片控制GP21并读取数据,因为GP21只能传8位字节,因此配置函数如下
:void Spi_fifo_init() //子函数Spi_fifo_init(),SPI寄存器配置初始化函数
{
SpibRegs.SPICCR.bit.SPISWRESET=0; //重设SPI
SpibRegs.SPICCR.all=0x0017; //8字元传输,内部回接测试模式,
SpibRegs.SPICTL.all=0x0017; //中断致能,主控模式传输致能
SpibRegs.SPISTS.all=0x0000; //不作传出延迟
SpibRegs.SPIBRR=0x0063; //波特率为(20Mhz/99+1)=200Khz/s
SpibRegs.SPIFFTX.all=0xC028; //致能FIFO,设定传出FIFO为8层
SpibRegs.SPIFFRX.all=0x0028; //设定接收FIFO为8层
SpibRegs.SPIFFCT.all=0x00; //没有TX延迟
SpibRegs.SPIPRI.all=0x0010; //当模拟除错发生,继续SPI运作
SpibRegs.SPICCR.bit.SPISWRESET=1; //放开SPI的重设
SpibRegs.SPIFFTX.bit.TXFIFO=1; //放开FIFO传出重设
SpibRegs.SPIFFRX.bit.RXFIFORESET=1; //放开FIFO接收重设
}
想问一下这么配置可以吗 |