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
You are not showing where you are setting your SSEL-signal in relation to your reads and writes. Is it in SPI_ReadData() and SPI_WriteData()?
I have been using the SSP and I had to drive the SSEL signal as GPIO since the automatic drive did not correspond with my needs.
Are you waiting until the SSP device is idle before deselecting SSEL? Note that the SSP has a FIFO so you can write multiple bytes to it that it will then continue to send as fast as it can.
But with this as with most other problems relating communication: Have you looked at the signaling with an oscilloscope? Based on the oscilloscope view: - what did you expect to happen? - what did happen? - what was the exact code involved?
Thank you so much for replying quickly !
First of all, I use an ascilloscope to check every signal. I tested a lot of cases : - with automatic drive by SSEL or with manual drive with a GPIO. - with a polling of the slave's status register prior to send each command/ with the same polling but after each command / with no polling.
The interesting information is : - with auto drived SSEL , I managed to read the status register or send short commands like 'erase'. But when I send long commands (more than 5 bytes), the SSEL sometimes deselect between 2 bytes. I think this is why the behaviour wasn't stable.
Yesterday I start again with a new, easier and clearer code. I used a GPIO to drive manually the chip select. I finally succeed in writing, reading and erasing some bytes. Now I need to improve my code to allow it to support bigger data and with an higher speed.
But it remains a question concerning the auto drived SSEL. According to the lpcxx user manual, 'For continuous back-to-back transmissions, the SSEL pins remains in its active LOW state, until the final bit of the last word has been captured, and then returns to its idle state'. I can't find how and why this signal is switching alhough it shouldn't.
Thank you again for helping me and hope my work will help somebone else !