|
软件设计
系统中TMS320C6711通过McBSP将图像处理结果采用主动发送的方式发送给TMS320LF2407,后者通过响应SCI中断的方式接收数据信息。
串行通讯初始化程序
TMS320C6711与TMS320LF2407进行串行通讯的软件设计难点是McBSP与SCI的初始化程序设计。初始化程序包括对芯片的管脚配置、通讯模式配置和中断配置等方面。以下分别给出TMS320C6711的McBSP模块和TMS320LF2407的SCI模块的初始化程序模块。
(1)TMS320C6711的McBSP模块初始化程序
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void init_mcbsp0_master(void)</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> {</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCBSP_Config mcbspCfg0=</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> {</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00010001,//配置spcr寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x000D0000,//配置rcr寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00040020,//配置xcr寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x200000ef,//配置srgr寄存器,</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> //波特率设定为312.5kb/s</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00000000,//配置mcr寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00000000,//配置rcer寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00000000,//配置xcer寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> 0x00000b0c//配置pcr寄存器</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> };</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">
- </font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> hMcbsp0=MCBSP_open(MCBSP_DEV0, MCBSP_OPEN_RESET);</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> //选用port 0</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCBSP_config(hMcbsp0,&mcbspCfg0);</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">
- </font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> IRQ_map(IRQ_EVT_RINT0,13);//映射接收中断0为</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> //13号中断</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> IRQ_reset(IRQ_EVT_RINT0);</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> IRQ_enable(IRQ_EVT_RINT0);//开中断</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">
- </font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCBSP_enableRcv(hMcbsp0);</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCBSP_enableSrgr(hMcbsp0);//Handle to SRGR</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCBSP_enableFsync(hMcbsp0);</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> }</font>
复制代码
(2)TMS320LF2407的SCI模块初始化程序
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void sci_INIT(void)</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> {</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> MCRA=MCRA|0x0003; //设置引脚SCITXD/IOPA0和</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> //SCIRXD/IOPA1为串行通讯功能</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> PADATDIR=0X0100; //设PA口为输入口</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCICTL1=0x13; //使能接收和发送</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCICTL2=0x02; //禁止发送中断,使能接收中断</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCICCR=0X07; //8位字长,1个停止位,空闲线多处</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> //理器模式,无奇偶校验</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCIHBAUD=0x00; //波特率设为312.5kb/s</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCILBAUD=0x09;</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCIPRI=0x00; //接收为高优先级中断</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCIRXST=SCIRXST&0xbf;//清除SCI接收中断标志</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> SCICTL1=0x33; //保存设置</font>
- <font size="4" style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> }</font>
复制代码
利用TMS320C6711的McBSP和TMS320LF2407的SCI可以实现异步串行数据通讯,具有电路简单、设置灵活、数据传输速度快、性能可靠稳定等特点。在此基础上可成功构建主从式双DSP数据处理系统,有效解决单一DSP系统数据处理能力与控制能力难以兼顾的问题。本文所介绍的设计方案已在实际应用系统中采用,并经长时间运行检验。实践证明,此设计方案是一种有效的多DSP数据交换手段。
|
|