打印

DSP启动详解(以2812为例)

[复制链接]
楼主: zhangmangui
手机看帖
扫描二维码
随时随地手机跟帖
21
zhangmangui|  楼主 | 2013-11-24 18:56 | 只看该作者 回帖奖励 |倒序浏览
wlwxzs 发表于 2013-11-23 23:56
版主,我有个相关问题请你指教,我用的是28069开发板,我把程序下到Flash,在调试界面里点击reset CPU按键 ...

如果是要调试   你应该load到RAM中运行才对
烧写flash和在线调试是不同的   

使用特权

评论回复
22
wlwxzs| | 2013-11-24 20:34 | 只看该作者
但我烧到FLASH里也可以单步调试,暂停什么的,这有什么区别吗?

使用特权

评论回复
23
zhangmangui|  楼主 | 2013-11-24 20:48 | 只看该作者
wlwxzs 发表于 2013-11-24 20:34
但我烧到FLASH里也可以单步调试,暂停什么的,这有什么区别吗?

那就还是搬移到了RAM中跑的

使用特权

评论回复
24
raoxianbin| | 2014-2-28 13:10 | 只看该作者
讲的很不错,这两天想烧写一下FLASH   到时请教版主

使用特权

评论回复
25
zhangmangui|  楼主 | 2014-2-28 15:05 | 只看该作者
raoxianbin 发表于 2014-2-28 13:10
讲的很不错,这两天想烧写一下FLASH   到时请教版主

2000自带flash的   烧写都由CCS的插件完成  很简单的

使用特权

评论回复
26
raoxianbin| | 2014-2-28 15:23 | 只看该作者
zhangmangui 发表于 2014-2-28 15:05
2000自带flash的   烧写都由CCS的插件完成  很简单的

恩 烧的时候遇到很多人遇到的问题了  就是烧写进去的话,必须还得连上仿真器才能工作   把JTGA拔了就不成功了  我看看斑竹以前发的那个帖子,学习下

使用特权

评论回复
27
zhangmangui|  楼主 | 2014-2-28 15:28 | 只看该作者
raoxianbin 发表于 2014-2-28 15:23
恩 烧的时候遇到很多人遇到的问题了  就是烧写进去的话,必须还得连上仿真器才能工作   把JTGA拔了就不成 ...

不会吧  你烧写提示成功了   拔掉仿真器重新上电就不工作了?

使用特权

评论回复
28
raoxianbin| | 2014-2-28 15:32 | 只看该作者
zhangmangui 发表于 2014-2-28 15:28
不会吧  你烧写提示成功了   拔掉仿真器重新上电就不工作了?

对   烧写提示成功,但是一把仿真器拔了  就不正常了  插上去又正常了

使用特权

评论回复
29
zhangmangui|  楼主 | 2014-2-28 16:48 | 只看该作者
raoxianbin 发表于 2014-2-28 15:32
对   烧写提示成功,但是一把仿真器拔了  就不正常了  插上去又正常了

控制器外部的一些跳线选择的引脚有没有选择对
你的意思是你烧写完  仿真器也在  CCS也连接上  此时代码是运行的
然后你断开CCS  断电重新上电后   代码就不运行  
再次接上JTAG   不用CCS连接到DSP上也就运行正常了?还是?

使用特权

评论回复
30
raoxianbin| | 2014-2-28 17:22 | 只看该作者
本帖最后由 raoxianbin 于 2014-2-28 17:29 编辑
zhangmangui 发表于 2014-2-28 16:48
控制器外部的一些跳线选择的引脚有没有选择对
你的意思是你烧写完  仿真器也在  CCS也连接上  此时代码 ...


引脚我都是按从FLASH运行通过硬件实现的,我的情况是烧写完之后,把电,JTAG,CCS都断开之后,再上电不出现象,但是一把Jtag连接上就好使了,但是我刚才用示波器观察了一下,我本来就是观察一个管脚上的PWM波,但是我发现,但JTGA插上的时候,波形很规范,可以驱动一个发光二极管,但是把JTGA拿下来的时候,波形不规范,但是还是有的,只不过无法从直观上观察到发光二极管发光就是,也就是说,现象和我在RAM里调试的完全不同,加上JTga就对了    迷茫。。。

使用特权

