我将McBSP用作SPI功能,我的数据长度是8位,发送一个1,本来应该一个时钟周期为高电平,可是我输出的确是三到四个时钟周期,不知道是我哪设置错了?
这是我的McBSP的初始化程序:
void InitMcbsp(void)
{
EALLOW;
GpioMuxRegs.GPFMUX.all = 0xFF00;
EDIS;
McbspaRegs.SPCR2.bit.XRST = 0; // Reset FS generator, sample rate generator & transmitter
McbspaRegs.SPCR1.bit.RRST = 0; // Reset Receiver, Right justify word,clock stop mode, without clock
for(d=0;d<100;d++)
{;}
McbspaRegs.SPCR2.bit.GRST = 0;
McbspaRegs.SPCR1.bit.CLKSTP = 2;
McbspaRegs.PCR1.bit.CLKXP = 0;
McbspaRegs.PCR1.bit.CLKRP = 1;
McbspaRegs.PCR1.bit.SCLKME = 0; //the clock generated by the sample rate generator is derived form the cpu clock // The Mcbsp is a master in the SPI protocol
McbspaRegs.SRGR2.bit.CLKSM = 1; // CLKSM=1 (If SCLKME=0, i/p clock to SRG is LSPCLK)
McbspaRegs.SRGR1.bit.CLKGDV = 2;
McbspaRegs.PCR1.bit.FSXM = 1; // FSX generated internally, FSR derived from an external source
McbspaRegs.SRGR2.bit.FSGM = 0;
McbspaRegs.PCR1.bit.FSXP = 1;
McbspaRegs.XCR2.bit.XDATDLY=1;
McbspaRegs.RCR2.bit.RDATDLY=1;
McbspaRegs.SPCR1.bit.RJUST = 0;
McbspaRegs.PCR1.bit.CLKXM =1;
McbspaRegs.XCR2.bit.XPHASE = 0;
McbspaRegs.RCR2.bit.RPHASE =0;
McbspaRegs.XCR1.bit.XFRLEN1 = 0;
McbspaRegs.RCR1.bit.RFRLEN1 = 0;
McbspaRegs.XCR1.bit.XWDLEN1 = 0;
McbspaRegs.RCR1.bit.RWDLEN1 = 0;
McbspaRegs.SPCR2.bit.GRST=1; // Enable the sample rate generator
for(d=0;d<100;d++)
{;}
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
} |