1234下一页
返回列表 发新帖我要提问本帖赏金: 5.00元(功能说明)

[DSP编程] 我的5509A之路

[复制链接]
27387|75
wopt 发表于 2015-3-1 19:57 | 显示全部楼层 |阅读模式
IO, TI, AN, ic, DSP
本帖最后由 wopt 于 2015-7-4 18:03 编辑

说之前,先看看TMS320VC5509A的在产品中的定位。根据TI官方文档,该芯片的特定是高性能、低功耗,使用与个人便携式上网以及无线通信,通常也做协处理器使用,详细内容可以参考datasheet。

  • Miniaturized personal and portable products            个人、小型便携设备
  • 2G, 2.5G and 3G cell phones and basestations         2G, 2.5G and 3G 手机和基站
  • Voice recognition     语音识别
  • GPS receivers           GPS
  • Fingerprint / pattern recognition     指纹/模式识别
  • Wireless modems      无线猫
  • Biometrics     生物识别技术
  • Audio and voice applications    音频与语音应用
  • Low-power vision analytics applications  低功耗视觉分析应用

该帖子不会说TMS320VC5509A的硬件结构和设计,主要以算法实现为主,当然外设是必需的,所以大体上分为简介、外设、数字信号处理、简单图像处理、bios五个部分(或有第六个部分 尾巴)。



第三章 数字信号处理 (基于DSPLIB,参考教材:数字信号处理――原理、算法与应用(第四版))   
    3.1 基本算数运算
    3.2 Q-value
    3.3 sine
    3.4 FFT
    3.5 FIR
    3.6 IIR
    3.7 LMS
    3.8 Kalman
第四章 简单图像处理 (这部分内容还是留在DM642的帖子上吧!~)
Ti IMGLIB库简介
    4.1 图像的反色
    4.2 数字图像的锐化

第五章 DSP/BIOS
   5.1 DSP/BIOS入门

第六章 一个例子(完结)
    6.1 G.711语音编码

差不多就到这里结束了吧。其实关于5509本身没什么好讲的,还是要更加多关注DSP周围的一些知识。相对于那些小制作,该帖偏向于理论,看起来也确实枯燥。再者此贴也只是大概浅谈了一些关于DSP旁边的一些东西。如果要利用5509做个产品,该帖的知识还远远不够。


打赏榜单

zhangmangui 打赏了 5.00 元 2015-07-14

评分

参与人数 1威望 +1 收起 理由
晓白不 + 1 赞一个!

查看全部评分

zhangmangui 发表于 2015-3-1 22:36 | 显示全部楼层
等待中   
 楼主| wopt 发表于 2015-3-2 14:11 | 显示全部楼层
本帖最后由 wopt 于 2015-3-2 14:21 编辑

1.1 TMS320VC5509A Data Sheet
   ps..这个不用多说,看文档就可以了。

1.2 开发环境
以我的为例,开发板: 鸿翔电子 HX-5509A
                     仿真器: 艾瑞合众 seed-xds510plus
                     开发软件: win7 64bit  Code Composer Studio5.5.0
关于开发软件的使用请细看:CCS5.5的详细操作说明


JY-DX-JY 发表于 2015-3-2 15:14 | 显示全部楼层
我们公司就有这个。
海中水 发表于 2015-3-2 16:10 | 显示全部楼层
学习了,C5000我暂时还没有真正的在工程中应用过。
 楼主| wopt 发表于 2015-3-3 09:22 | 显示全部楼层
JY-DX-JY 发表于 2015-3-2 15:14
我们公司就有这个。

论坛的网友都是我的良师益友:lol:lol
 楼主| wopt 发表于 2015-3-3 10:44 | 显示全部楼层
本帖最后由 wopt 于 2015-3-4 10:16 编辑

1.3 软件开发基础
一个DSP应用程序项目包含如下文件:
  • 主程序main.c 。
  • CMD文件。
  • vectors.s55。中断服务表。
  • 运行支持库rtx5xxx.lib,对C运行环境的支持。
  • 芯片支持库cls5xxx.lib,提供芯片特性的支持。

c_init00()是C运行环境的入口,初始化堆栈指针、页指针、全局变量等。
  • 为系统堆栈产生.stack段,并初始化堆栈指针。
  • 从.cinit段初始化数据复制到.bss段中相应的变量。
  • 调用main函数。


1.3.1 伪汇编指令
参考TMS320C55x Assembly Language Tools User's Guide
中文 DSP的汇编伪指令


