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
To get 64 bits from the card to the processor, the card needs to see 64 clocks on the SPI clock line (while the card also sees the slave select signal active).
So how do you get 64 clock ticks on the clock signal? Exactly - by sending 64 bits of dummy data to the card. It is the master that owns the clock signal, and the master must transmit to be able to receive. And it will always receive when it is transmitting.
In this case, you should probably send 8 bytes of 0xff (if the idle state of the data lines are expected to be high) to generate a 64-bit dual-direction transfer. Dummy data to the memory chip and read data from chip to processor.