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

我的5509A之路

[复制链接]
21472|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文件的原理
参考:
MEMORY 
{
        MMR     : origin = 0000000h, length = 00000c0h
        SPRAM   : origin = 00000c0h, length = 0000040h
        VECS0   : origin = 0000100h, length = 0000100h
        VECS1   : origin = 0000200h, length = 0000100h
        DARAM0  : origin = 0000300h, length = 0003D00h
        DARAM1  : origin = 0004000h, length = 0004000h
        DARAM2  : origin = 0008000h, length = 0004000h
        DARAM3  : origin = 000c000h, length = 0004000h

        SARAM0  : origin = 0010000h, length = 0004000h
        SARAM1  : origin = 0014000h, length = 0008000h
       /* SARAM2  : origin = 0018000h, length = 0004000h */
        SARAM3  : origin = 001c000h, length = 0004000h
        SARAM4  : origin = 0020000h, length = 0004000h
        SARAM5  : origin = 0024000h, length = 0004000h
        SARAM6  : origin = 0028000h, length = 0004000h
        SARAM7  : origin = 002c000h, length = 0004000h
        SARAM8  : origin = 0030000h, length = 0004000h
        SARAM9  : origin = 0034000h, length = 0004000h
        SARAM10 : origin = 0038000h, length = 0004000h
        SARAM11 : origin = 003c000h, length = 0004000h
        SARAM12 : origin = 0040000h, length = 0004000h
        SARAM13 : origin = 0044000h, length = 0004000h
        SARAM14 : origin = 0048000h, length = 0004000h
        SARAM15 : origin = 004c000h, length = 0004000h

        CE0     : origin = 0050000h, length = 03b0000h
        CE1     : origin = 0400000h, length = 0400000h
        CE2     : origin = 0800000h, length = 0400000h
        CE3     : origin = 0c00000h, length = 03f8000h

        PDROM   : origin = 0ff8000h, length = 07f00h
}

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

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

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反映或设置。
#include "csl.h"
#include "csl_gpio.h"

void delay();

void main(void)
{
     /* 初始化CSL库 */
    CSL_init();
    /* 确定方向为输出 */
    GPIO_pinDirection(GPIO_PIN1, GPIO_OUTPUT);
        /* 循环闪烁 */
           while (1)
           {
                   GPIO_pinWrite(GPIO_PIN1, 1);
                   delay();
                   GPIO_pinWrite(GPIO_PIN1, 0);
                   delay();
           }
}
void delay()
{
        Uint32 j = 0, k = 0;
        for(j = 0; j < 0x0D; j++)
        {
                for(k= 0; k<0xffff; k++)
                {}
        }
}


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

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

void main(void)
{
        /* 初始化CSL库 */
    CSL_init();
    /* 设置系统的运行速度为144MHz */
    PLL_config(&myConfig);
    /* 确定方向为输出 */
    GPIO_pinDirection(GPIO_PIN1, GPIO_OUTPUT);
        /* 循环闪烁 */
           while (1)
           {
                   GPIO_pinWrite(GPIO_PIN1, 1);
                   delay();
                   GPIO_pinWrite(GPIO_PIN1, 0);
                   delay();
           }
}
void delay()
{
        Uint32 j = 0, k = 0;
        for(j = 0; j < 0x0D; j++)
        {
                for(k= 0; k<0xffff; k++)
                {}
        }
}
对比两个程序,后者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
#include "csl.h"
#include "csl_irq.h"
#include "csl_timer.h"
#include "csl_chip.h"
#include "csl_gpio.h"

//---------Global data definition---------
#define TIMER_CTRL    TIMER_TCR_RMK(\
                      TIMER_TCR_IDLEEN_DEFAULT,    /* IDLEEN == 0 */ \
                      TIMER_TCR_FUNC_OF(0),        /* FUNC   == 0 */ \
                      TIMER_TCR_TLB_RESET,         /* TLB    == 1 */ \
                      TIMER_TCR_SOFT_BRKPTNOW,     /* SOFT   == 0 */ \
                      TIMER_TCR_FREE_WITHSOFT,     /* FREE   == 0 */ \
                      TIMER_TCR_PWID_OF(0),        /* PWID   == 0 */ \
                      TIMER_TCR_ARB_RESET,         /* ARB    == 1 */ \
                      TIMER_TCR_TSS_START,         /* TSS    == 0 */ \
                      TIMER_TCR_CP_PULSE,          /* CP     == 0 */ \
                      TIMER_TCR_POLAR_LOW,         /* POLAR  == 0 */ \
                      TIMER_TCR_DATOUT_0           /* DATOUT == 0 */ \
)

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

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