1.3.2 CMD文件
详情查看DSP与CMD文件的原理
参考:
  1. MEMORY
  2. {
  3.         MMR     : origin = 0000000h, length = 00000c0h
  4.         SPRAM   : origin = 00000c0h, length = 0000040h
  5.         VECS0   : origin = 0000100h, length = 0000100h
  6.         VECS1   : origin = 0000200h, length = 0000100h
  7.         DARAM0  : origin = 0000300h, length = 0003D00h
  8.         DARAM1  : origin = 0004000h, length = 0004000h
  9.         DARAM2  : origin = 0008000h, length = 0004000h
  10.         DARAM3  : origin = 000c000h, length = 0004000h

  11.         SARAM0  : origin = 0010000h, length = 0004000h
  12.         SARAM1  : origin = 0014000h, length = 0008000h
  13.        /* SARAM2  : origin = 0018000h, length = 0004000h */
  14.         SARAM3  : origin = 001c000h, length = 0004000h
  15.         SARAM4  : origin = 0020000h, length = 0004000h
  16.         SARAM5  : origin = 0024000h, length = 0004000h
  17.         SARAM6  : origin = 0028000h, length = 0004000h
  18.         SARAM7  : origin = 002c000h, length = 0004000h
  19.         SARAM8  : origin = 0030000h, length = 0004000h
  20.         SARAM9  : origin = 0034000h, length = 0004000h
  21.         SARAM10 : origin = 0038000h, length = 0004000h
  22.         SARAM11 : origin = 003c000h, length = 0004000h
  23.         SARAM12 : origin = 0040000h, length = 0004000h
  24.         SARAM13 : origin = 0044000h, length = 0004000h
  25.         SARAM14 : origin = 0048000h, length = 0004000h
  26.         SARAM15 : origin = 004c000h, length = 0004000h

  27.         CE0     : origin = 0050000h, length = 03b0000h
  28.         CE1     : origin = 0400000h, length = 0400000h
  29.         CE2     : origin = 0800000h, length = 0400000h
  30.         CE3     : origin = 0c00000h, length = 03f8000h

  31.         PDROM   : origin = 0ff8000h, length = 07f00h
  32. }

  33. SECTIONS
  34. {
  35.     /* 存放程序区 */
  36.      vectors:    {} > VECS0          /* vectors是在rts55x.lib中定义的 */
  37.     .vectors:   {} > VECS1           /* interrupt vector table */
  38.     .cinit:     {} > SARAM0          /* 变量初值和常量 */
  39.     .text:      {} > SARAM1          /* C程序代码 */

  40.     /* 存放数据区 */
  41.     .csldata:    {} > DARAM0          /* csl库 */
  42.     .bss:        {} > DARAM0         /* 全局和静态变量 */
  43.     .const:      {} > DARAM0         /* 字符、浮点常量和用const声明的常量 */
  44.     .data:       {} > DARAM0
  45.     .cio:        {} > DARAM1
  46.     .stack:      {} > DARAM1         /* 保持返回地址,函数间的参数传递,存储局部变量和中间结果 */
  47.     .sysstack:    {} > DARAM1
  48.     .sysmem:     {} > DARAM2         /* malloc,calloc和realloc函数动态分配的存储空间 */
  49. }

1.3.3 新建工程注意事项






zhangmangui 发表于 2015-3-3 22:51 | 显示全部楼层
使用5509A做过相关项目  配合FPGA
支持楼主  继续分享
 楼主| wopt 发表于 2015-3-4 20:05 | 显示全部楼层
本帖最后由 wopt 于 2015-3-4 21:21 编辑

2.1 GPIO
文档:TMS320VC5509A Data Sheet
          TMS320C55x Chip Support Library API Reference Guide


General-Purpose Input/Output (GPIO) ,每个引脚的方向可以有I/O方向寄存器IODIR独立配置,引脚input/ouput状态有I/O数据寄存器IODATA反映或设置。
  1. #include "csl.h"
  2. #include "csl_gpio.h"

  3. void delay();

  4. void main(void)
  5. {
  6.      /* 初始化CSL库 */
  7.     CSL_init();
  8.     /* 确定方向为输出 */
  9.     GPIO_pinDirection(GPIO_PIN1, GPIO_OUTPUT);
  10.         /* 循环闪烁 */
  11.            while (1)
  12.            {
  13.                    GPIO_pinWrite(GPIO_PIN1, 1);
  14.                    delay();
  15.                    GPIO_pinWrite(GPIO_PIN1, 0);
  16.                    delay();
  17.            }
  18. }
  19. void delay()
  20. {
  21.         Uint32 j = 0, k = 0;
  22.         for(j = 0; j < 0x0D; j++)
  23.         {
  24.                 for(k= 0; k<0xffff; k++)
  25.                 {}
  26.         }
  27. }


