ucosii下使用外部SRAM

来源:互联网 发布:新店如何招募淘宝客 编辑:程序博客网 时间:2024/06/14 07:53

ucosii 基于uC-Probe工程

1.工程options->linker->Config->linnker congfigration file下得到路径$PROJ_DIR$/../BSP/STM32F103ZE_FLASH.icf

打开icf文件

/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = 0x08000000 ;
define symbol __ICFEDIT_region_ROM_end__     = 0x0807FFFF;
define symbol __ICFEDIT_region_RAM_start__   = 0x60000000;      // 外部SRAM起始地址,改成自己所需要的
define symbol __ICFEDIT_region_RAM_end__     = 0x6000FFFF;

 

2.app_vect_v5.c中将原程序中应用block1中SRAM3该为SRAM1

/*
*********************************************************************************************************
*                                           __low_level_init()
*
* Description : Perform low-level initialization.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : IAR startup code.
*
* Note(s)     : none.
*********************************************************************************************************
*/
#define STM32_EXT_SRAM
#ifdef STM32_EXT_SRAM
#pragma location="ICODE"
__interwork int __low_level_init(void)
{

                                                                /* FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL   */
                                                                /* if another Bank is req'd, adjust the Reg Addrs       */

    *(volatile  CPU_INT32U  *)0x40021014 = 0x00000114;          /* Enable FSMC clock                                    */


    *(volatile  CPU_INT32U  *)0x40021018 = 0x000001E0;          /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks          */


                                                                /* --------------------- CFG GPIO --------------------- */
                                                                /* SRAM Data lines, NOE and NWE configuration           */
                                                                /* SRAM Address lines configuration                     */
                                                                /* NOE and NWE configuration                            */
                                                                /* NE3 configuration                                    */
                                                                /* NBL0, NBL1 configuration                             */
    *(volatile  CPU_INT32U  *)0x40011400 = 0xB4BB44BB;         

 //port D 0x4001 1400  NE1:PD7->Alternate Function output speed 50MHz
    *(volatile  CPU_INT32U  *)0x40011404 = 0xBBBBBBBB;

    *(volatile  CPU_INT32U  *)0x40011800 = 0xB44444BB;          // port E 0x4001 1800
    *(volatile  CPU_INT32U  *)0x40011804 = 0xBBBBBBBB;

    *(volatile  CPU_INT32U  *)0x40011C00 = 0x44BBBBBB;          // port F 0x4001 1C00
    *(volatile  CPU_INT32U  *)0x40011C04 = 0xBBBB4444;

    *(volatile  CPU_INT32U  *)0x40012000 = 0x44BBBBBB;          // port G 0x4001 2000
    *(volatile  CPU_INT32U  *)0x40012004 = 0x44444B44;          // NE3:PG10->Input floating
   
   
                                                                /* --------------------- CFG FSMC --------------------- */
//    *(volatile  CPU_INT32U  *)0xA0000010 = 0x00001011;          /* Enable FSMC Bank1_SRAM3 Bank                 */
//    *(volatile  CPU_INT32U  *)0xA0000014 = 0x00000200;

    *(volatile  CPU_INT32U  *)0xA0000000 = 0x00001011;          /* Enable FSMC Bank1_SRAM1 Bank                         */
    *(volatile  CPU_INT32U  *)0xA0000004 = 0x00000200;
   
    return (1);
}
#endif

 

3.main()将

    Uart1_Init();
    MallocUartDmaBuf();

置于App_TaskStart前,malloc函数能自动将串口buf分配到外部内存中,效果如下。

Uart1_RxBuf addr=0x60000408
Uart2_RxBuf addr=0x60000450
Uart3_RxBuf addr=0x60000498

但是UCOSII系统启动后,即OSStart(); /* Start multitasking (i.e. give control to uC/OS-II)*/运行以后失控,程序指针停留在static  void  App_Fault_ISR (void)