评论回复
31
zhangmangui|  楼主 | 2014-2-28 18:18 | 只看该作者
raoxianbin 发表于 2014-2-28 17:22
引脚我都是按从FLASH运行通过硬件实现的,我的情况是烧写完之后,把电,JTAG,CCS都断开之后,再上电不出 ...

只是把JTAG口插上  USB端有没有接到电脑上?

使用特权

评论回复
32
raoxianbin| | 2014-2-28 18:51 | 只看该作者
zhangmangui 发表于 2014-2-28 18:18
只是把JTAG口插上  USB端有没有接到电脑上?

插上了。。USB拔了的话也是不正常的状态,斑竹我再问一个问题,在主函数里面执行
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);//将初始化Flash代码复制到RAM
这个函数,是不是只是把通过#pragma CODE_SECTION(函数, "ramfuncs")处理的函数复制到RAM对吧,没有经过这样处理的函数还是在FLASH中执行对吗??  
麻烦版主了

使用特权

评论回复
33
raoxianbin| | 2014-2-28 19:05 | 只看该作者
本帖最后由 raoxianbin 于 2014-2-28 19:09 编辑

烧写又都正常了,重新烧写了一遍,麻烦版主解答下我那个疑问。。还有就是GEL在烧写的过程中是必须的吗?

使用特权

评论回复
34
zhangmangui|  楼主 | 2014-2-28 19:45 | 只看该作者
raoxianbin 发表于 2014-2-28 19:05
烧写又都正常了,重新烧写了一遍,麻烦版主解答下我那个疑问。。还有就是GEL在烧写的过程中是必须的吗? ...

GEL只是对你的ccs功能和存储器等进行初始化   不是必要的  它的重要性在于计算机模拟环境的用户

使用特权

评论回复
35
zhangmangui|  楼主 | 2014-2-28 19:45 | 只看该作者
raoxianbin 发表于 2014-2-28 18:51
插上了。。USB拔了的话也是不正常的状态,斑竹我再问一个问题,在主函数里面执行
MemCopy(&RamfuncsLoadS ...

搬移应该只是搬移代码段

使用特权

评论回复
36
raoxianbin| | 2014-2-28 19:52 | 只看该作者
zhangmangui 发表于 2014-2-28 19:45
搬移应该只是搬移代码段

恩    谢谢斑竹,那是不是说如果我程序中只用了一次
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);//将初始化Flash代码复制到RAM
这个函数,也就是初始化flash控制寄存器,再就没有其他的复制操作,那是不是只有初始化FLASH的程序在RAM中执行,其他的功能都是在FLASH中执行的?

使用特权

评论回复
37
zhangmangui|  楼主 | 2014-2-28 19:56 | 只看该作者
raoxianbin 发表于 2014-2-28 19:52
恩    谢谢斑竹,那是不是说如果我程序中只用了一次
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &Ra ...

搬移后肯定都是在RAM中执行了  
你可以对比一下  比如蜂鸣器的发声频率
在flash中运行的时候明显慢 搬移后运行频率明显变快了

使用特权

评论回复
38
拿起书本| | 2014-2-28 20:09 | 只看该作者
关于FLASH搬移到RAM中的**里运行的**应该不少,应该好解决。

使用特权

评论回复
39
raoxianbin| | 2014-2-28 20:21 | 只看该作者
zhangmangui 发表于 2014-2-28 19:56
搬移后肯定都是在RAM中执行了  
你可以对比一下  比如蜂鸣器的发声频率
在flash中运行的时候明显慢 搬移 ...

那我就有点迷糊了  


斑竹那您看看这个TI的测试程序


