This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Run stack from external Memory

Hello All

I am working on a project using a STR912 ARM9 core microcontroller with 96k internal RAM. I also have a external RAM with 1MB. Since i begin to run low on internal RAM, i want to transfer the whole stack to the external RAM so everything is running from there.

Now i am wondering how to implement this. I am using Keil µVision and the Keil Compiler. In the target options i can specifiy my external RAM but as soon as i declare it as on the only default memory, the code won't execute on the microcontroller anymore.
My guess is that the EMI configuration (it's a c function in my main.c file) needs to be called from the Startup code before the stack gets initialized but i don't really know how to implement this. Has anybody the answer or a example code where this is done ? I searched for this info but haven't found anything.
Oh the startup code i use is the one provided by Keil for the STR912 device.

Thanks for reading

Florian

Parents
  • Hello

    I tried to call the c-function from the main routine for configuration of the EMI in the startup code but it doesn't work.

    Here is the c-function:

    void EMI_Configuration(void)
    {
            // GPIO7 Configuration
      //configure EMI A16, A17, A18, CS0, CS1 pin GPIO 7.0, 7.1, 7.2, 7.6, 7.7
    
            GPIO_InitTypeDef        GPIO_InitStructure2;
            EMI_InitTypeDef         EMI_InitStruct;
    
      GPIO_DeInit(GPIO7);
      GPIO_StructInit(&GPIO_InitStructure2);
      GPIO_InitStructure2.GPIO_Direction = GPIO_PinOutput;
      GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 |
                                     GPIO_Pin_7;
      GPIO_InitStructure2.GPIO_Type = GPIO_Type_PushPull;
      GPIO_InitStructure2.GPIO_Alternate = GPIO_OutputAlt2 ;
      GPIO_Init (GPIO7, &GPIO_InitStructure2);
    
      GPIO_InitStructure2.GPIO_Direction = GPIO_PinOutput;
      GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_6;
      GPIO_InitStructure2.GPIO_Type = GPIO_Type_PushPull;
      GPIO_InitStructure2.GPIO_Alternate = GPIO_OutputAlt3 ;
      GPIO_Init (GPIO7, &GPIO_InitStructure2);
    
      GPIO_EMIConfig(ENABLE);
    
      EMI_DeInit();
    
      EMI_StructInit(&EMI_InitStruct);
      EMI_InitStruct.EMI_Bank_IDCY = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTRD = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTWR = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTROEN = 0x2;
      EMI_InitStruct.EMI_Bank_WSTWEN = 0x2;
      EMI_InitStruct.EMI_Bank_MemWidth = EMI_Width_HalfWord;
      EMI_InitStruct.EMI_Bank_WriteProtection =  EMI_Bank_NonWriteProtect;
    
            EMI_Init( EMI_Bank0, &EMI_InitStruct);
      EMI_Init( EMI_Bank1, &EMI_InitStruct);
    }
    

    And here the call from the startup:

    ; Setup External Memory Interface
            IMPORT EMI_Configuration
            MOV             SP,#0x4000000
            ADD             SP,SP,#0x10000
            LDR             R0, =EMI_Configuration
            BX              R0
    

    Can anybody tell me where the problem is ? Can i even call a c-function directly from the startup code ? As it's possible with other compilers.
    If it's not possible to call a c-function, has anybody got an example for configuration of the EMI in ASM for the STR9xx device ?

    Thanks for reading

    Florian

Reply
  • Hello

    I tried to call the c-function from the main routine for configuration of the EMI in the startup code but it doesn't work.

    Here is the c-function:

    void EMI_Configuration(void)
    {
            // GPIO7 Configuration
      //configure EMI A16, A17, A18, CS0, CS1 pin GPIO 7.0, 7.1, 7.2, 7.6, 7.7
    
            GPIO_InitTypeDef        GPIO_InitStructure2;
            EMI_InitTypeDef         EMI_InitStruct;
    
      GPIO_DeInit(GPIO7);
      GPIO_StructInit(&GPIO_InitStructure2);
      GPIO_InitStructure2.GPIO_Direction = GPIO_PinOutput;
      GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 |
                                     GPIO_Pin_7;
      GPIO_InitStructure2.GPIO_Type = GPIO_Type_PushPull;
      GPIO_InitStructure2.GPIO_Alternate = GPIO_OutputAlt2 ;
      GPIO_Init (GPIO7, &GPIO_InitStructure2);
    
      GPIO_InitStructure2.GPIO_Direction = GPIO_PinOutput;
      GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_6;
      GPIO_InitStructure2.GPIO_Type = GPIO_Type_PushPull;
      GPIO_InitStructure2.GPIO_Alternate = GPIO_OutputAlt3 ;
      GPIO_Init (GPIO7, &GPIO_InitStructure2);
    
      GPIO_EMIConfig(ENABLE);
    
      EMI_DeInit();
    
      EMI_StructInit(&EMI_InitStruct);
      EMI_InitStruct.EMI_Bank_IDCY = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTRD = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTWR = 0x3 ;
      EMI_InitStruct.EMI_Bank_WSTROEN = 0x2;
      EMI_InitStruct.EMI_Bank_WSTWEN = 0x2;
      EMI_InitStruct.EMI_Bank_MemWidth = EMI_Width_HalfWord;
      EMI_InitStruct.EMI_Bank_WriteProtection =  EMI_Bank_NonWriteProtect;
    
            EMI_Init( EMI_Bank0, &EMI_InitStruct);
      EMI_Init( EMI_Bank1, &EMI_InitStruct);
    }
    

    And here the call from the startup:

    ; Setup External Memory Interface
            IMPORT EMI_Configuration
            MOV             SP,#0x4000000
            ADD             SP,SP,#0x10000
            LDR             R0, =EMI_Configuration
            BX              R0
    

    Can anybody tell me where the problem is ? Can i even call a c-function directly from the startup code ? As it's possible with other compilers.
    If it's not possible to call a c-function, has anybody got an example for configuration of the EMI in ASM for the STR9xx device ?

    Thanks for reading

    Florian

Children