时钟工作模式
  1. #include "csl.h"
  2. #include "csl_pll.h"
  3. #include "csl_gpio.h"

  4. void delay();
  5. /*锁相环的设置*/
  6. PLL_Config  myConfig      = {
  7.   0,    //IAI: the PLL locks using the same process that was underway
  8.                 //before the idle mode was entered
  9.   1,    //IOB: If the PLL indicates a break in the phase lock,
  10.                 //it switches to its bypass mode and restarts the PLL phase-locking
  11.                 //sequence
  12.   24,    //PLL multiply value; multiply 24 times
  13.   1             //Divide by 2 PLL divide value; it can be either PLL divide value
  14.                 //(when PLL is enabled), or Bypass-mode divide value
  15.                 //(PLL in bypass mode, if PLL multiply value is set to 1)
  16. };

  17. void main(void)
  18. {
  19.         /* 初始化CSL库 */
  20.     CSL_init();
  21.     /* 设置系统的运行速度为144MHz */
  22.     PLL_config(&myConfig);
  23.     /* 确定方向为输出 */
  24.     GPIO_pinDirection(GPIO_PIN1, GPIO_OUTPUT);
  25.         /* 循环闪烁 */
  26.            while (1)
  27.            {
  28.                    GPIO_pinWrite(GPIO_PIN1, 1);
  29.                    delay();
  30.                    GPIO_pinWrite(GPIO_PIN1, 0);
  31.                    delay();
  32.            }
  33. }
  34. void delay()
  35. {
  36.         Uint32 j = 0, k = 0;
  37.         for(j = 0; j < 0x0D; j++)
  38.         {
  39.                 for(k= 0; k<0xffff; k++)
  40.                 {}
  41.         }
  42. }
对比两个程序,后者LED闪烁频率变快了。

 楼主| wopt 发表于 2015-3-4 20:37 | 显示全部楼层
本帖最后由 wopt 于 2015-3-4 21:25 编辑