// TI File $Revision: /main/3 $
// Checkin $Date: July 2, 2007   11:31:49 $
//###########################################################################
//
// FILE:   DSP28_281xFlash.c
//
// TITLE:  DSP281x Flash example.
//
// ASSUMPTIONS:
//
//          This program requires the DSP281x V1.00 header files.  
//          As supplied, this project is configured for "boot to Flash" operation.   
//
//          This example runs the EV Timer Period example from the
//          Flash.  
//
//          1) Build the project
//          2) Flash the .out file into the device.  This program will fit on
//             an F2812 or an F2810
//          3) Set the hardware jumpers to boot to Flash
//          4) Use the included GEL file to load the project, symbols
//             defined within the project and the variables into the watch
//             window.   
//
//          Steps that were taken to convert the EV example from RAM
//          to Flash execution:
//
//          - Change the linker cmd file to reflect the flash memory map.
//            This example uses the DSP281x F2812.cmd file.
//          - Make sure any initialized sections are mapped to Flash.  
//            In SDFlash utility this can be checked by the View->Coff/Hex
//            status utility. Any section marked as "load" should be
//            allocated to Flash.
//          - Make sure there is a branch instruction from the entry to Flash
//            at 0x3F7FF6 to the beginning of code execution. This example
//            uses the DSP281x_CodeStartBranch.asm file to accomplish this.
//          - Set boot mode Jumpers to "boot to Flash"
//          - For best performance from the flash, modify the waitstates
//            and enable the flash pipeline as shown in this example.
//            Note: any code that manipulates the flash waitstate and pipeline
//            control must be run from RAM. Thus these functions are located
//            in their own memory section called ramfuncs.
//
// DESCRIPTION:
//
//          This program sets up EVA Timer 1, EVA Timer 2, EVB Timer 3
//          and EVB Timer 4 to fire an interrupt on a period overflow.  
//          A count is kept each time each interrupt passes through
//          the interrupt service routine.
//
//          EVA Timer 1 has the shortest period while EVB Timer4 has the
//          longest period.
//
//          ISR Locations:
//                eva_timer1_isr  executed from RAM, puts flash in sleep mode
//                eva_timer2_isr  executed from RAM, puts flash in standby mode
//                evb_timer3_isr  executed from RAM, puts flash in sleep mode
//                                              and later moves it to standby
//                evb_timer4_isr  executed from FLASH
//        
//          Watch Variables:
//
//                EvaTimer1InterruptCount;
//                EvaTimer2InterruptCount;
//                EvbTimer3InterruptCount;
//                EvbTimer4InterruptCount;
//
//###########################################################################
// $TI Release: DSP281x C/C++ Header Files V1.20 $
// $Release Date: July 27, 2009 $
//###########################################################################

#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File

// Functions that will be run from RAM need to be assigned to
// a different section.  This section will then be mapped using
// the linker cmd file.
#pragma CODE_SECTION(eva_timer1_isr, "ramfuncs");//eva_timer_isr为一个函数名
#pragma CODE_SECTION(eva_timer2_isr, "ramfuncs");
#pragma CODE_SECTION(evb_timer3_isr, "ramfuncs");

// Prototype statements for functions found within this file.
interrupt void eva_timer1_isr(void);
interrupt void eva_timer2_isr(void);
interrupt void evb_timer3_isr(void);
interrupt void evb_timer4_isr(void);
void init_eva_timer1(void);
void init_eva_timer2(void);
void init_evb_timer3(void);
void init_evb_timer4(void);

// Global variables used in this example
Uint32 EvaTimer1InterruptCount;
Uint32 EvaTimer2InterruptCount;
Uint32 EvbTimer3InterruptCount;
Uint32 EvbTimer4InterruptCount;
Uint32 LoopCount;

// These are defined by the linker (see F2812.cmd)
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;


void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();
   
// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_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 DSP281x_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 DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.         
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.T1PINT = &eva_timer1_isr;
   PieVectTable.T2PINT = &eva_timer2_isr;
   PieVectTable.T3PINT = &evb_timer3_isr;
   PieVectTable.T4PINT = &evb_timer4_isr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   init_eva_timer1();
   init_eva_timer2();
   init_evb_timer3();
   init_evb_timer4();
     
// Step 5. User specific code, enable interrupts:

