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

SSP1 Problem - Serial Mem. Communication

Hi u all!

I'm facing a problem here, I'm trying to develop a serial flash memory interface here.
The memory is M25P128, and I'm using LPC2368.

The thing is..I don't have much experience with SPI/SSP.
Well.. I've downloaded some examples but I couldn't establish the communication appropriately.
Ideally I should have an oscilloscope to check all this, but..

The following code just try to request from the memory its status register:

int InitSSP()
{
        PCONP = 1<<10;
        PINSEL0 = 0xA8000;
        PINMODE0 = 0xA8000;// Here is my first doubt, the pins should be configured with pull-up or not?

        //INTERRUPT
        VICVectAddr11 = (unsigned long) SSP_Isr;
        VICVectCntl11 = 0;
        VICIntEnable |= 0x800; // 11th bit is the SSP1

        FIO2DIR1 = (1<<3); //SS Pin - configured as output

        SSP1CR1 = 0;//SSP disable
        SSP1CR0 = 0x07;
        SSP1CPSR= 10;
        SSP1IMSC = 3;//Receives int
        SSP1CR1 = 2;

}

void SSP_Isr(void) __irq
{
        spiBuf[0] = SSP1DR;
        VICVectAddr = 0; // reset VIC
        FIO2PIN1  = 1<<3;//HIGH
}

int WriteFlash()//Adress, Data, size
{

    FIO2PIN1  = 1<<3;     //HIGH
    FIO2PIN1  = 0<<3;     //LOW

    SSP1DR = 0x05; //Instrução WREN
    while (!(SSP1SR & SSPSR_BSY));

    //FIO2PIN1  = 1<<3;   //HIGH - In this test I set the High signal in the interruption method because it should be set after receive the message from the memory

}

The problem is, doesn't matter which instruction I send I still receive answers that doesn't make any sense! And should be just a few specific instructions that the memory should answer back.

thanks

0