对DSP进行开发时,需要对其底层的硬件及外设进行相应的配置,当配置完成后才可以将其相应模块激活,才可以在其内部进行程序编写及调试处理。下面对程序配置及操作进行简单的整理,仅供参考。
第一步:初始化系统控制,PLL,看门狗,使能外设时钟等,一般调用函数InitSysCtrl();
第二步:初始化GPIO,对于不同的硬件系统,进行不同的功能配置;
第三步:清除所有的中断并初始化PIE中断向量表
禁用CPU中断
DINT;
初始化PIE控制寄存器为默认状态
InitPieVectTable();
禁用CPU中断并清除所有的CPU中断标志
IER=0x0000;
IFR=0x0000;
初始化PIE中断向量表
InitPieVectTable();
EALLOW;
XXX-------此处填写程序中需要的中断,将其映射到中断向量表中(如
Pie VectTable.SCIRXINTA=&sciaRxFifoIsr;)
EDIS;
第四步:初始化所有外设(如果没有外设结构,此部分可省略);
第五步:用户程序段,使能中断。以上为初步设计DSP程序的基本框架,具体要实现的功能还需在其中添加!
led 闪烁实验
参考
参考 2
CCS You are required to terminate existing debug…
debug后,直接点 terminate 小方框不行,ccs没停止上一次的 debug。
解决方法DSP程序调试时CCS如何安全退出调试状态
Example02_DSP2833x_LED/targetConfigs line 0
targetconfigs 直接复制过去一直都是感叹号,解决:重新创建一个把原来的删了
//###########################################################################
//
// FILE: Example_2833xGpioToggle.c
//
// TITLE: DSP2833x Device GPIO toggle test program.
//
// ASSUMPTIONS:
//
// This program requires the DSP2833x header files.
//
// ALL OF THE I/O'S TOGGLE IN THIS PROGRAM. MAKE SURE
// THIS WILL NOT DAMAGE YOUR HARDWARE BEFORE RUNNING THIS
// EXAMPLE.
//
// Monitor desired pins on an oscilloscope.
//
// As supplied, this project is configured for "boot to SARAM"
// operation. The 2833x Boot Mode table is shown below.
// For information on configuring the boot mode of an eZdsp,
// please refer to the documentation included with the eZdsp,
//
// $Boot_Table:
//
// GPIO87 GPIO86 GPIO85 GPIO84
// XA15 XA14 XA13 XA12
// PU PU PU PU
// ==========================================
// 1 1 1 1 Jump to Flash
// 1 1 1 0 SCI-A boot
// 1 1 0 1 SPI-A boot
// 1 1 0 0 I2C-A boot
// 1 0 1 1 eCAN-A boot
// 1 0 1 0 McBSP-A boot
// 1 0 0 1 Jump to XINTF x16
// 1 0 0 0 Jump to XINTF x32
// 0 1 1 1 Jump to OTP
// 0 1 1 0 Parallel GPIO I/O boot
// 0 1 0 1 Parallel XINTF boot
// 0 1 0 0 Jump to SARAM <- "boot to SARAM"
// 0 0 1 1 Branch to check boot mode
// 0 0 1 0 Boot to flash, bypass ADC cal
// 0 0 0 1 Boot to SARAM, bypass ADC cal
// 0 0 0 0 Boot to SCI-A, bypass ADC cal
// Boot_Table_End$
//
// DESCRIPTION:
//
// Three different examples are included. Select the example
// (data, set/clear or toggle) to execute before compiling using
// the #define statements found at the top of the code.
//
//
// Toggle all of the GPIO PORT pins
//
// The pins can be observed using Oscilloscope.
// #include "DSP28x_Project.h" // Device Headerfile and Examples Include File/**************************************宏定义************************************************/
#define LED1_OFF GpioDataRegs.GPBSET.bit.GPIO60 = 1 //LED D10 点亮
#define LED1_ON GpioDataRegs.GPBCLEAR.bit.GPIO60 = 1 //LED D10 熄灭
#define LED2_OFF GpioDataRegs.GPBSET.bit.GPIO61 = 1 //LED D11 点亮
#define LED2_ON GpioDataRegs.GPBCLEAR.bit.GPIO61 = 1 //LED D11 熄灭
#define LED3_OFF GpioDataRegs.GPASET.bit.GPIO2 = 1 //LED D12 点亮
#define LED3_ON GpioDataRegs.GPACLEAR.bit.GPIO2 = 1 //LED D12 熄灭
#define LED4_OFF GpioDataRegs.GPASET.bit.GPIO3 = 1 //LED D13 点亮
#define LED4_ON GpioDataRegs.GPACLEAR.bit.GPIO3 = 1 //LED D13 熄灭
#define LED5_OFF GpioDataRegs.GPASET.bit.GPIO4 = 1 //LED D14 点亮
#define LED5_ON GpioDataRegs.GPACLEAR.bit.GPIO4 = 1 //LED D14 熄灭
#define LED6_OFF GpioDataRegs.GPASET.bit.GPIO5 = 1 //LED D15 点亮
#define LED6_ON GpioDataRegs.GPACLEAR.bit.GPIO5 = 1 //LED D15 熄灭
#define LED7_OFF GpioDataRegs.GPASET.bit.GPIO6 = 1 //LED D16 点亮
#define LED7_ON GpioDataRegs.GPACLEAR.bit.GPIO6 = 1 //LED D16 熄灭
#define LED8_OFF GpioDataRegs.GPASET.bit.GPIO7 = 1 //LED D17 点亮
#define LED8_ON GpioDataRegs.GPACLEAR.bit.GPIO7 = 1 //LED D17 熄灭#define DELAY_TIME 2000000 //延时时间
/*****************************************************************************************************//*********************************************函数声明************************************************/
void Init_LedGpio(void);
void delay(Uint32 t);
/*****************************************************************************************************/
void Init_LedGpio(void)
{EALLOW; //关闭写保护//LED D10 GpioCtrlRegs.GPBPUD.bit.GPIO60 = 0; // Enable pullup on GPIO11 使能 GPIO 上拉电阻GpioDataRegs.GPBSET.bit.GPIO60 = 1; // Load output latch 设置 GPIO 输出高电平GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 0; // GPIO11 = GPIO 设置为通用 GPIO 功能GpioCtrlRegs.GPBDIR.bit.GPIO60 = 1; // GPIO11 = output 设置 GPIO 方向为输出 //LED D11GpioCtrlRegs.GPBPUD.bit.GPIO61 = 0; // Enable pullup on GPIO11GpioDataRegs.GPBSET.bit.GPIO61 = 1; // Load output latchGpioCtrlRegs.GPBMUX2.bit.GPIO61 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPBDIR.bit.GPIO61 = 1; // GPIO11 = output //LED D12GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO2 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // GPIO11 = output //LED D13 GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO3 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO3 = 1; // GPIO11 = output //LED D14 GpioCtrlRegs.GPAPUD.bit.GPIO4 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO4 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO4 = 1; // GPIO11 = output //LED D15 GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO5 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO5 = 1; // GPIO11 = output //LED D16 GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO6 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO11 = output //LED D17 GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; // Enable pullup on GPIO11GpioDataRegs.GPASET.bit.GPIO7 = 1; // Load output latchGpioCtrlRegs.GPAMUX1.bit.GPIO7 = 0; // GPIO11 = GPIOGpioCtrlRegs.GPADIR.bit.GPIO7 = 1; // GPIO11 = output EDIS; // 开启写保护}
/*********************************************延时函数************************************************/
void delay(Uint32 t)
{Uint32 i = 0;for (i = 0; i < t; i++);
}void main(void)
{// Step 1. Initialize System Control: 系统时钟初始化
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.InitSysCtrl();// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.Init_LedGpio(); //初始化LED的GPIO
// For this example use the following configuration:
// Gpio_select();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts DINT;// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.InitPieCtrl();// Disable CPU interrupts and clear all CPU interrupt flags:IER = 0x0000;IFR = 0x0000;// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.InitPieVectTable();//--------------------------]]]]]]]]]]]]]]]]]]]--------------------------------------------------------
// 烧写FLASH更换cmd文件,添加下面2行代码,并添加DSP2833x_MeMCopy.c(DSP280x_CSMPasswords.asm)文件,重新编译
//------------------------------------------------------------------
// MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// InitFlash();
//-------------------------------------------------------------------
//]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals(); // Not required for this example// Step 5. User specific code:while(1) //死循环{LED1_ON; //LED1 D10 点亮delay(DELAY_TIME); //延时LED1_OFF; //LED1 D10 熄灭LED2_ON; //LED2 D11 点亮delay(DELAY_TIME); //延时LED2_OFF; //LED2 D11 熄灭LED3_ON; //LED3 D12 点亮delay(DELAY_TIME); //延时LED3_OFF; //LED3 D12 熄灭LED4_ON; //LED4 D13 点亮delay(DELAY_TIME); //延时LED4_OFF; //LED4 D13 熄灭LED5_ON; //LED5 D14 点亮delay(DELAY_TIME); //延时LED5_OFF; //LED5 D14 熄灭LED6_ON; //LED6 D15 点亮delay(DELAY_TIME); //延时LED6_OFF; //LED6 D15 熄灭LED7_ON; //LED7 D16 点亮delay(DELAY_TIME); //延时LED7_OFF; //LED7 D16 熄灭LED8_ON; //LED8 D17 点亮delay(DELAY_TIME); //延时LED8_OFF; //LED8 D17 熄灭}
} /*****************************************************************************************************/