2.2 Timer
文档:TMS320VC5503/5507/5509/5510 DSP Timers Reference Guide
           TMS320VC5509A Data Sheet (3.11 Interrupts)
           TMS320C55x Chip Support Library API Reference Guide
  1. #include "csl.h"
  2. #include "csl_irq.h"
  3. #include "csl_timer.h"
  4. #include "csl_chip.h"
  5. #include "csl_gpio.h"

  6. //---------Global data definition---------
  7. #define TIMER_CTRL    TIMER_TCR_RMK(\
  8.                       TIMER_TCR_IDLEEN_DEFAULT,    /* IDLEEN == 0 */ \
  9.                       TIMER_TCR_FUNC_OF(0),        /* FUNC   == 0 */ \
  10.                       TIMER_TCR_TLB_RESET,         /* TLB    == 1 */ \
  11.                       TIMER_TCR_SOFT_BRKPTNOW,     /* SOFT   == 0 */ \
  12.                       TIMER_TCR_FREE_WITHSOFT,     /* FREE   == 0 */ \
  13.                       TIMER_TCR_PWID_OF(0),        /* PWID   == 0 */ \
  14.                       TIMER_TCR_ARB_RESET,         /* ARB    == 1 */ \
  15.                       TIMER_TCR_TSS_START,         /* TSS    == 0 */ \
  16.                       TIMER_TCR_CP_PULSE,          /* CP     == 0 */ \
  17.                       TIMER_TCR_POLAR_LOW,         /* POLAR  == 0 */ \
  18.                       TIMER_TCR_DATOUT_0           /* DATOUT == 0 */ \
  19. )

  20. /* Create a TIMER configuration structure that can be passed */
  21. /* to TIMER_config CSL function for initialization of Timer  */
  22. /* control registers.                                        */
  23. TIMER_Config timCfg0 = {
  24.    TIMER_CTRL,               /* TCR0 */
  25.    0x3400u,                  /* PRD0 */
  26.    0x0000                    /* PRSC */
  27. };

  28. //---------Function prototypes---------
  29. /* Reference start of interrupt vector table   */
  30. /* This symbol is defined in file, vectors_timer1.s55 */
  31. extern void VECSTART(void);

  32. /* Function/ISR prototypes */
  33. interrupt void timer0Isr(void);
  34. void taskFxn(void);


  35. /* Create a TIMER_Handle object for use with TIMER_open */
  36. TIMER_Handle mhTimer0;

  37. Uint16 eventId0;
  38. volatile Uint16 timer0_cnt = 0;
  39. int old_intm;
  40. Uint16 tim_val;

  41. //---------main routine---------
  42. void main(void)
  43. {
  44.         /* Initialize CSL library */
  45.         CSL_init();

  46.         /* Set IVPH/IVPD to start of interrupt vector table */
  47.         /* 修改寄存器IVPH,IVPD,重新定义中断向量表 */
  48.         IRQ_setVecs((Uint32)(&VECSTART));

  49.         /* Call function to set timer */
  50.         taskFxn();
  51.     GPIO_pinDirection(GPIO_PIN4, GPIO_OUTPUT);
  52.         while(1)
  53.         {

  54.         }
  55. }

  56. void taskFxn(void)
  57. {
  58.     /* Temporarily disable all maskable interrupts */
  59.         /* 禁止所有可屏蔽的中断源 */
  60.     old_intm = IRQ_globalDisable();

  61.     /* Open Timer 0, set registers to power on defaults */
  62.     /* 打开定时器0,设置其为上电的的默认值,并返回其句柄 */
  63.     mhTimer0 = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET);

  64.     /* Get Event Id associated with Timer 0, for use with */
  65.     /* CSL interrupt enable functions.                    */
  66.     /* 获取定时器0的中断ID号 */
  67.     eventId0 = TIMER_getEventId(mhTimer0);

  68.     /* Clear any pending Timer interrupts */
  69.     /* 清除定时器0的中断状态位 */
  70.     IRQ_clear(eventId0);

  71.     /* Place interrupt service routine address at */
  72.     /* associated vector location */
  73.     /* 为定时器0设置中断服务程序 */
  74.     IRQ_plug(eventId0,&timer0Isr);

  75.     /* Write configuration structure values to Timer control regs */
  76.     TIMER_config(mhTimer0, &timCfg0);

  77.     /* Enable Timer interrupt */
  78.     IRQ_enable(eventId0);

  79.     /* Enable all maskable interrupts */
  80.     IRQ_globalEnable();

  81.     /* Start Timer */
  82.     TIMER_start(mhTimer0);
  83. }

  84. interrupt void timer0Isr(void)
  85. {
  86.     ++timer0_cnt;
  87.         if (timer0_cnt == 1)
  88.         {
  89.                 GPIO_pinWrite(GPIO_PIN4, 1);
  90.         }
  91.     if (timer0_cnt == 200)
  92.     {
  93.                 GPIO_pinWrite(GPIO_PIN4, 0);
  94.     }
  95.     if (timer0_cnt == 400)
  96.     {
  97.             timer0_cnt = 0;
  98.     }
  99. }




 楼主| wopt 发表于 2015-3-4 20:55 | 显示全部楼层
本帖最后由 wopt 于 2015-3-4 21:26 编辑

2.3 Watchdog
文档:TMS320VC5503/5507/5509/5510 DSP Timers Reference Guide
            TMS320C55x Chip Support Library API Reference Guide
  1. #include <csl.h>
  2. #include <csl_wdtim.h>

  3. //---------Global data definition---------
  4. volatile int pscVal, wdtimVal;
  5. WDTIM_Config getConfig;
  6. WDTIM_Config myConfig = {
  7.      0x1000,          /* WDPRD */

  8.      0x0000,          /* WDTCR */
  9.                       // WDOUT    SOFT    FREE    PSC   TDDR
  10.                       //  0b       0b      0b      0b    0b

  11.      0x1000           /* WDTCR2 */
  12.                       // WDFLAG    WDEN   PREMD   WDKEY
  13.                       //   1b       0b     0b      0

  14. };

  15. //---------main routine---------
  16. void main(void)
  17. {
  18.     pscVal = 0;
  19.     wdtimVal = 0;
  20.     CSL_init();

  21. #if(_WDTIM_SUPPORT)
  22.     WDTIM_config(&myConfig);
  23.     WDTIM_FSET(WDTCR, WDOUT, 1);   // 不可屏蔽中断
  24.     WDTIM_FSET(WDTCR, TDDR, 0xF);  // 预定标计数器
  25.     WDTIM_FSET(WDTCR2, PREMD, 0);  // 直接模式
  26.     WDTIM_service();               // 使能看门狗
  27.     while (1)
  28.     {
  29.         pscVal = WDTIM_FGET(WDTCR, PSC);
  30.         wdtimVal = WDTIM_FGET(WDTIM, TIM);
  31.         /* write periodically to WDTIMER  - when this line is commented out,
  32.            the watchdog times out, WDFLAG set to 1, indicating
  33.            that a Watchdog time-out occurred.*/
  34.         //WDTIM_service();
  35.     }
  36. #endif
  37. }
