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

MCB2300 + SPI serial flash issue

Hello,

I'm trying to use the MCB2300 board (LPC2378) with an external serial flash using SPI (ST M25P80).
First, I used SPI without interrupt and it works without any problem. But LPC2378 SPI has a maximum clock of 9MHz (with a 72MHz master clock). And I would like to use my flash with a faster clock.

So I tried to use the SSP. I didn't manage to use it without interrupt (I never read something although my write signal seems to be good on the scope). Then I tried to use SSP with interrupt. Sometimes I can read and erase some bytes and sometimes not.

Moreover, I tested to use the automatic "SSEL" chip select, set by LPC2378. But it seems to deselect between 2 frames and it's not compatible with my serial flash according to the datasheet. So I tried a manual chip select, with a GPIO, between each instruction. Without any success.

Here is my sequence :

Start
InitSPIMaster(); // initialize the driver
B = SPI_ReadStatus();
SPI_ReadData(0,P1,2); // Read data (2 bytes in P1 array) from address 0
SPI_EraseChip();
SPI_ReadData(0,P1,2); // Read data
SPI_WriteEnable(1); // Enable Writes
SPI_WriteData(0,P0,2); // Write data (2 bytes from P0 array) in address 0
SPI_ReadData(0,P1,2); // Read data
End

Is there something wrong ?

According to me, the SPI initialisation is good, since the 'read status' and 'write' function looks good.

I had to this that I started my work with the 'lpc_ssp.c' and 'lpc_ssp.h' library from C. Strahm (found on web).

Could someone help me please ?

Thank you so much in advance.

Aurelien

