Adding external RAM to M52259 using mini-flexbus

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding external RAM to M52259 using mini-flexbus

Jump to solution
5,146 Views
JaimeR
Contributor III

Hi, I have read AN3854 concerning this topic, however, this AN doesn't mention modifications to .lcf and I am not sure If modifications are required.

I also know that the 52259EVB have an external MRAM connected to this bus, but I haven't seen any 

explanation about the .lcf file in the examples provided, neither an example of  an application using this

external memory.

I am just starting with this part of the project and I might have missed some important documentation, please let me know if anyone knows about documentations or examples about this topic.

 

Thanks in advanced,

 

0 Kudos
1 Solution
826 Views
EAI
Contributor IV

in the BSP project, in the file bsp_init.c, function mcf5225_init, you will find:

 

    /* Enable Mini FlexBUS signals (used by external MRAM and CPLD) */
    reg_ptr->GPIO.PASPAR = 0x20;   /* enable CS1 operation for CPLD */
    reg_ptr->GPIO.PTEPAR = 0xff;
    reg_ptr->GPIO.PTFPAR = 0xff;
    reg_ptr->GPIO.PTGPAR = 0xff;   /* enable CS0 operation for MRAM */
    reg_ptr->GPIO.PTHPAR = 0x5555;

    /* Enable external MRAM mapped on CS0 */
    reg_ptr->FB.CSAR0 = 0x10000000; /* CS0 base address */
    reg_ptr->FB.CSCR0 = 0x00000540; /* CS0 control (8bit data, 1 waitstate) */
    reg_ptr->FB.CSMR0 = 0x00070001; /* CS0 address mask and enable */

Message Edited by EAI on 2009-08-05 06:49 PM

View solution in original post

0 Kudos
7 Replies
826 Views
EAI
Contributor IV

The extmram.lcf file used by the web_hvac demo shows an example of using the MRAM.

 

The linker file defines some symbols:

   ___EXTERNAL_MRAM_ROM_BASE = 0x10000000;
   ___EXTERNAL_MRAM_ROM_SIZE = 0x00060000;
   ___EXTERNAL_MRAM_RAM_BASE = 0x10060000;
   ___EXTERNAL_MRAM_RAM_SIZE = 0x00020000;

The way the MRAM was carved up between ROM, or code space, and RAM was arbitrary.

 

For rhe RAM portion, the BSP then defines :

#define BSP_EXTERNAL_MRAM_RAM_BASE  ((pointer)__EXTERNAL_MRAM_RAM_BASE)
#define BSP_EXTERNAL_MRAM_RAM_SIZE  ((uint_32)__EXTERNAL_MRAM_RAM_SIZE)

 

Then the web HVAC demo carves up the MRAM RAM :

    #define DEMOCFG_RTCS_POOL_ADDR  (uint_32)(BSP_EXTERNAL_MRAM_RAM_BASE)
    #define DEMOCFG_RTCS_POOL_SIZE  0x0000A000
    #define DEMOCFG_MFS_POOL_ADDR   (uint_32)(DEMOCFG_RTCS_POOL_ADDR + DEMOCFG_RTCS_POOL_SIZE)
    #define DEMOCFG_MFS_POOL_SIZE   0x00002000
    #define DEMOCFG_KLOG_ADDR       (uint_32)(DEMOCFG_MFS_POOL_ADDR + DEMOCFG_MFS_POOL_SIZE)
    #define DEMOCFG_KLOG_SIZE       4000

 

and then it is used in the application, for example, to set up a memory pool for RTCS:

 

    _RTCS_mem_pool = _mem_create_pool((pointer)DEMOCFG_RTCS_POOL_ADDR, DEMOCFG_RTCS_POOL_SIZE);

826 Views
kleckerspur
Contributor III

Hello,

In which file do you put the following lines:

For rhe RAM portion, the BSP then defines :

#define BSP_EXTERNAL_MRAM_RAM_BASE  ((pointer)__EXTERNAL_MRAM_RAM_BASE)
#define BSP_EXTERNAL_MRAM_RAM_SIZE  ((uint_32)__EXTERNAL_MRAM_RAM_SIZE)

And where do put this line ?

Then the web HVAC demo carves up the MRAM RAM :

    #define DEMOCFG_RTCS_POOL_ADDR  (uint_32)(BSP_EXTERNAL_MRAM_RAM_BASE)
    #define DEMOCFG_RTCS_POOL_SIZE  0x0000A000
    #define DEMOCFG_MFS_POOL_ADDR   (uint_32)(DEMOCFG_RTCS_POOL_ADDR + DEMOCFG_RTCS_POOL_SIZE)
    #define DEMOCFG_MFS_POOL_SIZE   0x00002000
    #define DEMOCFG_KLOG_ADDR       (uint_32)(DEMOCFG_MFS_POOL_ADDR + DEMOCFG_MFS_POOL_SIZE)
    #define DEMOCFG_KLOG_SIZE       4000

Thanks

0 Kudos
826 Views
JaimeR
Contributor III

Thank you for your answer, things are starting to get clear.

 

What if I want to use external RAM for stack?

