SPI - External storage


#1

Hi to all,

I want to write datas in external storage through SPI1. I used the sample code which is in OpenAT. But I can’t read & write in it. The below are my SPI bus settings,

adl_busSPISettings_t MySPIConfig =
{
	9,                          // use 1.3MHZ clock speed  112
	ADL_BUS_SPI_CLK_MODE_1,     // Mode 0 clock
	ADL_BUS_SPI_ADDR_CS_GPIO,   // Use a GPIO to handle the Chip Select signal
	ADL_BUS_SPI_CS_POL_LOW,     // Chip Select active in low state
	ADL_BUS_SPI_MSB_FIRST,      // Data are sent MSB first
	ADL_IO_GPIO | 31,           // Use GPIO 35 to handle the Chip Select signal
	ADL_BUS_SPI_FRAME_HANDLING,    // LOAD signal not used
	ADL_BUS_SPI_DATA_UNIDIR,    // 3 Wires configuration
	ADL_BUS_SPI_MASTER_MODE,    // Master mode
	ADL_BUS_SPI_BUSY_UNUSED		// BUSY Signal Used
};

Is there anyone succeed it before. Thanks in Advance.

Regards - Senthil.


#2

have you tried measuring the CS signal to see that it really does what you expect it to do?


#3

Hiya,

SPI can be tricky. Have you got a CRO (oscilloscope) to watch the SPI I/O lines? By preference, a four channel CRO is appropriate - you really need to watch CS, SCK, SDI and SDO. Trigger off CS going negative, then manually decode the first few bytes so you know what’s being sent by the Q26 and what’s being returned by the external storage.

Blindly using the settings from the ADL example can be a trap.

Do you know what mode your SPI external memory chip uses? SPI can be set to one of four different modes.

Have you got the hardware set up properly? SCK goes to SCK, but Q26 SDI goes to Memory SDO; Q26 SDO goes to Memory SDI… As Madouc said, check that your CS line is correct. In my experience, Flash chips are selected when CS is LOW - but check your datasheet to ensure that this is the case.

Software: Check your Mode, and that you are using the correct GPIO for CS (your code indicates you are using GPIO 31, the comment says GPIO 35. Which is correct?). Have you set up a adl_busAccess_t structure correctly?

Write a short program to simply try and read the status register of your Flash Chip. Watch the transfer on the CRO.

Really, get hold of a CRO and watch the hardware I/O pins. It’s the only way to get this right…

ciao, Dave


#4

Thanks for ur reply David,

I checked the following things using CRO & my observations are,

  • CS is low
  • when I wrote data, I watched the datalines which is toggled. But when I read data, no changes in scope.
  • I used GPIO31 - SPI 1 in my datasheet.
  • I checked the hardware connection as you mentioned by using my datasheet. Everything is correct.

If you have any sample code for SPI read/write, could you send it to me. I think It is helpful to identify software issues :slight_smile:

Thanks in Advace.

Regards - Senthil.


#5

There is an example already included in the SDK!