Pablo Garcia

MCF52259 External nvSRAM problems

Discussion created by Pablo Garcia on May 19, 2011
Latest reply on May 23, 2011 by Angelo Dureghello

Hi everybody.


I'm (once again) in trouble. I've designed a board based on MCF52259 microcontroller and I'm having several problems with the external memory.


Hardware Description


The external memory is based on two Cypress CY14B108N-ZSP45XI nvSRAM memory chips. Each chip has 1Mb memory and is 45ns memory. When added, I've got 2Mb installed and connected to the Mini FlexBus port.


The mean of connection is by routing FB_A0 directly to BHE signal, and not(FB_A0) using an inverter to BLE. As a result of this, I've connected FB_A[1..19] to memory A[0..18] lines. So that's the address bus. The data bus is connecting this way: FB_D[0..7] connected to D[0..7] and to D[15..8]. (Notice that FB_D0 is connected to D0 and D15.) As you can guess this is exactly the same setup that is used in the tower board.


Each memory chip has one chip select (CS0 for one, and CS1 for the other) connected to CE.


Software Description


I've tuned the twrmcf52259 bsp to meet my board requirements. Basically I've changed the function that setups the CS0 and CS1 in order to have the following code:

static void _bsp_flexbus_nvsram_setup (const uint_32 base_address){    VMCF5XXX_MINIFB_STRUCT_PTR fb_ptr = &((VMCF5225_STRUCT_PTR)BSP_IPSBAR)->FB;        /* Enable external nvSRAM mapped on CS0 */    fb_ptr->CSAR0 = MCF5XXX_FBCS_CSAR_BA(base_address);     /* CS0 base address */    fb_ptr->CSCR0 = 0x00000d40;           /* CS0 control (8bit data, 3 waitstate) */    fb_ptr->CSMR0 = MCF5XXX_FBCS_CSMR_BAM_1024K | MCF5XXX_FBCS_CSMR_V; /* CS0 address mask and enable */        /* Enable external nvSRAM mapped on CS1 */    fb_ptr->CSAR1 = MCF5XXX_FBCS_CSAR_BA(base_address)+0x00100000;  /* CS1 base address */    fb_ptr->CSCR1 = 0x00000d40;           /* CS1 control (8bit data, 3 waitstate) */    fb_ptr->CSMR1 = MCF5XXX_FBCS_CSMR_BAM_1024K | MCF5XXX_FBCS_CSMR_V; /* CS1 address mask and enable */}

 base_address is set externally to 0x10000000.


In my functions I'm just writing directly to the memory and then reading it.

void write_nvSRAM(uint_8 wr) { char   *pc_posRAM; uint_32  i; uint_32  ui_ramsize = 0x200000; pc_posRAM = (char*)0x10000000; printf("\nWriting RAM memory %x\n", wr); for (i=0; i<ui_ramsize; i++) {  pc_posRAM[i] = wr; }}


void read_nvSRAM(uint_8 rd) { char   *pc_posRAM; uint_32  ui_ramsize = 0x200000; uint_32  i, j; uint_8  ui_value = 0; printf("Reading RAM memory %x\n", rd); pc_posRAM = (char*)0x10000000; j = 0; for (i=0; i<ui_ramsize; i++) {  ui_value  = pc_posRAM[i];  if (ui_value != rd) {   //printf("0x%x\n", i);   j++;  } } printf("Finished Reading RAM memory!! There are %d errors.\n", j);}


In the main program I just call this functions:



My problem is that the number of errors that the program find aren't always the same, not even in the same addresses. It doesn't seem to be a problem with one of the address or data lines.


Then, I've tried to write directly in the memory via de debugger. This is more extrange if possible. I can only write the even memory positions and not the odd ones. And if I write on an odd memory position, it is written in the previos even position.


I'm lost, any idea will be welcomed.


Best regards.