网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> FAQ >> 硬件开发 >> 文章正文
  AD50参考代码         ★★★ 【字体:
AD50参考代码,通用于合众达5402DSK板和恒科5402实验
作者:skywolf    文章来源:本站原创    点击数:    更新时间:2004-7-20    
这是我调试恒科5402教学实验箱所写的代码,改参数IfDSK可用于合众达的5402 DSK板

*************************************************
*本程序通用于合众达5402 DSK板和恒科5402教学实验箱
*少量修改也可用于其它用C54xx+AD50的目标板
*支持Software/Hardware Quest Secondary Communication
*************************************************
        .def CodeStart
        .mmregs

        .data
DATA_DP:
TEMP    .word 0

        .text
CodeStart: 
        SSBX    INTM                    ; disable global interrupt
        SSBX    XF          
        .copy "../SP_DP_IPTR.asm"       ;初始化SP/DP/IPTR
        call AD50Init
        call codec
END:    B END

***************************************************
*子程序
***************************************************
*寄存器、宏定义
***************************************************
IfDSK   .set    0           ;0: not DSK, 1: for DSK
SoftHardQuest .set 1        ;0: soft , 1: hard

;McBSP寄存器地址
        .if IfDSK=1         ;McBSP1
SPSAx    .set    48h        ; McBSPx sub-address
SPSDx    .set    49h        ; Write for McBSPx sub-addressed regs
DRR1x    .set    41h        ; Data receive of McBSPx
DXR1x    .set    43h        ; Data transmit of McBSPx
        .else               ;McBSP0
SPSAx    .set    38h        ; McBSP0 sub-address
SPSDx    .set    39h        ; Write for McBSP0 sub-addressed regs
DRR1x    .set    21h        ; Data receive of McBSP0
DXR1x    .set    23h        ; Data transmit of McBSP0
        .endif
       
;AD50寄存器设置    
        .if SoftHardQuest=1     ;Hardware Request
CR1     .set    0101H           ;16bit
CR2     .set    0201H
        .else                   ;Software Request
CR1     .set    0100H           ;15+1
CR2     .set    0200H
        .endif             
CR3     .set    0300H           ;default, no slave
CR4     .set    0490H           ;0490 fs=16k,0400 fs=8k

;Quest Secondary Commuication for AD50
        .if SoftHardQuest=1     ;Hardware Request
Quest2stCOM .macro
        SetFC                   ; set FC=1
        .endm  
        .else                   ;Software Request
Quest2stCOM .macro
        STM     #0000H,DXR1x
        CALL    XSR_RDY         ; wait till McBSPx transmit ok
        STM     #0001H,DXR1x
        CALL    XSR_RDY         ; wait till McBSPx transmit ok
        .endm
        .endif

;设置/清除FC       
        .if IfDSK=0
SetFC   .macro
        SSBX XF
        .endm
ClrFC   .macro
        RSBX XF
        .endm      
        .else
SetFC   .macro
        PORTW   *AR2, 04h
        .endm
ClrFC   .macro
        PORTW   *AR1, 04h
        .endm              
        .endif
               
        .text
***************************************************
*初始化AD50
***************************************************
AD50Init:
** McBSP串口初始化
        STM     #00h, SPSAx      ; SPCR11
        STM     #4000h, SPSDx    ; Put McBSPx receive in reset
       
        STM     #01h, SPSAx      ; SPCR21
        STM     #0100h, SPSDx    ; Soft mode, Put McBSPx transmit in reset

        STM     #02h, SPSAx      ; RCR11
        STM     #0040h, SPSDx    ; 1 word per frame, 16-bit word

        STM     #03h, SPSAx      ; RCR21
        STM     #0000h, SPSDx    ; Frame sync for each word, 0-bit delay

        STM     #04h, SPSAx      ; XCR11
        STM     #0040h, SPSDx    ; 1 word per frame, 16-bit word

        STM     #05h, SPSAx      ; XCR21
        STM     #0000h, SPSDx    ; Frame sync for each word, 0-bit
delay         

        STM     #0Eh, SPSAx      ; PCR1
        STM     #000Ch, SPSDx    ; Low active frame syncs

;** McBSPx transmit out of reset, prepare initializing codec AD50

        STM     #00h, SPSAx      ; SPCR11
        STM     #4001h, SPSDx    ; serial port receiver enabled
        STM     #01h, SPSAx      ; SPCR21
        STM     #0101h, SPSDx    ; XRST=1, enable transmit, soft mode


;for DSK Only
FC_set  .int    0008h            ; set FC bit 
FC_clr  .int    0000h            ; clear FC bit
        STM     #FC_clr, AR1
        STM     #FC_set, AR2 
       
;初始化AD50
        rpt     #8000           ;wait 150us after reset(Hardware Reset)
        NOP

        CALL    XSR_RDY          ; wait till McBSPx transmit ok
        Quest2stCOM
        STM     #(CR1|0080H), DXR1x   ;SoftReset
        CALL    XSR_RDY          ; wait till McBSPx transmit ok
        NOP

        Quest2stCOM
        STM     #CR1, DXR1x     ;out of Reset
        CALL    XSR_RDY
       
        rpt     #8000           ;wait 150us after reset(Software Reset)
        NOP

        Quest2stCOM
        STM     #CR2, DXR1x     ; CR2,
        CALL    XSR_RDY

        Quest2stCOM
        STM     #CR3, DXR1x     ; CR3,
        CALL    XSR_RDY

        Quest2stCOM
        stm     #CR4,DXR1x 
        CALL    XSR_RDY
       
        rpt #0FFFFH      ;PLL等待至少18个frame syncs才稳定
        nop

        RET                                            
       
**************************   
** XSR_RDY Test         **
**************************   
XSR_RDY:
        STM     #01h, SPSAx             ; SPCR21
        LDM     SPSDx,A
        AND     #2H,A
        BC      XSR_RDY, AEQ            ; branch to XSR_RDY if TC=0, else
return
        .if SoftHardQuest=1             ;hard
        ClrFC
        .endif
        RET
**************************   
** RSR_RDY Test         **
**************************   
RSR_RDY:               
        STM     #00h, SPSAx             ; SPCR21
        LDM     SPSDx,A
        AND     #2H,A
        BC      RSR_RDY, AEQ            ; branch to XSR_RDY if TC=0, else
return
        .if SoftHardQuest=1             ;hard
        ClrFC
        .endif       
        RET
       
********************
* codec
********************
codec:
oo:
        call RSR_RDY        ;检查接收完毕
        ldm DRR1x, b        ;读入收到的
        and #0fffeh,b       ;这句在31+1数据格式时才有用
        call XSR_RDY        ;
        stlm b,DXR1x        ;
        b oo                ;简单起见用了无限循环
        ret
   

        .end
               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    两个从AD50和DSP连接
    两个AD50和DSP连接
    AD50和一个DSP的连接
    AD50模拟和数字电源的连接
    AD50的去耦合电容的连接
    AD50C程序已经调试好
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号