/* Function/ISR prototypes */
interrupt void timer0Isr(void);
void taskFxn(void);


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

Uint16 eventId0;
volatile Uint16 timer0_cnt = 0;
int old_intm;
Uint16 tim_val;

//---------main routine---------
void main(void)
{
        /* Initialize CSL library */
        CSL_init();

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

        /* Call function to set timer */
        taskFxn();
    GPIO_pinDirection(GPIO_PIN4, GPIO_OUTPUT);
        while(1)
        {

        }
}

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

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

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

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

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

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

    /* Enable Timer interrupt */
    IRQ_enable(eventId0);

    /* Enable all maskable interrupts */
    IRQ_globalEnable();

    /* Start Timer */
    TIMER_start(mhTimer0);
}

interrupt void timer0Isr(void)
{
    ++timer0_cnt;
        if (timer0_cnt == 1)
        {
                GPIO_pinWrite(GPIO_PIN4, 1);
        }
    if (timer0_cnt == 200)
    {
                GPIO_pinWrite(GPIO_PIN4, 0);
    }
    if (timer0_cnt == 400)
    {
            timer0_cnt = 0;
    }
}




使用特权

评论回复
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
#include <csl.h>
#include <csl_wdtim.h>

//---------Global data definition---------
volatile int pscVal, wdtimVal;
WDTIM_Config getConfig;
WDTIM_Config myConfig = {
     0x1000,          /* WDPRD */

     0x0000,          /* WDTCR */
                      // WDOUT    SOFT    FREE    PSC   TDDR
                      //  0b       0b      0b      0b    0b

     0x1000           /* WDTCR2 */
                      // WDFLAG    WDEN   PREMD   WDKEY
                      //   1b       0b     0b      0

};

