TI中文支持网
TI专业的中文技术问题搜集分享网站

MCBSP配置成SPI问题

我使用28335将Mcbsp配置成SPI接口,数据输出端口2个字节直接出现三角波形(见附件),初始化代码如下

McbspaRegs.SPCR2.all=0x0000; // Reset FS generator, sample rate generator & transmitter
McbspaRegs.SPCR1.all=0x0000; // Reset Receiver, Right justify word, Digital loopback dis.
McbspaRegs.MFFINT.all=0x0; // Disable all interrupts
McbspaRegs.PCR.bit.FSXM = 1; //FSX generated internally, FSR derived from an external source
McbspaRegs.PCR.bit.CLKXM = 1; //CLKX generated internally, CLKR derived from an external source
McbspaRegs.PCR.bit.FSRM = 1;
McbspaRegs.PCR.bit.CLKRM = 1;
McbspaRegs.PCR.bit.SCLKME=0;
McbspaRegs.PCR.bit.FSXP=1;
McbspaRegs.PCR.bit.CLKXP=0;
McbspaRegs.PCR.bit.CLKRP=1; McbspaRegs.SPCR1.bit.CLKSTP = 2; McbspaRegs.RCR2.all=0x0; // Single-phase frame, 1 word/frame, No companding (Receive)
McbspaRegs.RCR1.all=0x0;
McbspaRegs.XCR2.all=0x0; // Single-phase frame, 1 word/frame, No companding (Transmit)
McbspaRegs.XCR1.all=0x0;
McbspaRegs.XCR2.bit.XDATDLY=1; McbspaRegs.RCR2.bit.RDATDLY=1; McbspaRegs.SRGR2.all=0x2000; // CLKSM=1, FPER = 1 CLKG periods
McbspaRegs.SRGR1.all= 0x001D; // Frame Width = 1 CLKG period, CLKGDV=29
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

发送函数

while(McbspaRegs.SPCR2.bit.XRDY != 1);//准备好发送
McbspaRegs.DXR1.all=(Data);

赞(0)
未经允许不得转载:TI中文支持网 » MCBSP配置成SPI问题
分享到: 更多 (0)