本帖最后由 niuyuanhai 于 2014-4-16 21:19 编辑
MCBSP工作在SPI模式下作为Master向ad9834写频率字,时序有问题,CLKX(spi中的sck)正常,但是FSX(spi中的ss)不正常,下图是测试的时序图,
3号线是DX(数据),2号线是CLKX(时钟),1号线是FSX(帧同步)。正确的情况下帧同步信号是不是应该这样: 不发送数据是一直高电平,
发送数据时自动跳变到低电平,传输结束后自动跳回高电平? 但是我的FSX比较乱,传输数据过程中经常高点转换:(
请问各位高手,帮忙分析下,为什么我的FSX信号这个样子?十分感谢……
这是我的一个测试程序:
void trans(Uint16 con_word)
{
McbspbRegs.DXR1.all=con_word;
}
这是Mcbspb的配置代码:
void InitMcbspb(void)
{
McbspbRegs.SPCR2.bit.XRST=0;
McbspbRegs.SPCR1.bit.RRST=0;
McbspbRegs.SPCR2.bit.GRST=0;
McbspbRegs.SPCR1.bit.CLKSTP=11; //enable or diable the Clock Stop Mood
McbspbRegs.PCR.bit.CLKXP=0; //set the transmit clock polarity
McbspbRegs.PCR.bit.CLKRP=0;
McbspbRegs.PCR.bit.CLKXM=1;
delay_loop();
McbspbRegs.PCR.bit.SCLKME=0;
McbspbRegs.SRGR2.bit.CLKSM=1;
McbspbRegs.SRGR1.bit.CLKGDV = CLKGDV_VAL; // CLKG frequency = LSPCLK/(CLKGDV+1)
McbspbRegs.PCR.bit.FSXM=1; //Transmit frame-synchronization mode
McbspbRegs.SRGR2.bit.FSGM=0; //Sample rate generator transmit frame-synchronization mode
McbspbRegs.PCR.bit.FSXP=1; //Set the transmit frame-synchronization polarity
McbspbRegs.XCR2.bit.XDATDLY=1; //Set the Transmit Data Delay
McbspbRegs.RCR2.bit.RDATDLY=1;
McbspbRegs.XCR2.bit.XPHASE=0; //Choose one or two Phases for the Transmit Frame
McbspbRegs.RCR2.bit.RPHASE=0;
McbspbRegs.XCR1.bit.XFRLEN1=0;
McbspbRegs.RCR1.bit.RFRLEN1=0;
McbspbRegs.XCR1.bit.XWDLEN1=2;
McbspbRegs.RCR1.bit.RWDLEN1=2;
McbspbRegs.SPCR2.bit.GRST=1; // Enable the sample rate generator
clkg_delay_loop(); // Wait at least 2 CLKG cycles
McbspbRegs.SPCR2.bit.XRST=1; // Release TX from Reset
McbspbRegs.SPCR1.bit.RRST=1; // Release RX from Reset
clkg_delay_loop();
McbspbRegs.SPCR2.bit.FRST=1; // Frame Sync Generator reset
}
这是两个延时函数:
void delay_loop(void)
{
long i;
for (i = 0; i < MCBSP_INIT_DELAY; i++) {} //delay in McBsp init. must be at least 2 SRG cycles
}
void clkg_delay_loop(void)
{
long i;
for (i = 0; i < MCBSP_CLKG_DELAY; i++) {} //delay in McBsp init. must be at least 2 SRG cycles
}
|