现在将DSP28335的McBSP口配置成SPI模式,通过SPI配置AD9747,一直有问题。很不解。
void init_mcbsp_spi()
{
// McBSP-A register settings
McbspaRegs.SPCR2.all=0x0000; // Reset FS generator, sample rate generator & transmitter
McbspaRegs.SPCR1.all=0x0000; // Reset Receiver, Right justify word, Digital loopback dis.
McbspaRegs.PCR.all=0x0F08; //(CLKXM=CLKRM=FSXM=FSRM= 1, FSXP = 1)
//McbspaRegs.SPCR1.bit.DLB = 1; //数字循环模式,自收自发
McbspaRegs.SPCR1.bit.CLKSTP = 2; //Clock stop mode, without clock delay
McbspaRegs.PCR.bit.CLKXP = 0; //0: Transmit data is sampled on the rising edge of CLKX.
McbspaRegs.PCR.bit.CLKRP = 0; //0: Receive data is sampled on the falling edge of MCLKR.
McbspaRegs.RCR2.bit.RDATDLY=01; // FSX setup time 1 in master mode. 0 for slave mode (Receive)
McbspaRegs.XCR2.bit.XDATDLY=01; // FSX setup time 1 in master mode. 0 for slave mode (Transmit)
McbspaRegs.XCR1.bit.XFRLEN1=1;
McbspaRegs.XCR2.bit.XPHASE=0;
McbspaRegs.RCR1.bit.RFRLEN1=0;
McbspaRegs.RCR2.bit.RPHASE=0;
//McbspaRegs.XCR2.bit.XFRLEN2=0;
//McbspaRegs.XCR2.bit.XWDLEN2=0;
McbspaRegs.RCR1.bit.RWDLEN1=2; // 8-bit word
McbspaRegs.XCR1.bit.XWDLEN1=2; // 8-bit word
// Sample Rate Generator Registers
McbspaRegs.SRGR2.all=0x2000; // CLKSM=1, FPER = 1 CLKG periods
McbspaRegs.SRGR1.all=0x000F; // Frame Width = 1 CLKG period, CLKGDV=16
McbspaRegs.SPCR2.bit.GRST=1; // Enable the sample rate generator
delay_loop(); // Wait at least 2 SRG clock cycles
McbspaRegs.SPCR2.bit.XRST=1; // Release TX from Reset
McbspaRegs.SPCR1.bit.RRST=1; // Release RX from Reset
McbspaRegs.SPCR2.bit.FRST=1; // Frame Sync Generator reset
}
配置SPI的每帧数据字节数为2字节,每字节16位,但是发送数据时发现第二个数据发现时钟并不是16位,McbspaRegs.RCR2.bit.RDATDLY=01设置了一位,但是还有一位不明白是怎么来的,有没有大神指导(黄色是片选信号,红色是数据输出,蓝色时钟,绿色数据输入)
|