0 Kudos
826 Views
EAI
Contributor IV

You can create a task that has it's stack in ext. ram by calling _task_create_at

 

_task_id _task_create_at
   (
      /* [IN] the processor upon which to create the task */
      _processor_number processor_number,

      /* [IN] the task template index number for this task */
      _mqx_uint         template_index,

      /* [IN] the parameter to pass to the newly created task */
      uint_32           parameter,

      /* [IN] the location where the stack and TD are to be created */
      pointer           stack_ptr,

      /* [IN] the size of the stack */
      _mem_size         stack_size
   )

 

This function is not documented in the reference manual.

826 Views
JaimeR
Contributor III

Thats exactly what I need, now I am looking for the mini Flexbus initialization code in the web_hvac application in order to make the changes to use my external SRAM and not the MRAM provided with the

M52259EVB. I have looked for the following code mentioned in the AN3854 but search haven't returned anything. 

 

MCF_GPIO_PTEPAR = 0xFF; //Enable Address Lines A0-A7
MCF_GPIO_PTFPAR = 0xFF; //Enable Address Lines A8-A15
MCF_GPIO_PTGPAR = 0xFF; //Enable Address Lines A16-A19
MCF_GPIO_PTHPAR = 0x5555; //Enable Data Lines D0-D7
MCF_GPIO_PASPAR = 0x20; //Enable FB_CS1 function

 

 

Do you have an idea what should I look for?

0 Kudos
827 Views
EAI
Contributor IV

in the BSP project, in the file bsp_init.c, function mcf5225_init, you will find:

 

    /* Enable Mini FlexBUS signals (used by external MRAM and CPLD) */
    reg_ptr->GPIO.PASPAR = 0x20;   /* enable CS1 operation for CPLD */
    reg_ptr->GPIO.PTEPAR = 0xff;
    reg_ptr->GPIO.PTFPAR = 0xff;
    reg_ptr->GPIO.PTGPAR = 0xff;   /* enable CS0 operation for MRAM */
    reg_ptr->GPIO.PTHPAR = 0x5555;

    /* Enable external MRAM mapped on CS0 */
    reg_ptr->FB.CSAR0 = 0x10000000; /* CS0 base address */
    reg_ptr->FB.CSCR0 = 0x00000540; /* CS0 control (8bit data, 1 waitstate) */
    reg_ptr->FB.CSMR0 = 0x00070001; /* CS0 address mask and enable */

Message Edited by EAI on 2009-08-05 06:49 PM
0 Kudos
826 Views
niravj
Contributor I

Hi,

 

This thread was quite helpful to me in bringing up the external sram up and running in my app spec board, the attached app note I used for making my sram accessible.

 

did not modified the NVRAM start address of MCF52259EVB - used the same address with different size in Base address mask register. I used following configuration in control,mask and base addr registers for mini flex bus in bsp_init.c...

 

/* Enable Mini FlexBUS signals (used by external MRAM and CPLD) */    reg_ptr->GPIO.PASPAR = 0x10;       reg_ptr->GPIO.PTEPAR = 0xff;    reg_ptr->GPIO.PTFPAR = 0xff;    reg_ptr->GPIO.PTGPAR = 0xff;       reg_ptr->GPIO.PTHPAR = 0x0000;    reg_ptr->GPIO.DDRTH = 0xff;     reg_ptr->GPIO.PORTTH = 0x00;         /* Enable external MRAM mapped on CS0 */    reg_ptr->FB.CSAR0 = 0x10000000; /* CS0 base address */    reg_ptr->FB.CSCR0 = 0x00301780; /* port size = 16 bit, 5- ws, multiplex mode, auto acknowledge enable, address setup - 11*/      reg_ptr->FB.CSMR0 = 0x00010001; /* size 128 kb */

 

With this initialization and following code I could access the external SRAM I configured

 

   *((unsigned short int *)0x10000000) = 0x1517;   *((unsigned short int *)0x10000002) = 0x1518;   *((unsigned short int *)0x10000004) = 0x1519;   *((unsigned short int *)0x10000006) = 0x151A;

 

Question - when I try to use _task_create_at or memory pool creation with pointer at this external sram address it gives error.

 

Error while _task_create_at -> unhandled interrupt

Error while memory pool creation -> memory pool size too small.

 

using following code for both task creation and memory pool creation

 

#define DEMOCFG_RTCS_POOL_ADDR  (uint_32)(BSP_EXTERNAL_SRAM_BASE)#define DEMOCFG_RTCS_POOL_SIZE  0x000100pointer pt = BSP_EXTERNAL_MRAM_BASE;....................tid = _task_create_at(0, TEST_TASK1, TEST_TASK1_PARAM, pt,TEST_STACK_SIZE);................._RTCS_mem_pool = _mem_create_pool((pointer)DEMOCFG_RTCS_POOL_ADDR, DEMOCFG_RTCS_POOL_SIZE);  

 

Any idea why MQX is giving error in both of the above function calls - is the memory endienness or byte/word access which MQX needs specifically ? I am using here the mux mode in 16 bit memory configurations...

 

Thanks for your time in reading this long thread and waiting for replies

 

0 Kudos