This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于28335的mcbsp 模拟SPI向74HC164发送数据点亮数码管的问题



这两天在学习28335的mcbsp 模拟SPI向74HC164发送数据,六个74HC164级联,然后把数据在六个数码管上进行显示,现在也不知道数据有没有传输成功,因为数码管没反应,很着急

init_mcbsp_spi();
sdata1 = 0x2222;
sdata2 = 0x0005;
// Main loop to transfer 32-bit words through MCBSP in SPI mode periodically
for(;;)
{
// while(McbspaRegs.SPCR2.bit.XRDY==1) {}
for(i=0;i<3;i++)
{
//sdata1=data[i];
mcbsp_xmit(sdata1);
while(!McbspaRegs.SPCR2.bit.XEMPTY) {}
delay_loop();
rdata1++;
}

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 = 0;
McbspaRegs.SPCR1.bit.CLKSTP = 2; // Together with CLKXP/CLKRP determines clocking scheme
McbspaRegs.PCR.bit.CLKXP = 0; // CPOL = 0, CPHA = 0 rising edge no delay
McbspaRegs.PCR.bit.CLKRP = 0;
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)

McbspbRegs.XCR2.bit.XPHASE=0;
McbspbRegs.RCR2.bit.RPHASE=0;
McbspbRegs.XCR1.bit.XFRLEN1=0;
McbspbRegs.RCR1.bit.RFRLEN1=0;

McbspaRegs.RCR1.bit.RWDLEN1=2; // 32-bit word
McbspaRegs.XCR1.bit.XWDLEN1=2; // 32-bit word

McbspaRegs.SRGR2.all=0x2014; // CLKSM=1, FPER = 1 CLKG periods
McbspaRegs.SRGR1.all= 0x0031; // 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
delay_loop();
McbspaRegs.SPCR2.bit.FRST=1; // Frame Sync Generator reset
}

void mcbsp_xmit(int a)
{
McbspaRegs.DXR1.all=a;
}

真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?