单步调试,观察pscVal、wdtimVal变量

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| wopt 发表于 2015-3-5 18:36 | 显示全部楼层
2.4 RTC
文档:TMS320VC5503/5507/5509 DSP Real-Time Clock (RTC) Reference Guide
           TMS320C55x Chip Support Library API Reference Guide


利用CSL编程,RTC默认24小时制。
  1. #include <csl.h>
  2. #include <csl_rtc.h>
  3. #include <csl_irq.h>

  4. //---------Function prototypes---------
  5. /* Reference start of interrupt vector table   */
  6. /* This symbol is defined in file, vectors_timer1.s55 */
  7. extern void VECSTART(void);

  8. /* Function/ISR prototypes */
  9. void RTC_UpdateIsr(void);

  10. RTC_Config getConfig;
  11. RTC_Config myConfig = {
  12.      0x59,    /* rtcsec   */
  13.      0x00,    /* rteseca  */
  14.      0x21,    /* rtcmin   */
  15.      0x00,    /* rtcmina  */
  16.      0x10,    /* rtchour  */
  17.      0x00,    /* rtchoura */
  18.      0x04,    /* rtcdayw  */
  19.      0x05,    /* rtcdaym  */
  20.      0x03,    /* rtcmonth */
  21.      0x15,    /* rtcyear  */
  22.      0x00,    /* rtcpintr */
  23.      0x82,    /* rtcinten */
  24.      0x00     /* rtcintfl */
  25. };

  26. RTC_Date getDate = {
  27.                 0,
  28.                 0,
  29.                 0
  30. };
  31. RTC_Time getTime = {
  32.                 0,
  33.                 0,
  34.                 0
  35. };

  36. RTC_IsrAddr addr = {
  37.         NULL,
  38.         NULL,
  39.         RTC_UpdateIsr
  40. };

  41. volatile Uint16 sec = 0;
  42. volatile Uint16 set_b = 0;
  43. int old_intm;
  44. int eventId;

  45. void main(void)
  46. {
  47.     CSL_init();

  48.     RTC_reset();
  49.     RTC_config(&myConfig);  // Initialization

  50.     set_b = RTC_FGET(RTCINTEN, SET);

  51.         /* 修改寄存器IVPH,IVPD,重新定义中断向量表 */
  52.         IRQ_setVecs((Uint32)(&VECSTART));

  53.     /* 禁止所有可屏蔽的中断源 */
  54.     old_intm = IRQ_globalDisable();

  55.     /* 获取RTC的中断ID号 */
  56.     eventId = RTC_getEventId();

  57.     /* 清除RTC的中断状态位 */
  58.     IRQ_clear(eventId);

  59.     /* Place interrupt service routine address at
  60.        associated vector location */
  61.     RTC_setCallback(&addr);

  62.     /* Enable RTC maskable interrupts */
  63.     IRQ_enable(eventId);

  64.     /* Enable all maskable interrupts */
  65.     IRQ_globalEnable();

  66.     sec = RTC_RGET(RTCSEC);

  67.     /* Start RTC */
  68.     RTC_start();

  69.         /* Read the current time from the RTC register */
  70.     RTC_getTime(&getTime);
  71.     RTC_getDate(&getDate);
  72.     set_b = RTC_FGET(RTCINTEN, SET);

  73.     while (sec != 0)
  74.     {
  75.         sec = RTC_RGET(RTCSEC);
  76.     }

  77.     /* Enable Update interrupt to start */
  78.     RTC_eventEnable(RTC_EVT_UPDATE);

  79.         while (1)
  80.         {

  81.         }
  82. }

  83. void RTC_UpdateIsr(void)
  84. {
  85.         /* Read the current time from the RTC register */
  86.     RTC_getTime(&getTime);
  87.     RTC_getDate(&getDate);
  88. }



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| wopt 发表于 2015-3-5 18:41 | 显示全部楼层
2.5 ADC
文档:TMS320VC5503/5507/5509/5510 DSP Timers Reference Guide
           TMS320C55x Chip Support Library API Reference Guide

  1. #include <csl.h>
  2. #include <csl_pll.h>
  3. #include <csl_adc.h>

  4. PLL_Config  myPLLConfig = {
  5.   0,    //IAI: the PLL locks using the same process that was underway
  6.                 //before the idle mode was entered
  7.   1,    //IOB: If the PLL indicates a break in the phase lock,
  8.                 //it switches to its bypass mode and restarts the PLL phase-locking
  9.                 //sequence
  10.   24,    //PLL multiply value; multiply 24 times
  11.   1             //Divide by 2 PLL divide value; it can be either PLL divide value
  12.                 //(when PLL is enabled), or Bypass-mode divide value
  13.                 //(PLL in bypass mode, if PLL multiply value is set to 1)
  14. };

  15. ADC_Config myADConfig = {
  16.   0x0000,   // ADCStart = 0, ChSelect = 000.
  17.   0x4f00,        // ADC Sample and Hold Period =
  18.                          // (1 / (ADC Clock)) / (2 (CONVRATEDIV + 1 + SAMPTIMEDIV))
  19.                          // = (1 / (4 MHz)) / (2 (0 + 1 + SAMPTIMEDIV))
  20.                          // = 250 ns  (2 (0 + 1 + 79)) = 40 μs
  21.                          // ADC Conversion Clock = (4 MHz) / (2 (0 + 1)) = 2 MHz
  22.   0x0023    // ADC Clock = (144 MHz) / (35 + 1) = 4 MHz;
  23. };

  24. void main(void)
  25. {
  26.         volatile Uint16 average = 0;
  27.         Uint16 samplestorage[8] = {0};
  28.         Uint8 i = 0;
  29.         Uint16 sum = 0;

  30.     CSL_init();

  31.     /* 设置系统的运行速度为144MHz */
  32.     PLL_config(&myPLLConfig);

  33.     /* 设置ACD的运行速度 */
  34.     ADC_config(&myADConfig);

  35.         while(1)
  36.         {
  37.                 /* samplestorage array. */
  38.                 ADC_read(0, samplestorage, 8);

  39.                 for (i = 0; i < 8; i++)
  40.                 {
  41.                         sum += samplestorage[0];
  42.                 }
  43.                 average = sum / 8;
  44.                 average = 0;
  45.                 sum = 0;
  46.         }
  47. }
