请教高手:OMAPL138的DSP核负责数据采集与处理,mcbsp连接AIC23,数据采集部分直接采用mcbsp进行采集,数据发送部分采用mcbsp+edma3乒乓操作的方式,在CCS仿真时,数据采集和发送都正常,但是程序烧写进NAND FLASH后,数据采集部分正常(液晶显示的采集数据波形正常),测试数据发送的EDMA中断进入节奏正常,但是从mcbsp测试的输出数据一直保持低电平,导致AIC23没有输出波形。程序如下,请高手帮我分析一下原因,谢谢!
void McBSP0Init(void)
{
// McBSP0 串行口控制寄存器
SPCR |=(1<<13|1<<7);
SPCR &= ~(1<<23 |1<<22 | 1<<16 |1); // Disable FRST, GRST, XRST, RRST first.
// McBSP0 管脚控制寄存器
PCR = (0 << 11 | //transmit frame-synchronization signal is derived from external source, FSX is an input pin.
0 << 10 | //receive frame-synchronization signal is derived from an external source, FSR is an input pin.
0 << 9 | //CLKX is an input pin and is driven by an external clock
0 << 8 | //receive clock-CLKR is an output pin and is driven by the internal sample-rate generator
0 << 7 | //sample rate generator input clock mode bit, conjunction with CLKSM bit to select the input clock,McBSP internal input clock
0 << 3 | //transmit frame-synchronization polarity bit: active high
0 << 2 | //receive frame-synchronization pulse is active high
1 << 1 | // CLKXP TX data transmit data driven on falling edge of CLKX
1 ); // CLKRP RX data driven on RISING edge of CLKR
// McBSP0 接收控制寄存器
RCR = ( 0 << 31 | // single-phase frame
1 << 24 | //2 word in phase 2
2 << 21 | // 16 bit word in phase 2
0 << 19 | // No companding
0 << 18 | // 第一个帧脉冲重新开始传输之后,接收帧同步脉冲
1 << 16 | // 1-bit delay
1 << 8 | // 2 word in phase 1
2 << 5 | //16 bit word in phase 1
0 << 4 | // no reversal
0 );
// McBSP0 发送控制寄存器
XCR = ( 0 << 31 | // single-phase frame
1 << 24 | // 2 word in phase 2
2 << 21 | // word length is 16 bit
0 << 19 | //no companding
0 << 18 | // Ignore fs glitch
1 << 16 | //1 bit delay
1 << 8 | //2 word in phase 1
2 << 5 | //16 bit word
0 << 4 | // no reversal
0 );
//McBSP0 write FIFO control register
// 延时等待内部同步
unsigned char i;
for(i=0;i<100;i++)
asm (" nop");
//8. enable transimit and / or receive
/* SPCR |= (1 << 16 | 1); //Enable RRST, XRST
for(i=0;i<100;i++)
asm (" nop ");*/
}
发送部分ping pong paRAM 参数
static struct EDMA3CCPaRAMEntry const PingxmtPar =
{
(unsigned int)(1 << 20 | 3 << 12), // Opt set
(unsigned int)pingxmt, // 源地址
(unsigned short)(BYTES_PER_SAMPLE), // aCnt
(unsigned short)(AUDIO_BUF_SIZE), // bCnt
(unsigned int) (SOC_MCBSP_0_DATA_REGS), // 目标地址
(short) (BYTES_PER_SAMPLE), // 源 bIdx
(short)(0), // 目标 bIdx
(unsigned short)(Pongxmt_PaRAM_ID * SIZE_PARAMSET), // 链接地址 Pongxmt_PaRAM_ID
(unsigned short)(AUDIO_BUF_SIZE), // bCnt 重装值
(short)(0), // 源 cIdx
(short)(0), // 目标 cIdx
(unsigned short)1 // cCnt
};
static struct EDMA3CCPaRAMEntry const PongxmtPar =
{
(unsigned int)(1 << 20 | 3 << 12), // Opt set
(unsigned int)pongxmt, // 源地址
(unsigned short)(BYTES_PER_SAMPLE), // aCnt
(unsigned short)(AUDIO_BUF_SIZE), // bCnt
(unsigned int) (SOC_MCBSP_0_DATA_REGS), // 目标地址
(short) (BYTES_PER_SAMPLE), // 源 bIdx
(short)(0), // 目标 bIdx
(unsigned short)(Pingxmt_PaRAM_ID * SIZE_PARAMSET), // 链接地址 Pingxmt_PaRAM_ID
(unsigned short)(AUDIO_BUF_SIZE), // bCnt 重装值
(short)(0), // 源 cIdx
(short)(0), // 目标 cIdx
(unsigned short)1 // cCnt
};
static void EDMA3ParamInit(void)
{
EDMA3CCPaRAMEntry paramSet;
memcpy(¶mSet, &PingxmtPar, SIZE_PARAMSET – 2);
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, Pingxmt_PaRAM_ID, ¶mSet);
memcpy(¶mSet, &PongxmtPar, SIZE_PARAMSET – 2);
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, Pongxmt_PaRAM_ID, ¶mSet);
memcpy(¶mSet, &PingxmtPar, SIZE_PARAMSET – 2);
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCBSP0_TX, ¶mSet);
xfreebuf = xpongbuf;
rfreebuf = rpongbuf;
}
void InitMcbspEdma(void)
{
unsigned int i;
for(i=0;i<AUDIO_BUF_SIZE;i++)
{
pingrcv[i] = 0;
pongrcv[i] = 0;
pingxmt[i] = 0;
pongxmt[i] = 0;
}
EDMA3Init(SOC_EDMA30CC_0_REGS, 0);
EDMA3IntSetup();
// 申请 EDMA 通道,通道 3 用于发送
EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
EDMA3_CHA_MCBSP0_TX, EDMA3_CHA_MCBSP0_TX, 0);
// 初始化 DMA 参数
EDMA3ParamInit();
//初始化 McBSP0 参数
McBSP0Init();
// 使能 EDMA 传输
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCBSP0_TX,
EDMA3_TRIG_MODE_EVENT);
// 使能 接收// 使能 发送
SPCR |= (1 << 16 | 1); //Enable RRST, XRST
for(i=0;i<100;i++)
asm (" nop ");
}
static void EDMA3CCComplIsr(void)
{
IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
// GPIOPinWrite(SOC_GPIO_0_REGS, 102, 0);
// 判断发送 DMA 完成
if(EDMA3GetIntrStatus(SOC_EDMA30CC_0_REGS) & (1 << EDMA3_CHA_MCBSP0_TX))
{
// 清除 3 通道中断标志
EDMA3ClrIntr(SOC_EDMA30CC_0_REGS, EDMA3_CHA_MCBSP0_TX);
if(xfreebuf == xpingbuf)
xfreebuf = xpongbuf;
else
xfreebuf = xpingbuf;
}
}
Tony Tang:
没看到上面有Pinmux管脚配置.
lan teng:
回复 Tony Tang:
您好,有的,在程序的其它地方,这里没有上传,mcbsp0的Pinmux配置:
*(unsigned int *)0x01C14128 = 0x02222220; // PINMUX2 resgister
Tony Tang:
回复 lan teng:
建议你把pinmux, PSC配置都放到aisgen里配置试试。
lan teng:
回复 Tony Tang:
您好,将pinmux和PSC配置放到aisgen里配置,烧写进NAND FLASH后,仍然是mcbsp的数字输出都为低电平。另外,我今天试了将数据发送改为mcbsp直接发送,不用EDMA3,测试mcbsp的数字输出信号正常,不再是低电平,这是不是可以说明,mcbsp设置没有问题,问题在EDMA3的设置部分,但是我也找不出问题,望指教,谢谢!
Tony Tang:
回复 lan teng:
估计是EDMA配置的顺序有问题,导致EDMA事件丢失了,然后该EDMA通道卡死了。
lan teng:
回复 Tony Tang:
EDMA事件丢失,通道卡死还会不断进入EDMA发送中断吗?
Tony Tang:
回复 lan teng:
不会EDMA中断了,EDMA都不动作了,怎么还会有中断。
lan teng:
回复 Tony Tang:
但是我测试EDMA中断还在正常进入,只是mcbsp的输出数字信号不对,全为一个电平。仿真测试都正常,为什么烧写到NAND FLASH后上电运行就不对了,.这是什么情况,麻烦帮我分析一下,谢谢!
lan teng:
回复 Tony Tang:
您好,我将程序烧写进NAND FLASH 后,上电运行,同时用CCS查看程序运行时各个寄存器地址的设置,用于连接的两个PaRAM地址设置值与程序设置值一致,mcbsp发送对应的PaRAM3地址上,SRC,A_B_CNT,LINK_BCNTRLD地址上的数值都一直在更新,与程序设置相符,只是mcbsp的DXR寄存器地址上的值一直为0.感觉是EDMA3没有把数据发送给mcbsp的DXR,但是PaRAM3的DST地址上明明就是mcbsp的DXR的地址0x01D10004,我彻底懵了,这是怎么回事,请指教,谢谢!
lan teng:
回复 Tony Tang:
终于找到问题了,mcbsp发送数据地址分配在shared RAM中,mcbsp输出数字信号就正常了,之前一直在L2 RAM中放着,但是不明白为什么,请指教,谢谢!