Parents
  • Dear Aurelien
    Sorry,here I am not giving you solution on ur problems.
    but u can help me on my SPI communication LPC2378 with dataflash (AT456DB161)</>b.Here I am in trouble from few days.I am not getting data on S0SPDR after simulation.
    Here is my SPI master initalization

    void InitSPI(void)
    {
    
                    PCONP   |= 0x100;
                    PINSEL0  |= 0xC0000000;                 //P0.15    spi pin configuration
                    PINSEL1 |= 0x0000003F;          //P0.16,P0.17,P0.18
    
                    PCLKSEL0 |= 0x00000000;                 //PCLK= CCLK/4
    
    
    
                    IODIR0          = SPI0_SEL;
                    IOSET0  |= 0x4000;
                    IODIR0          = 0x4000;
                    IOSET0  |= 0x800;
    
                    S0SPCCR  |= 0xA5;
                    //S0SPCCR        |= 0xA8;                          // spi bus frequency
    
    
                    S0SPCR  |= 0x20;                                //CPH = 0, CPOL = 0
    
    
    

    Here I am writing on SPI (S0SPDR register)

    void WrToflash(unsigned int BaseAdd,unsigned char size,unsigned char *buffAdd1)
    {
            unsigned char k;
            unsigned char u32dummyData;
            for (k=0;k<size; k++)
            {
                    IOCLR0           |= 0x4000;
    
    
    
                    S0SPDR   = 0x87;
                    while (!(S0SPSR & SPIF));
                    u32dummyData    = S0SPDR;
    
                    S0SPDR = (BaseAdd>>8) & 0xFF;
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    Delay(1000);
                    S0SPDR = BaseAdd & 0xFF;
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    BaseAdd++;
    
                    S0SPDR = buffAdd1[k];
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    IOSET0 |= 0x4000;
            }
    }
    
    

    Here I am reading from SPI (S0SPDR register)

    
    void RdFromflash(unsigned int BaseAdd2,unsigned char size2,unsigned char *buffAdd2)
    {
            unsigned char j;
            unsigned char u32dummyData2;
    
            IOCLR0 |= 0x4000;
    
            S0SPDR = 0xD6;                  //opcode for rading flash location
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
            S0SPDR = (BaseAdd2>>8) & 0xFF;
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
            S0SPDR = BaseAdd2 & 0xFF;
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
    
            for (j=0;j<size2;j++)
            {
                    Delay(1000);
                    S0SPDR = 0;                     //Dummy write
                    while (!(S0SPSR & SPIF));
                    buffAdd2[j] = S0SPDR;
            }
            IOSET0 |= 0x4000;
    
    }
    

    Here what happen I observed status on simulator.
    all SPI register i observed all all modify according to my settings except datar egister(S0SPDR), when I observed S0SPDR during writing data,i am writing 0x87 but it is not modify,it only showing 0x00.at that time my SPI transfer flag bit is set.
    so Is my (desired)data transfer is completed,if completed what value it is transfer?

    At the time of reading I am getting 0xFF on my hyperterminal.so what will be exect issue?

    Plz help me regarding this issue.and you can.because you are allready done these things.
    you can send your code on my mail ID
    shyam_tayade@rediffmail.com

    wating for your positive reply.....

    regards
    Shyam T.
    Pune India

Reply
  • Dear Aurelien
    Sorry,here I am not giving you solution on ur problems.
    but u can help me on my SPI communication LPC2378 with dataflash (AT456DB161)</>b.Here I am in trouble from few days.I am not getting data on S0SPDR after simulation.
    Here is my SPI master initalization

    void InitSPI(void)
    {
    
                    PCONP   |= 0x100;
                    PINSEL0  |= 0xC0000000;                 //P0.15    spi pin configuration
                    PINSEL1 |= 0x0000003F;          //P0.16,P0.17,P0.18
    
                    PCLKSEL0 |= 0x00000000;                 //PCLK= CCLK/4
    
    
    
                    IODIR0          = SPI0_SEL;
                    IOSET0  |= 0x4000;
                    IODIR0          = 0x4000;
                    IOSET0  |= 0x800;
    
                    S0SPCCR  |= 0xA5;
                    //S0SPCCR        |= 0xA8;                          // spi bus frequency
    
    
                    S0SPCR  |= 0x20;                                //CPH = 0, CPOL = 0
    
    
    

    Here I am writing on SPI (S0SPDR register)

    void WrToflash(unsigned int BaseAdd,unsigned char size,unsigned char *buffAdd1)
    {
            unsigned char k;
            unsigned char u32dummyData;
            for (k=0;k<size; k++)
            {
                    IOCLR0           |= 0x4000;
    
    
    
                    S0SPDR   = 0x87;
                    while (!(S0SPSR & SPIF));
                    u32dummyData    = S0SPDR;
    
                    S0SPDR = (BaseAdd>>8) & 0xFF;
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    Delay(1000);
                    S0SPDR = BaseAdd & 0xFF;
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    BaseAdd++;
    
                    S0SPDR = buffAdd1[k];
                    while (!(S0SPSR & SPIF));
                    u32dummyData = S0SPDR;
    
                    IOSET0 |= 0x4000;
            }
    }
    
    

    Here I am reading from SPI (S0SPDR register)

    
    void RdFromflash(unsigned int BaseAdd2,unsigned char size2,unsigned char *buffAdd2)
    {
            unsigned char j;
            unsigned char u32dummyData2;
    
            IOCLR0 |= 0x4000;
    
            S0SPDR = 0xD6;                  //opcode for rading flash location
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
            S0SPDR = (BaseAdd2>>8) & 0xFF;
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
            S0SPDR = BaseAdd2 & 0xFF;
            while (!(S0SPSR & SPIF));
            u32dummyData2 = S0SPDR;
    
    
            for (j=0;j<size2;j++)
            {
                    Delay(1000);
                    S0SPDR = 0;                     //Dummy write
                    while (!(S0SPSR & SPIF));
                    buffAdd2[j] = S0SPDR;
            }
            IOSET0 |= 0x4000;
    
    }
    

    Here what happen I observed status on simulator.
    all SPI register i observed all all modify according to my settings except datar egister(S0SPDR), when I observed S0SPDR during writing data,i am writing 0x87 but it is not modify,it only showing 0x00.at that time my SPI transfer flag bit is set.
    so Is my (desired)data transfer is completed,if completed what value it is transfer?

    At the time of reading I am getting 0xFF on my hyperterminal.so what will be exect issue?

    Plz help me regarding this issue.and you can.because you are allready done these things.
    you can send your code on my mail ID
    shyam_tayade@rediffmail.com

    wating for your positive reply.....

    regards
    Shyam T.
    Pune India

Children