CCS Debug-->Tools-->Graph-->Single Time


设置断点,运行,查看变量average变化。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
zhangmangui 发表于 2015-3-6 00:00 | 显示全部楼层
楼主的帖子看来要设置精华了  加油
 楼主| wopt 发表于 2015-3-7 17:14 | 显示全部楼层
本帖最后由 wopt 于 2015-3-20 20:33 编辑

2.6 EMIF
外部存储器接口(External Memory Interface)控制DSP和外部存储器之间的所有数据传输一般来说,EMIF可实现DSP与不同类型存储器的连接。3种类型的存储器提供无缝接口:
  • 异步存储器,比如ROM,FLASH
  • 同步突发SRAM(SBSRAM)
  • 同步DRAM(SDRAM)

需要注意的是VC5509A与VC5509有些许不同,在编程或移植的时,要以TI官方datasheet为参考。

SDRAM的刷新分为AR(自动刷新)和SR(自刷新),VC5509不支持SDRAM自刷新命令,只支持AR,因此CKE引脚必须置‘1’,而VC5509A支持AR和SR两种(《手把手教你学C55x》的书中的错误之处,详情可以查看EMIF文档的3.9节SDRAM Refresh)。对自动刷新,寄存器SDC1中的RFEN位决定EMIF是否具有控制SDRAM自动刷新的能力。

以配置EMIF访问SDRAM为例,一般配置寄存器流程如下:
  • 设置寄存器EBSR,将外部总线设为full EMIF模式。
  • 设置寄存器EGCR,SDRAM工作频率。
  • 设置寄存器CEx,SDSIZE,SDWID等
  • 设置有关时序寄存器SDC1、SDPER、SDCN、SDC2和SDC3(VC5509无SDC3)。

注意到手册Configuration Procedure最后一句话。Write to the SDRAM initialization register. After new values are written to EMIF configuration registers, 6 CPU clock cycles are required for the new configuration to propagate through the EMIF logic. After this delay, the EMIF begins the SDRAM initialization sequence.


