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

LPC2148 and FM25L512 memory, using SPI protocol

Hello

I have a device based on LPC2148 microcontroller with FM25L512 memory, connected to the SPI0 on microcontroller. I'm trying to use SPI example downloaded from nxp.com. Here is the code:

DWORD SPIInit( void )
{
    TxCounter = 0;

    S0SPCR = 0x00;
    PINSEL0 &= 0xFFFF00FF;
    PINSEL0 |= 0x00001500;
    IODIR0 = SPI0_SEL;
    IOSET0 = SPI0_SEL;

    S0SPCCR = 0x8;
    S0SPCR = SPI0_MSTR;
    return( TRUE );
}

BYTE SPIReceiveByte( void )
{
    BYTE data;

    S0SPDR = 0xFF;
    while ( !(S0SPSR & SPIF) );
    data = S0SPDR;
    return ( data );
}


The problem is that in SPIReveiceByte data variable is always set to 0xFF, whatever commands I send to the memory. Even when I change the dummy assignment ( S0SPDR = 0xFF;) to some else value - the result is 0xFF.

P.S. I have the same device with LPC2368 instead of 2148, and the same program based on the SPI examples from the nxp.com - it works.

May be somebody suggest something? Thank you

0