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
The only non-scope alternative is to have a processor sample the relevant signals There is another, using what I call "the DNA scope". This, however requires full and complete understanding if all aspects of hardware, software and the SPI protocol. (Fortunately rarely) I have had to resort to using "the DNA scope" in situations of locating glitches that were too small to be caught by "the electronic scope".
That said, for a novice in SPI to tackle such without a scope could be used in a commercial for Aspirin
Erik
One transistor and some R/C is OK with you? Actually if you need full Vcc swing you need to amplify it so may it's not so good idea but it will buffer signals.
The 74F series can oscillate with a crystal but the layout is very critical and if not done right can result in the oscillator not starting up or starting up intermittently. Because of this I prefer to use crystal modules at higher frequency's. You could use 74AC or 74ACT at 3.3V if you can find them. Alternatively you could use a transistor but the layout is very critical and it is hard to get reliable start up.
You building an oscilloscope with 74F + crystal???
The Intronix LogicPort 34 port usb logic analyzer was invaluable in dealing with an optically isolated SPI port that took 5 SCK cycles for the /CS line to go low. It ran circles around a scope for SPI work as it would display the Tx and Rx in hex so you could verify the data to and from the device. Well worth the $400.
Otherwise, without a logic analyzer bit bang the SPI using the same pins as the SPI module. See if the boss will approve 4 LED's and a few 100 to 1000 ohm resistors to indicate the states of the SPI wires. The memory chip sheets I have seen don't seem to care how slow you run the SPI.
Chad
I really wanted to thank Per for the help! After a lot of tests it's working now, the problem was with the dummy bytes. Thank you, Per.
Nice :)