程序从Flash里一直到RAM,Led灯按要求亮灭,IO口输出乱码

2019-07-24 17:55发布

   我想测试一下程序有没有移植到RAM中,有两个指示,一是LED灯亮灭,二是IO口输出与灯亮灭一致 的高低电平。到那时结果显示灯正常,但是输出口输出的波形不对,如下:

  我还发现所有的引脚全部是这样的波形,并且关闭DSP开发板的而电源搜有引脚波形跟上图一样。这是怎么回事啊?程序移植困然好几天了,本人太笨了,感觉智商已经到极限了,求求懂得大神们教教我吧!程序如下:
图片1.png #include "DSP281x_Device.h"     // Headerfile Include File
#include "DSP281x_Examples.h"   // Examples Include File
#include "DSP281x_Globalprototypes.h"
// Specify LED Toggle Rate
#define EVA_TIMER_PRD 63025          // EVA Timer Period (LED Toggle .75 sec)
//#define EVA_TIMER_PRD 42016          // EVA Timer Period (LED Toggle .5 sec)
//#define EVA_TIMER_PRD 21008           // EVA Timer Period (LED Toggle .25 sec)
unsigned int * LED0 = (unsigned int *) 0x4100;       
//unsigned int * LED  = (unsigned int *) 0x410;
unsigned  int  *Ext_IO_L  = (unsigned int *)0x4e00;        //输出IO口的低16位地址   
unsigned  int  *Ext_IO_H  = (unsigned int *)0x4f00;
int flag1 = 0;
#define          SetPWM3        GpioDataRegs.GPADAT.bit.GPIOA2 = 1
#define          ClrPWM3   GpioDataRegs.GPADAT.bit.GPIOA2 = 0
// Prototype statements for functions found within this file.
interrupt void eva_timer1_isr(void);
void init_eva_timer1(void);
void main(void)
{
   InitSysCtrl();
   DINT;
   InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;
   InitPieVectTable();
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.T1PINT = &eva_timer1_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers
   init_eva_timer1();   
   EALLOW;
   GpioMuxRegs.GPFDIR.bit.GPIOF14 = 1;
     GpioMuxRegs.GPAMUX.all = 0x0000; ///A口当IO口用,实际上只用到PA2~PA5 四根口线
           GpioMuxRegs.GPADIR.all = 0x00ff; ///A口低8位全当输出
   EDIS;
   // Enable CPU INT2 which is connected to EVA TIMER 1 INT:
   IER |= M_INT2;
   // Enable EVAPINt in the PIE: Group 2 interrupt 4
   PieCtrlRegs.PIEIER2.bit.INTx4 = 1;
   // Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM
// Step 6. IDLE loop. Just sit and loop forever (optional):     
   for(;;){};
}
void init_eva_timer1()
{
    EvaRegs.T1PR = EVA_TIMER_PRD;       // Period
    EvaRegs.EVAIMRA.bit.T1PINT = 1;
    EvaRegs.EVAIFRA.bit.T1PINT = 1;

    // Clear the counter for GP timer 1
    EvaRegs.T1CNT = 0x0000;
        // Count up, x128, internal clk, enable compare, use own period
    EvaRegs.T1CON.all = 0x1740;
}
interrupt void eva_timer1_isr(void)
{
   // Toggle LED
   GpioDataRegs.G PFTOGGLE.bit.GPIOF14 = 1;
   flag1++;
   if( flag1 == 1 )
   {
            *LED0 = 0x00;
        *Ext_IO_L=0x0000;
     SetPWM3;
   }
   if( flag1 == 2 )
   {
                *LED0 = 0xff;
                *Ext_IO_L=0xffff;
       *Ext_IO_H=0xffff;
            SetPWM3;
        flag1  = 0;               
   }
   EvaRegs.EVAIFRA.all = BIT7;
   // Acknowledge interrupt to receive more interrupts from PIE group 2
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
}

       CMD 部分如下:
      /*** Initialized Sections ***/                                          
          .cinit                        :        LOAD = FLASH_AB,        PAGE = 0        /* Load section to Flash */
                                RUN = RAM_H0,                  PAGE = 0    /* Run section from RAM */
                                LOAD_START(_cinit_loadstart),
                                RUN_START(_cinit_runstart),
                                                SIZE(_cinit_size)

        .const                        :   LOAD = FLASH_AB,          PAGE = 0    /* Load section to Flash */
                                RUN = RAM_H0,                 PAGE = 0    /* Run section from RAM */
                                LOAD_START(_const_loadstart),
                                RUN_START(_const_runstart),
                                                SIZE(_const_size)

        .econst                        :   LOAD = FLASH_AB,          PAGE = 0           /* Load section to Flash */
                                RUN = RAM_H0,                  PAGE = 0    /* Run section from RAM */
                                LOAD_START(_econst_loadstart),
                                RUN_START(_econst_runstart),
                                                SIZE(_econst_size)

        .pinit                        :   LOAD = FLASH_AB,          PAGE = 0    /* Load section to Flash */
                                RUN = RAM_H0,           PAGE = 0    /* Run section from RAM */
                                LOAD_START(_pinit_loadstart),
                                RUN_START(_pinit_runstart),
                                                SIZE(_pinit_size)

        .switch                        :   LOAD = FLASH_AB,          PAGE = 0           /* Load section to Flash */
                                RUN = RAM_H0,           PAGE = 0    /* Run section from RAM */
                                LOAD_START(_switch_loadstart),
                                RUN_START(_switch_runstart),
                                                SIZE(_switch_size)

        .text                        :   LOAD = FLASH_AB,         PAGE = 0    /* Load section to Flash */
                                RUN = RAM_L0L1,           PAGE = 0    /* Run section from RAM */
                                LOAD_START(_text_loadstart),
                                RUN_START(_text_runstart),
                                                SIZE(_text_size)
}
文件:
图片2.png   
0条回答

一周热门 更多>