// Copy time critical code and Flash setup code to RAM
// This includes the following ISR functions: EvaTimer1(), EvaTimer2()
// EvbTimer3 and and InitFlash();
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the F2812.cmd file.
   MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
   InitFlash();

   // Initialize count values to 0
   EvaTimer1InterruptCount = 0;
   EvaTimer2InterruptCount = 0;
   EvbTimer3InterruptCount = 0;
   EvbTimer4InterruptCount = 0;
   LoopCount = 0;


   // Enable PIE group 2 interrupt 4 for T1PINT
   PieCtrlRegs.PIEIER2.all = M_INT4;
   // Enable PIE group 3 interrupt 1 for T2PINT
   PieCtrlRegs.PIEIER3.all = M_INT1;   
   // Enable PIE group 4 interrupt 4 for T3PINT
   PieCtrlRegs.PIEIER4.all = M_INT4;
   // Enable PIE group 5 interrupt 1 for T4PINT
   PieCtrlRegs.PIEIER5.all = M_INT1;

   // Enable CPU INT2 for T1PINT, INT3 for T2PINT, INT4 for T3PINT
   // and INT5 for T4PINT:
   IER |= (M_INT2 | M_INT3 | M_INT4 | M_INT5);

   // 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:       
   while(1)
   {
       LoopCount++;
   }

}


void init_eva_timer1(void)
{
    // Initialize EVA Timer 1:
    // Setup Timer 1 Registers (EV A)
    EvaRegs.GPTCONA.all = 0;
   
    // Set the Period for the GP timer 1 to 0x0200;
    EvaRegs.T1PR = 0x0200;       // Period
    EvaRegs.T1CMPR = 0x0000;     // Compare Reg
   
    // Enable Period interrupt bits for GP timer 1
    // Count up, x128, internal clk, enable compare, use own period
    EvaRegs.EVAIMRA.bit.T1PINT = 1;
    EvaRegs.EVAIFRA.bit.T1PINT = 1;

    // Clear the counter for GP timer 1
    EvaRegs.T1CNT = 0x0000;
    EvaRegs.T1CON.all = 0x1742;

    // Start EVA ADC Conversion on timer 1 Period interrupt
    EvaRegs.GPTCONA.bit.T1TOADC = 2;

}

void init_eva_timer2(void)
{
    // Initialize EVA Timer 2:
    // Setup Timer 2 Registers (EV A)
    EvaRegs.GPTCONA.all = 0;
   
    // Set the Period for the GP timer 2 to 0x0200;
    EvaRegs.T2PR = 0x0400;       // Period
    EvaRegs.T2CMPR = 0x0000;     // Compare Reg
   
    // Enable Period interrupt bits for GP timer 2
    // Count up, x128, internal clk, enable compare, use own period
    EvaRegs.EVAIMRB.bit.T2PINT = 1;
    EvaRegs.EVAIFRB.bit.T2PINT = 1;

    // Clear the counter for GP timer 2
    EvaRegs.T2CNT = 0x0000;
    EvaRegs.T2CON.all = 0x1742;

    // Start EVA ADC Conversion on timer 2 Period interrupt
    EvaRegs.GPTCONA.bit.T2TOADC = 2;
}

void init_evb_timer3(void)
{
    // Initialize EVB Timer 3:
    // Setup Timer 3 Registers (EV B)
    EvbRegs.GPTCONB.all = 0;
   
    // Set the Period for the GP timer 3 to 0x0200;
    EvbRegs.T3PR = 0x0800;       // Period
    EvbRegs.T3CMPR = 0x0000;     // Compare Reg
   
    // Enable Period interrupt bits for GP timer 3
    // Count up, x128, internal clk, enable compare, use own period
    EvbRegs.EVBIMRA.bit.T3PINT = 1;
    EvbRegs.EVBIFRA.bit.T3PINT = 1;

    // Clear the counter for GP timer 3
    EvbRegs.T3CNT = 0x0000;
    EvbRegs.T3CON.all = 0x1742;

    // Start EVA ADC Conversion on timer 3 Period interrupt
    EvbRegs.GPTCONB.bit.T3TOADC = 2;
}

void init_evb_timer4(void)
{
    // Initialize EVB Timer 4:
    // Setup Timer 4 Registers (EV B)
    EvbRegs.GPTCONB.all = 0;
   
    // Set the Period for the GP timer 4 to 0x0200;
    EvbRegs.T4PR = 0x1000;       // Period
    EvbRegs.T4CMPR = 0x0000;     // Compare Reg
   
    // Enable Period interrupt bits for GP timer 4
    // Count up, x128, internal clk, enable compare, use own period
    EvbRegs.EVBIMRB.bit.T4PINT = 1;
    EvbRegs.EVBIFRB.bit.T4PINT = 1;

    // Clear the counter for GP timer 4
    EvbRegs.T4CNT = 0x0000;
    EvbRegs.T4CON.all = 0x1742;

    // Start EVA ADC Conversion on timer 4 Period interrupt
    EvbRegs.GPTCONB.bit.T4TOADC = 2;
}