另外配置时细看 EMIF文档的 3.2.2 Configuration Procedure

  1. #include "csl.h"
  2. #include "csl_pll.h"
  3. #include "csl_emif.h"
  4. #include "csl_chip.h"

  5. /*锁相环的设置*/
  6. PLL_Config  myConfig      = {
  7.   0,    //IAI: the PLL locks using the same process that was underway
  8.                 //before the idle mode was entered
  9.   1,    //IOB: If the PLL indicates a break in the phase lock,
  10.                 //it switches to its bypass mode and restarts the PLL phase-locking
  11.                 //sequence
  12.   24,    //PLL multiply value; multiply 24 times
  13.   1             //Divide by 2 PLL divide value; it can be either PLL divide value
  14.                 //(when PLL is enabled), or Bypass-mode divide value
  15.                 //(PLL in bypass mode, if PLL multiply value is set to 1)
  16. };
  17. /*SDRAM的EMIF设置*/
  18. void sdram_init(void)
  19. {
  20.     ioport unsigned int *ebsr  = (unsigned int *)0x6c00;
  21.     ioport unsigned int *egcr  = (unsigned int *)0x0800;
  22.     ioport unsigned int *emirst = (unsigned int *)0x0801;
  23.     // ioport unsigned int *emibe = (unsigned int *)0x0802;
  24.     ioport unsigned int *ce01  = (unsigned int *)0x0803;
  25.     ioport unsigned int *ce02  = (unsigned int *)0x0804;
  26.     ioport unsigned int *ce03  = (unsigned int *)0x0805;
  27.     ioport unsigned int *ce11  = (unsigned int *)0x0806;
  28.     ioport unsigned int *ce12  = (unsigned int *)0x0807;
  29.     ioport unsigned int *ce13  = (unsigned int *)0x0808;
  30.     ioport unsigned int *ce21  = (unsigned int *)0x0809;
  31.     ioport unsigned int *ce22  = (unsigned int *)0x080A;
  32.     ioport unsigned int *ce23  = (unsigned int *)0x080B;
  33.     ioport unsigned int *ce31  = (unsigned int *)0x080C;
  34.     ioport unsigned int *ce32  = (unsigned int *)0x080D;
  35.     ioport unsigned int *ce33  = (unsigned int *)0x080E;
  36.     ioport unsigned int *sdc1  = (unsigned int *)0x080F;
  37.     ioport unsigned int *sdper = (unsigned int *)0x0810;
  38.     // ioport unsigned int *sdcnt = (unsigned int *)0x0811;
  39.     ioport unsigned int *init  = (unsigned int *)0x0812;
  40.     ioport unsigned int *sdc2  = (unsigned int *)0x0813;
  41.         ioport unsigned int *sdc3  = (unsigned int *)0x0814;  // 此寄存器只用于5510,5509中无

  42.     *ebsr   = 0x0201;    // full emif 23d
  43.     *egcr   = 0x0210;         //  230  210
  44.                          // EGCR  : the MEMFREQ = 001
  45.                                  //         the MEMCEN = 0, 最后置‘1’
  46.                                  //         ARDYOFF = 1, 不使用异步

  47.     *ce01   = 0x3FFF;        // CE0_1:  CE0 space control register 1
  48.                                 //         MTYPE = 011, Synchronous DRAM (SDRAM), 16-bit data bus width
  49.     *ce02   = 0xFFFF;   // CE0_2:  CE0 space control register 2
  50.     *ce03   = 0x00FF;   // CE0_3:  CE0 space control register 3

  51.     *ce11   = 0x3FFF;        // CE1_1:  CE1 space control register 1
  52.                                 //         MTYPE = 011, Synchronous DRAM (SDRAM), 16-bit data bus width
  53.     *ce12   = 0xFFFF;   // CE1_2:  CE1 space control register 2
  54.     *ce13   = 0x00FF;   // CE1_3:  CE1 space control register 3

  55.     *ce21   = 0x7FFF;        // CE0_1:  CE2 space control register 1
  56.     *ce22   = 0xFFFF;   // CE0_2:  CE2 space control register 2
  57.     *ce23   = 0x00FF;   // CE0_3:  CE2 space control register 3

  58.     *ce31   = 0x7FFF;        // CE3_1:  CE3 space control register 1
  59.     *ce32   = 0xFFFF;   // CE3_2:  CE3 space control register 2
  60.     *ce33   = 0x00FF;   // CE3_3:  CE3 space control register 3

  61.     *emirst = 0xFFFF;    // EMIRST: any write to this register resets the EMIF state machine
  62.     *sdc1   = 0x2911;
  63.     *sdc2   = 0x0131;
  64.     *sdc3   = 0x0003;   //
  65.     *sdper  = 0x0410;

  66.     *egcr   = *egcr | 0x0020;     // the MEMCEN = 1
  67.     *init   = 0xFFFF;
  68. }

  69. void main(void)
  70. {
  71.         volatile int *SourceAddr = (int *)0x40000;
  72.         int i = 0;

  73.         /*初始化CSL库*/
  74.     CSL_init();

  75.     /*初始化DSP的外部SDRAM*/
  76.     sdram_init();

  77.     /*设置系统的运行速度为144MHz*/
  78.     PLL_config(&myConfig);

  79.     /*向SDRAM中写入数据*/
  80.     for (i = 0; i < 1000; i++)
  81.     {
  82.              *SourceAddr++ = i;
  83.     }

  84.     while(1);
  85. }

