DSP 54x串口FAQ |
时间:2013-11-23 来源:123485.com 作者:9stone |
| |
| 串口|
| |
| | 本人正在使用‘542的BUFFER串口,手册上只有2K BUFFER内的地址设置, 不知道这2K BUFFER是否可以在程序存贮区中任意指定?请赐教。 | |
| | ’54X的BPS的ARR和AXR都是11位,其基地址可以查看相应DSP的DATA SHEET。 例如:‘542占用0800H-0FFFH,C548占用0800H-0FFFH以及1800H-1FFFH | |
| |
| | 一般DSP串口的工作频率能不能达到其CPU的工作频率? 比如,40M的DSP,它的串口能接40M b/s的数据流吗? | |
| | 我用5402时,用内部的时钟作为串行时钟输出,我测得的频率达到100MHZ, 但我并没有这样用过,我用的是外部的时钟,接ST-BUS,较慢。 | |
| | 不可能。 串口速度由其时钟决定
公式:
f(pulse mode)=f(timer clock)/period register f(clock mode)=f/(2*period register)
如果是内部时钟 f(max timer clock)=f(H1)/2 如果是外部时钟 f(max timer clock)=f(H1)/2.6
注意: f(H1)并不是C3x外接的时钟频率,而是C3x的内部分频后的,c3x好象是二分频 | |
| |
| | mcbsp的个寄存器的sub address是什么意思?比如RCR10的地址是39H,SUB ADDRESS是02,是说地址是3902H呢?还是说把0002写到0038H,SPSA0,则0039H的SPSD0对应的就是RCR10的值,还请大虾指教! | |
| | 应该是先把把0002写到0038H(SPSA0),则0039H的SPSD0对应的就是RCR10的值, | |
| |
| | 449 5402的mcbsp能否通过232与主机通讯? | |
| | 我的理解(没试过,不一定对)是不需加什么板卡,但好像得有电平转换吧?MCBSP可以模拟异步232串口,在这份文档里有:spra661 | |
| |
| | 下述寄存器的初值k_spcr1_rs, k_spcr2_rs, K_RCR1, K_RCR2, K_XCR1, K_XCR2, K_PCR, K_SRGRX1, K_SRGRX2具体为何值? 串口初始化完成后,如何发送,接收数据,如何触发中断?具体给出一段例程.谢谢! | |
| | 根据具体要求确定串口那些寄存器的值。比如:时钟和帧信号是进还是出,信号的极性,数据格式是多帧方式还是自动缓冲方式,等等。其中的#K_SPRC_RS是一个值,该值中的某个bit位对应SPRC寄存器的复位位,通常在初始化时要先复位,再修改。对于中断,可考虑直接触发中断,但更常见的是用MCBSP口产生的事件去触发DMA,再由DMA去触发中断。 | |
| |
| | 用mcbsp作数据发送,给dxr1赋要传送的数据之前,我想检验xrdy是否为1,也就是是否可以给dxr1赋值了,由于xrdy是spcr2寄存器的第1位,因此我需要先读取spcr2的值,请问该用何种指令? stm #spcr2,spsa0 这里该如何读取spsd0的值? | |
| | 不能直接使用SPCR2,得先将#1写入SPSA0,选择SPCR2,然后就可以使用LDM 39H,A或将DP=0,使用ORM,BITF,CMPM,等判断。 | |
| |
| | pc和F240串口通讯,时通时不通?作何解释? | |
| | 看看波特率设置对不对,我自己板子上的UART工作得很好。 | |
| |
| | McBSP当作普通同步串口用是否要注意什么问题? | |
| | 设置与原来的串口基本一致,主要注意: 1)帧同步信号,时针信号是输入还是输出? 2)一个帧(FRAME)中是双相(DUAL PHASE) 还是单相(SINGLE PHASE)? 3)一个帧中的字长和每个字的比特数 4)中断产生的方式? 其它设置使用缺省设置就可以了.给你一个参考: 发送设置 SPCR1 = 0x0001 SPCR2 = 0x0030 Transmitter reset, transmit interrupt (XINT to CPU) generated by XSYNCERR; receiver is running with RINT driven by RRDY. FRST & GRST =0 PCR = 0x0A00 FSX determined by FSGM in SRGR, transmit clock driven by external source, receive clock continues to be driven by external source !! SRGR1 = 0x0001 SRGR2 = 0x2000 CPU clock drives the sample rate generator clock (CLKG) after a divide-by-2. A DXR[1,2]-to-XSR[1,2] copy generates the transmit frame-sync signal. XCR1 = 0x0840 XCR2= 0x8421 Dual-phase frame; phase 1 has eight 16-bit words; phase 2 has four 12-bit words, and 1-bit data delay SPCR2 = 0x0031 Transmitter taken out of reset | |
| |
| | c5402McBSP寄存器子地址是怎么回事?如何映射和操作?写一段代码,可否? | |
| | 1.参看下面代码: ;------------------------------------------------ ; McBSP reg addr ;------------------------------------------------ MSP_DRR02 .set 020h ;McBSP 0 receive reg2 MSP_DRR01 .set 021h ;McBSP 0 receive reg1 MSP_DXR02 .set 022h ;McBSP 0 transmit reg2 MSP_DXR01 .set 023h ;McBSP 0 transmit reg1 MSP_DRR12 .set 040h ;McBSP 1 receive reg2 MSP_DRR11 .set 041h ;McBSP 1 receive reg1 MSP_DXR12 .set 042h ;McBSP 1 transmit reg2 MSP_DXR11 .set 043h ;McBSP 1 transmit reg1 MSP_SPSA0 .set 038h ;McBSP 0 sub-address register MSP_REG0 .set 039h ;McBSP 0 write reg MSP_SPSA1 .set 048h ;McBSP 1 sub-address register MSP_REG1 .set 049h ;McBSP 1 write reg ;sub addr MSP_SPCRX1 .set 00h ;Serial Port Control Register MSP_SPCRX2 .set 01h MSP_RCRX1 .set 02h ;Receive Control Register MSP_RCRX2 .set 03h MSP_XCRX1 .set 04h ;Transmit Control Register MSP_XCRX2 .set 05h MSP_SRGRX1 .set 06h MSP_SRGRX2 .set 07h MSP_MCRX1 .set 08h MSP_MCRX2 .set 09h MSP_RCERAX .set 0Ah MSP_RCERBX .set 0Bh MSP_XCERAX .set 0Ch MSP_XCERBX .set 0Dh ;------------------------------------------------ ; initialization serial port (McBSP) ;------------------------------------------------ ;McBSP0 STM #MSP_SPCRX1,MSP_SPSA0 ;reset all !!! STM #K_SPCR1_RS,MSP_REG0 STM #MSP_SPCRX2,MSP_SPSA0 STM #K_SPCR2_RS,MSP_REG0 STM #MSP_RCRX1,MSP_SPSA0 STM #K_RCR1,MSP_REG0 STM #MSP_RCRX2,MSP_SPSA0 STM #K_RCR2,MSP_REG0 STM #MSP_XCRX1,MSP_SPSA0 STM #K_XCR1,MSP_REG0 STM #MSP_XCRX2,MSP_SPSA0 STM #K_XCR2,MSP_REG0 STM #MSP_PCRX,MSP_SPSA0 STM #K_PCR,MSP_REG0 STM #MSP_SRGRX1,MSP_SPSA0 STM #K_SRGRX1,MSP_REG0 STM #MSP_SRGRX2,MSP_SPSA0 STM #K_SRGRX2,MSP_REG0
2.例如: SPCR1_SUBADDR .set 0h RCR10_SUBADDR .set 2h SPSA0 .set 38h ;address is 38h for port 0 SPCR10 .set 39h ;address is 39h for port 0 . . . . STM #SPCR1_SUBADDR,SPSA0h ;Store SPCR1 sub-address into SPSA0 STM #01h, SPCR10 ;Storing 01h into SPCR10. STM #RCR10_SUBADDR,38h STM #4h, 39h ; set RCR1 register ! . . . . | |
| |
| | 我们是用mcbsp与dma方式,但是仅仅发送了当前地址的数据,其余的均未发送,why?下面是我们的程序,请您帮忙检查一下,我们不知道mcbsp与dma具体如何配合使用 stm SPCR1_0,SPSA_0 stm #1000000011010010b,SPSD_0 stm SPCR2_0,SPSA_0 stm #0000000001011010b,SPSD_0 stm PCR_0,SPSA_0 stm #0000111100000001b,SPSD_0 rsbx intm stm #0030h,IMR stm RCR1_0,SPSA_0 stm #0000011100000000b,SPSD_0 ;8 words of each frame;8 bits of each word stm RCR2_0,SPSA_0 stm #000001110000110b,SPSD_0 stm XCR1_0,SPSA_0 stm #0000011100000000b,SPSD_0 ;8 words of each frame;8 bits of each word stm XCR2_0,SPSA_0 stm #0000011100000000b,SPSD_0 ;8 words of each frame;8 bits of each word stm SRGR1_0,SPSA_0 stm #0000000000000100b,SPSD_0 stm SRGR2_0,SPSA_0 stm #0010000000000110b,SPSD_0 stm MCR1_0,SPSA_0 stm #0000h,SPSD_0 stm MCR2_0,SPSA_0 stm #0000h,SPSD_0 stm RCERA_0,SPSA_0 stm #1111h,SPSD_0 stm RCERB_0,SPSA_0 stm #1111h,SPSD_0 stm XCERA_0,SPSA_0 stm #1111h,SPSD_0 stm XCERB_0,SPSA_0 stm #1111h,SPSD_0 * complete the initialization of McBSP0. stm SPCR1_0,SPSA_0 stm #1000000011011011b,SPSD_0 stm SPCR2_0,SPSA_0 stm #0000000001011011b,SPSD_0 stm PCR_0,SPSA_0 stm #0A00h,SPSD_0 stm SPCR2_0,SPSA_0 stm #0000000011011011b,SPSD_0 stm DMSRC4,DMSA ; Uses DMA channel #4 as serial port transmit data channel stm #2100h,DMSDN stm DMDST4,DMSA stm DXR1_0,DMSDN stm DMCTR4,DMSA stm #010h,DMSDN stm DMSFC4,DMSA stm #0010000000000000b,DMSDN stm DMMCR4,DMSA stm #1101001101000001b,DMSDN stm DMIDX0,DMSA stm #0001h,DMSDN stm #0001000000010000b,DMPREC serial_transmit_intr: rete .end | |
| | 可能一:是DMA的设置不对,检查一下DMA的地址增加方式是不是加一。 可能二:DMA只工作了一下,把第一个数据传过去后就停下来了,串口内部的缓冲区的 数值就一直是第一个数据,所以始终就发这一个数据,这种可能性比较大。检查一下DMA的触发设置吧。 另外建议您分开检查DMA和MCBSP的设置,首先看看DMA能不能在内存中搬移数据块,其次用指令不断地向MCBSP的数据口写数据(写,延迟,写,延迟,写,延迟。。。),看MCBSP能不能发出相应的数据。检查完后再把两者合并起来。 |
|
|
|