lpcware

LPC2468 - access to external NOR flash

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by rete1234 on Tue Mar 24 21:03:18 MST 2015
I'm doing a development on an NXP LPC2468.

We have an external NOR flash (16-bits wide - SST38VF6401) - which we want to use for code.

So we have mapped A0-A21 from MCU to A0-A21 on NOR flash. My first question - is this correct?
I have a application note that says A1-A22 (MCU) should go to A0-A21 for 16 bit memories.

I've been able to write to the NOR using A0 tided to either high or low (as needed). I can also access
words (16-bit) on the flash. But when I try and access a byte at a time I always get value=0xff.

The following code works for A0_ENABLE defined as 0 - I can't get it working with all signals controlled by EMC.
What am I doing wrong?



    // XXXXXXXXXX FLASH XXXXXXXXXXX
#if (A0_ENABLE)
    PINSEL8    = 0x55555555;    // A0-A15
#else
    PINSEL8    = 0x55555554;    // A1-A15

    // tie A0 low
    FIO4DIR    |= 1;
    FIO4CLR    |= 1;
#endif

#if (A0_ENABLE)
    EMCSTATICCNFG1 = (
        (1 << CNF_MEM_WIDTH) |  // bus width 0==8, 1==16, 2==32
        (0 << CNF_PAGE_MODE) |  // enable page mode (len=4)
        (0 << CNF_CS_HIGH)   |  // CS polarity 0=low, 1==high
        (0 << CNF_BLS_READ)  |  // byte lane active for 0=wr, 1=rd/wr
        (0 << CNF_EXT_WAIT)  |  // enable extended wait
        (0 << CNF_BUFF_EN)   |  // buffer enable
        (0 << CNF_WR_PROT)   |  // enable write protect
        0);
#else
    EMCSTATICCNFG1 = (
        (1 << CNF_MEM_WIDTH) |  // bus width 0==8, 1==16, 2==32
        (0 << CNF_PAGE_MODE) |  // enable page mode (len=4)
        (0 << CNF_CS_HIGH)   |  // CS polarity 0=low, 1==high
        (1 << CNF_BLS_READ)  |  // byte lane active for 0=wr, 1=rd/wr
        (0 << CNF_EXT_WAIT)  |  // enable extended wait
        (0 << CNF_BUFF_EN)   |  // buffer enable
        (0 << CNF_WR_PROT)   |  // enable write protect
        0);
#endif
   
    EMCSTATICWAITOEN1 = 1;  // 15 max   CS->OE delay: N*17.361ns
    EMCSTATICWAITRD1  = 6;  // 31 max   CS length: (N+1)*17.361ns
    EMCSTATICWAITTURN1= 5;  // 15 max   bus turn around after read: (N+1)*17.361ns

    //EMCSTATICWAITPG1  = 0;
   
    EMCSTATICWAITWEN1 = 0;  // 15 max   CS->WE delay: (N+1)*17.361ns
    EMCSTATICWAITWR1  = 5;  // 31 max   WE length:    (N+2)*17.361ns



I read and write words using the following code:


void WORD_PUT(unsigned int a, unsigned short v)
{
#if (A0_ENABLE == 0)
    if (a & 1)
    {
        FIO4SET |= 1;
    }
    else
    {
        FIO4CLR |= 1;
    }
   
    //a &= ~1;
#endif
   
    volatile unsigned short *p = (unsigned short*)(0x81000000 + a);
    *p = v;
   
#if (A0_ENABLE == 0)
    FIO4CLR |= 1;
#endif
}

unsigned char BYTE_GET(unsigned int a)
{
    unsigned char v;

#if (A0_ENABLE == 0)   
    if (a & 1)
    {
        FIO4SET |= 1;
    }
    else
    {
        FIO4CLR |= 1;
    }
   
    //a &= ~1;
#endif
   
    volatile unsigned char *p = (unsigned char*)(0x81000000 + a);
    v = *p;
   
#if (AO_ENABLE == 0)
    FIO4CLR |= 1;
#endif

    return v;
}

unsigned short WORD_GET(unsigned int a)
{
    unsigned short v;

#if (A0_ENABLE == 0)   
    if (a & 1)
    {
        FIO4SET |= 1;
    }
    else
    {
        FIO4CLR |= 1;
    }
   
    //a &= ~1;
#endif
   
    volatile unsigned short *p = (unsigned short*)(0x81000000 + a);
    v = *p;

#if (A0_ENABLE == 0)   
    FIO4CLR |= 1;
#endif
   
    return v;
}



Any feedback appreciated.

Outcomes