关键词ioport在CCS4以后的版本会出现 '?'提示,但编译后执行不受影响。

编写这个程序你可定有这个疑问,为什么我用5509的程序运行不了。查看官方FAQ!!!
Why can I not correctly move data that spans a 64K-word boundary?




 楼主| wopt 发表于 2015-3-7 20:39 | 显示全部楼层
本帖最后由 wopt 于 2015-3-7 22:10 编辑

2.7 EXINT
VC5509A 含有5个外部中断INT[4:0]。相关配置查看IFR and IER Registers.

触发外部中断1,控制LED反转。
  1. #include "csl.h"
  2. #include "csl_pll.h"
  3. #include "csl_chip.h"
  4. #include "csl_gpio.h"

  5. Uint16 eventId0;
  6. int old_intm;

  7. interrupt void int1(void);

  8. //---------Function prototypes---------

  9. /* Reference start of interrupt vector table   */

  10. /* This symbol is defined in file, vectors.s55 */

  11. extern void VECSTART(void);


  12. /*锁相环的设置*/
  13. PLL_Config  myConfig      = {
  14.   0,    //IAI: the PLL locks using the same process that was underway
  15.                 //before the idle mode was entered
  16.   1,    //IOB: If the PLL indicates a break in the phase lock,
  17.                 //it switches to its bypass mode and restarts the PLL phase-locking
  18.                 //sequence
  19.   12,    //PLL multiply value; multiply 12 times
  20.   1             //Divide by 2 PLL divide value; it can be either PLL divide value
  21.                 //(when PLL is enabled), or Bypass-mode divide value
  22.                 //(PLL in bypass mode, if PLL multiply value is set to 1)
  23. };

  24. void INTconfig()
  25. {
  26.     /* Temporarily disable all maskable interrupts */

  27.     IRQ_setVecs((Uint32)(&VECSTART));

  28.         /* Temporarily disable all maskable interrupts */

  29.     old_intm = IRQ_globalDisable();

  30.         /* Get Event Id associated with External INT1(8019), for use with */
  31.         eventId0 = IRQ_EVT_INT0;

  32.         /* Clear any pending INT1 interrupts */

  33.         IRQ_clear(eventId0);

  34.         /* Place interrupt service routine address at */

  35.     /* associated vector location */

  36.     IRQ_plug(eventId0,&int1);

  37.         /* Enable INT1(8019) interrupt */

  38.     IRQ_enable(eventId0);

  39.         /* Enable all maskable interrupts */

  40.     IRQ_globalEnable();

  41. }

  42. void main(void)
  43. {
  44.         /*初始化CSL库*/
  45.     CSL_init();

  46.     /*设置系统的运行速度为144MHz*/
  47.     PLL_config(&myConfig);

  48.         //设置并使能5509A芯片的INT0中断(EXINT中断)
  49.         INTconfig();

  50.     /* IO方向为输出 */
  51.     GPIO_pinDirection(GPIO_PIN0, GPIO_OUTPUT);

  52.         while(1);
  53. }

  54. //External INT0(EXINT)中断处理函数
  55. interrupt void int1()
  56. {
  57.         GPIO_pinWrite( GPIO_PIN0, 0x01 ^ GPIO_pinRead(GPIO_PIN0) );
  58. }




zhangmangui 发表于 2015-3-8 22:08 | 显示全部楼层
持续支持
 楼主| wopt 发表于 2015-3-9 21:36 | 显示全部楼层

谢谢,希望这个月底写完。
晓白不 发表于 2015-3-10 09:36 | 显示全部楼层
zhangmangui 发表于 2015-3-10 21:24 | 显示全部楼层
希望能在TI DSP版块同时分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

19

主题

131

帖子

12

粉丝
快速回复 在线客服 返回列表 返回顶部