//---------main routine---------
void main(void)
{
    pscVal = 0;
    wdtimVal = 0;
    CSL_init();

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

5509_2_3_0.png

使用特权

评论回复
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小时制。
#include <csl.h>
#include <csl_rtc.h>
#include <csl_irq.h>

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

/* Function/ISR prototypes */
void RTC_UpdateIsr(void);

RTC_Config getConfig;
RTC_Config myConfig = {
     0x59,    /* rtcsec   */
     0x00,    /* rteseca  */
     0x21,    /* rtcmin   */
     0x00,    /* rtcmina  */
     0x10,    /* rtchour  */
     0x00,    /* rtchoura */
     0x04,    /* rtcdayw  */
     0x05,    /* rtcdaym  */
     0x03,    /* rtcmonth */
     0x15,    /* rtcyear  */
     0x00,    /* rtcpintr */
     0x82,    /* rtcinten */
     0x00     /* rtcintfl */
};

RTC_Date getDate = {
                0,
                0,
                0
};
RTC_Time getTime = {
                0,
                0,
                0
};

RTC_IsrAddr addr = {
        NULL,
        NULL,
        RTC_UpdateIsr
};

volatile Uint16 sec = 0;
volatile Uint16 set_b = 0;
int old_intm;
int eventId;

void main(void)
{
    CSL_init();

    RTC_reset();
    RTC_config(&myConfig);  // Initialization

    set_b = RTC_FGET(RTCINTEN, SET);

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

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

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

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

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

    /* Enable RTC maskable interrupts */
    IRQ_enable(eventId);

    /* Enable all maskable interrupts */
    IRQ_globalEnable();

    sec = RTC_RGET(RTCSEC);

    /* Start RTC */
    RTC_start();

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

    while (sec != 0)
    {
        sec = RTC_RGET(RTCSEC);
    }

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

        while (1)
        {

        }
}

void RTC_UpdateIsr(void)
{
        /* Read the current time from the RTC register */
    RTC_getTime(&getTime);
    RTC_getDate(&getDate);
}
5509_2.png


使用特权

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

#include <csl.h>
#include <csl_pll.h>
#include <csl_adc.h>

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

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

void main(void)
{
        volatile Uint16 average = 0;
        Uint16 samplestorage[8] = {0};
        Uint8 i = 0;
        Uint16 sum = 0;

    CSL_init();

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

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

        while(1)
        {
                /* samplestorage array. */
                ADC_read(0, samplestorage, 8);

                for (i = 0; i < 8; i++)
                {
                        sum += samplestorage[0];
                }
                average = sum / 8;
                average = 0;
                sum = 0;
        }
}
CCS Debug-->Tools-->Graph-->Single Time
5509_2.png

设置断点,运行,查看变量average变化。
5509_1.png

使用特权

评论回复
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

#include "csl.h"
#include "csl_pll.h"
#include "csl_emif.h"
#include "csl_chip.h"

/*锁相环的设置*/
PLL_Config  myConfig      = {
  0,    //IAI: the PLL locks using the same process that was underway
                //before the idle mode was entered
  1,    //IOB: If the PLL indicates a break in the phase lock,
                //it switches to its bypass mode and restarts the PLL phase-locking
                //sequence
  24,    //PLL multiply value; multiply 24 times
  1             //Divide by 2 PLL divide value; it can be either PLL divide value
                //(when PLL is enabled), or Bypass-mode divide value
                //(PLL in bypass mode, if PLL multiply value is set to 1)
};
/*SDRAM的EMIF设置*/
void sdram_init(void)
{
    ioport unsigned int *ebsr  = (unsigned int *)0x6c00;
    ioport unsigned int *egcr  = (unsigned int *)0x0800;
    ioport unsigned int *emirst = (unsigned int *)0x0801;
    // ioport unsigned int *emibe = (unsigned int *)0x0802;
    ioport unsigned int *ce01  = (unsigned int *)0x0803;
    ioport unsigned int *ce02  = (unsigned int *)0x0804;
    ioport unsigned int *ce03  = (unsigned int *)0x0805;
    ioport unsigned int *ce11  = (unsigned int *)0x0806;
    ioport unsigned int *ce12  = (unsigned int *)0x0807;
    ioport unsigned int *ce13  = (unsigned int *)0x0808;
    ioport unsigned int *ce21  = (unsigned int *)0x0809;
    ioport unsigned int *ce22  = (unsigned int *)0x080A;
    ioport unsigned int *ce23  = (unsigned int *)0x080B;
    ioport unsigned int *ce31  = (unsigned int *)0x080C;
    ioport unsigned int *ce32  = (unsigned int *)0x080D;
    ioport unsigned int *ce33  = (unsigned int *)0x080E;
    ioport unsigned int *sdc1  = (unsigned int *)0x080F;
    ioport unsigned int *sdper = (unsigned int *)0x0810;
    // ioport unsigned int *sdcnt = (unsigned int *)0x0811;
    ioport unsigned int *init  = (unsigned int *)0x0812;
    ioport unsigned int *sdc2  = (unsigned int *)0x0813;
        ioport unsigned int *sdc3  = (unsigned int *)0x0814;  // 此寄存器只用于5510,5509中无

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

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

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

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

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

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

    *egcr   = *egcr | 0x0020;     // the MEMCEN = 1
    *init   = 0xFFFF;
}

void main(void)
{
        volatile int *SourceAddr = (int *)0x40000;
        int i = 0;

        /*初始化CSL库*/
    CSL_init();

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

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

    /*向SDRAM中写入数据*/
    for (i = 0; i < 1000; i++)
    {
             *SourceAddr++ = i;
    }

    while(1);
}

关键词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反转。
#include "csl.h"
#include "csl_pll.h"
#include "csl_chip.h"
#include "csl_gpio.h"

Uint16 eventId0;
int old_intm;

interrupt void int1(void);

//---------Function prototypes---------

/* Reference start of interrupt vector table   */

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

extern void VECSTART(void);


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

void INTconfig()
{
    /* Temporarily disable all maskable interrupts */

    IRQ_setVecs((Uint32)(&VECSTART));

        /* Temporarily disable all maskable interrupts */

    old_intm = IRQ_globalDisable();

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

        /* Clear any pending INT1 interrupts */

        IRQ_clear(eventId0);

        /* Place interrupt service routine address at */

    /* associated vector location */

    IRQ_plug(eventId0,&int1);

        /* Enable INT1(8019) interrupt */

    IRQ_enable(eventId0);

        /* Enable all maskable interrupts */

    IRQ_globalEnable();

}

void main(void)
{
        /*初始化CSL库*/
    CSL_init();

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

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

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

        while(1);
}

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




使用特权

评论回复
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版块同时分享

使用特权

评论回复
发新帖 本帖赏金 5.00元(功能说明)我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

19

主题

131

帖子

12

粉丝