这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
eassion yin:
怎么几天了还是没有人回复我啊
这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
mangui zhang:
建议你先用示波器看看输出波形 看看有没有将McBSP配置为SPI
这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
Puyol.Zhou:
回复 eassion yin:
深深怀疑你没有配置相应的gpio
这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
eassion yin:
回复 Puyol.Zhou:
不是gpio的问题,是McbspbRegs配成McbspaRegs了
这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
Puyol.Zhou:
回复 eassion yin:
好吧,高手都喜欢犯低级错误,倒是你的注释有问题,RWDLEN1和XWDLEN1为2的时候是16bit
这两天在学习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;
}
真不知道怎么办了,麻烦大牛们能指点一下,到底哪里有错误?
eassion yin:
回复 Puyol.Zhou:
嗯嗯,眼力真好,呵呵,当时出现错误就到处乱改,什么字长啊,帧长啊,帧同步的高低电平比啊,统统都改来改去,所以注释就没改了