// This ISR MUST be executed from RAM as it will put the Flash into Sleep
interrupt void eva_timer1_isr(void)
{
    Uint16 i;

    // Put the Flash to sleep
    FlashRegs.FPWR.bit.PWR = FLASH_SLEEP;
   
    EvaTimer1InterruptCount++;
    // Short Delay to simulate some ISR Code
    for(i = 1; i < 0x03FF; i++) {}

    // Enable more interrupts from this timer
    EvaRegs.EVAIMRA.bit.T1PINT = 1;

    // Note: To be safe, use a mask value to write to the entire
    // EVAIFRA register.  Writing to one bit will cause a read-modify-write
    // operation that may have the result of writing 1's to clear
    // bits other then those intended.
    EvaRegs.EVAIFRA.all = BIT7;

    // Acknowledge interrupt to receive more interrupts from PIE group 2
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
}

// This ISR MUST be executed from RAM as it will put the Flash into Standby
interrupt void eva_timer2_isr(void)
{
    Uint16 i;

    // Put the Flash into standby
    FlashRegs.FPWR.bit.PWR = FLASH_STANDBY;

    EvaTimer2InterruptCount++;

    // Short Delay to simulate some ISR Code
    for(i = 1; i < 0x02FF; i++) {}

    // Enable more interrupts from this timer
    EvaRegs.EVAIMRB.bit.T2PINT = 1;

   // Note: To be safe, use a mask value to write to the entire
   // EVAIFRB register.  Writing to one bit will cause a read-modify-write
   // operation that may have the result of writing 1's to clear
   // bits other then those intended.
   EvaRegs.EVAIFRB.all = BIT0;

   // Acknowledge interrupt to recieve more interrupts from PIE group 3
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}

// This ISR MUST be executed from RAM as it will put the Flash to sleep
// and then later move it to Standby
interrupt void evb_timer3_isr(void)
{

    Uint16 i;

    // Put the Flash to sleep
    FlashRegs.FPWR.bit.PWR = FLASH_SLEEP;

    EvbTimer3InterruptCount++;

    // Short Delay to simulate some ISR Code
    for(i = 1; i < 0x01FF; i++) {}

    // Sometime later, move the Flash to standby
    FlashRegs.FPWR.bit.PWR = FLASH_STANDBY;

    // Note: To be safe, use a mask value to write to the entire
    // EVBIFRA register.  Writing to one bit will cause a read-modify-write
    // operation that may have the result of writing 1's to clear
    // bits other then those intended.
    EvbRegs.EVBIFRA.all = BIT7;

    // Acknowledge interrupt to receive more interrupts from PIE group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;

}

// This ISR will be executed out of Flash
interrupt void evb_timer4_isr(void)
{

    Uint16 i;
   
    EvbTimer4InterruptCount++;

    // Short Delay to simulate some ISR Code
    for(i = 1; i < 0x00FF; i++) {}

    // Note: To be safe, use a mask value to write to the entire
    // EVBIFRB register.  Writing to one bit will cause a read-modify-write
    // operation that may have the result of writing 1's to clear
    // bits other then those intended.
    EvbRegs.EVBIFRB.all = BIT0;       

    // Acknowledge interrupt to recieve more interrupts from PIE group 5
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;

}


//===========================================================================
// No more.
//===========================================================================


在这个程序中,中断 1 2 3是在RAM中执行的

我认为他们就是因为有
#pragma CODE_SECTION(eva_timer1_isr, "ramfuncs");//eva_timer_isr为一个函数名
#pragma CODE_SECTION(eva_timer2_isr, "ramfuncs");
#pragma CODE_SECTION(evb_timer3_isr, "ramfuncs");
以上3句话,给它们分配了段,再通过MEM函数复制到了RAM中执行,但是中断4没处理
中断4就是在flash中执行,不知道我理解错了没、


麻烦斑竹了

使用特权

评论回复
40
zhangmangui|  楼主 | 2014-2-28 22:12 | 只看该作者
raoxianbin 发表于 2014-2-28 20:21
那我就有点迷糊了  

你的理解应该是对的   我下来再捉摸一下

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则