臨城夏目 2023-09-09 19:56 采纳率: 0%
浏览 4

DSPF2808程序烧写问题

我是用的是TMS320F2808开发板,软件是CCS3.3,用的研旭的LED闪烁例程,直接下载到RAM里仿真是没问题的,然后按照教程替换cmd文件,烧写到Flash里,led就不闪烁了,只亮第一盏,不知道到底是什么问题,代码如下:

#include "DSP280x_Device.h"     // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File

// Select the example to compile in.  Only one example should be set as 1
// the rest should be set as 0.
#define led1  GpioDataRegs.GPADAT.bit.GPIO0 
#define led2  GpioDataRegs.GPADAT.bit.GPIO1
#define led3  GpioDataRegs.GPADAT.bit.GPIO2
#define led4  GpioDataRegs.GPADAT.bit.GPIO3
#define led5  GpioDataRegs.GPADAT.bit.GPIO4
#define led6  GpioDataRegs.GPADAT.bit.GPIO5
#define led7  GpioDataRegs.GPADAT.bit.GPIO6
#define led8  GpioDataRegs.GPADAT.bit.GPIO7

void Gpio_init(void);

void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
   InitSysCtrl();
   
// Step 2. Initalize GPIO: 
// This example function is found in the DSP280x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
   // InitGpio(); Skipped for this example  
 
// 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 DSP280x_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 DSP280x_DefaultIsr.c.
// This function is found in DSP280x_PieVect.c.
   InitPieVectTable();
   Gpio_init();
    
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP280x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
    
// Step 5. User specific code:
    led1=1;
   DELAY_US(500);
    led2=1;
   DELAY_US(500);
    led3=1;
   DELAY_US(500);
    led4=1;
   DELAY_US(500);
    led5=1;
   DELAY_US(500);
    led6=1;
   DELAY_US(500);
    led7=1;
   DELAY_US(500);
    led8=1;
   DELAY_US(500);
   while(1)
   {
    led1=~led1;
    led2=~led2;
    led3=~led3;
    led4=~led4;
    led5=~led5;
    led6=~led6;
    led7=~led7;
    led8=~led8;
    DELAY_US(80000);
   }

}     


void Gpio_init(void)
{ 

   EALLOW;
   GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0;   // Enable pullup on GPIO0
   GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0;   // Enable pullup on GPIO1
   GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0;   // Enable pullup on GPIO2
   GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0;   // Enable pullup on GPIO3
   GpioCtrlRegs.GPAPUD.bit.GPIO4 = 0;   // Enable pullup on GPIO4
   GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0;   // Enable pullup on GPIO5
   GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0;   // Enable pullup on GPIO6
   GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0;   // Enable pullup on GPIO7

   GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;  // GPIO0 
   GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;  // GPIO1 
   GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;  // GPIO2 
   GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;  // GPIO3 
   GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0;  // GPIO4 
   GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0;  // GPIO5 
   GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0;  // GPIO6 
   GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 0;  // GPIO7
    
   GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;  //output gpio0   
   GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;  //output gpio1  
   GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;  //output gpio2  
   GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;  //output gpio3  
   GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;  //output gpio4  
   GpioCtrlRegs.GPADIR.bit.GPIO5 = 1;  //output gpio5  
   GpioCtrlRegs.GPADIR.bit.GPIO6 = 1;  //output gpio6   
   GpioCtrlRegs.GPADIR.bit.GPIO7 = 1;  //output gpio7  
                
   EDIS;
}

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-09-09 23:03
    关注

    【以下回答由 GPT 生成】

    问题可能出在GPIO初始化的部分。根据提供的代码,只看到在引脚为0-7的状态下才设置这些引脚为输出模式,而实际上TMS320F2808开发板上的LED引脚可能不是这些。因此,需要确认正确的引脚设置,并相应地修改代码中的引脚定义。

    你可以尝试使用以下代码进行GPIO初始化,确保引脚映射到了正确的LED引脚:

    void Gpio_init(void)
    {
        // Step 2.5.1: Enable GPIO0-7
        EALLOW;
        GpioCtrlRegs.GPAMUX1.all = 0x00000000;
        GpioCtrlRegs.GPADIR.all = 0x000000FF;
        GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // Set GPIO0 as output
        GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; // Set GPIO1 as output
        GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // Set GPIO2 as output
        GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; // Set GPIO3 as output
        GpioCtrlRegs.GPADIR.bit.GPIO4 = 1; // Set GPIO4 as output
        GpioCtrlRegs.GPADIR.bit.GPIO5 = 1; // Set GPIO5 as output
        GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // Set GPIO6 as output
        GpioCtrlRegs.GPADIR.bit.GPIO7 = 1; // Set GPIO7 as output
        EDIS;
    }
    

    将这段代码添加到你的main()函数之前,并替换掉原来的Gpio_init()函数。

    这应该可以解决你遇到的问题。如果问题仍然存在,请提供更多与LED闪烁相关的代码以供进一步分析。


    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 创建了问题 9月9日

悬赏问题

  • ¥20 服务器redhat5.8网络问题
  • ¥15 如何利用c++ MFC绘制复杂网络多层图
  • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
  • ¥15 python螺旋图像
  • ¥15 算能的sail库的运用
  • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码
  • ¥15 AutoDL无法使用docker install吗?