|
c6457 中的mcbsp模拟成spi若干问题
[复制链接]
各位大侠,我是菜鸟,想用TI的TMS320SEVM6457上的MCBSP设置成spi串口,和ARM通信,我是主,我按照文档上说的MCBSP初始化成spi的步骤配置好寄存器(步骤见图),现在遇到问题我已经调了一个星期解决不了:
如果我把SPCR寄存器中的GRST始终置零,则最终DX,FSX,CLKX三个管脚在示波器中的波形都正常,但是因为GRST是使能用于分频的SRGR寄存器中的CLKDV位的,所以这样设置就不能分频,频率太高没用;
但是如果我在第三步把GRST置一,则不知道为什么最终就是三个管脚什么信号也没有,示波器上只能捕捉一个瞬时的信号,时钟看起来是对的,但是FSX和DX还没产生数据就没了,三个管脚就没信号了,请问哪位大侠能帮我解答,程序如下:
#include
#include
#include
#include
#include
CSL_McbspHandle hMcbsp;
#define WAIT_FOR_2_CLK do { \
volatile int delayCnt = 2; \
while(delayCnt > 0) --delayCnt; \
}while (0)
void DSP_MCBSP_Init()
{
CSL_McbspObj mcbspObj;
CSL_Status status;
CSL_McbspConfig MyConfig;
CSL_BitMask16 ctrlMask;
MyConfig.SPCR=0x02001000;
MyConfig.RCR=0x7f050000;
MyConfig.XCR=0x00050000;
MyConfig.SRGR=0x20001350;
MyConfig.MCR= 0x00000000;
MyConfig.RCERE0=0x00000000;
MyConfig.RCERE1=0x00000000;
MyConfig.RCERE2=0x00000000;
MyConfig.RCERE3=0x00000000;
MyConfig.XCERE0=0x00000000;
MyConfig.XCERE1=0x00000000;
MyConfig.XCERE2=0x00000000;
MyConfig.XCERE3=0x00000000;
MyConfig.PCR=0x00000A0C;
memset (&mcbspObj, 0, sizeof(CSL_McbspObj));
CSL_mcbspInit (NULL);
hMcbsp = CSL_mcbspOpen (&mcbspObj, CSL_MCBSP_0, NULL, &status);
ctrlMask=0;
ctrlMask = CSL_MCBSP_CTRL_RX_DISABLE
| CSL_MCBSP_CTRL_TX_DISABLE
| CSL_MCBSP_CTRL_FSYNC_DISABLE //GAI
| CSL_MCBSP_CTRL_SRG_DISABLE; //GAI(5-22 9:16)
CSL_mcbspHwControl (hMcbsp, CSL_MCBSP_CMD_RESET_CONTROL, &ctrlMask);
WAIT_FOR_2_CLK;
status = CSL_mcbspHwSetupRaw (hMcbsp, &MyConfig);
WAIT_FOR_2_CLK;
WAIT_FOR_2_CLK;
ctrlMask =0;
hMcbsp->regs->SPCR =0x02E01000;//GRST=1
WAIT_FOR_2_CLK;
hMcbsp->regs->SPCR =0x02401000;
WAIT_FOR_2_CLK;
hMcbsp->regs->SPCR =0x02411001;//XRST=RRST=1
WAIT_FOR_2_CLK;
}
void DSP_MCBSP_Write()
{
int a=5;
while(1)
{
CSL_mcbspWrite (hMcbsp, CSL_MCBSP_WORDLEN_8, &a);
}
}
void main()
{
//int a;
DSP_MCBSP_Init();
DSP_MCBSP_Write();
}
|
|