This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 interfacing with External SPI eeprom M95-m02 (ST micro)

Other Parts Discussed in Thread: MSP430F5419A

Hi all,

I am trying to interface my MSP430F5419A with M95-M02 (SPI based external EEPROM from ST micro). I don't have much experience in SPI. I have just followed few links on the web and trying to read and write the data. But I want to know the flow of code for this SPI IC first. I have pointed out the flow. Can you please tell me is it true ?

1) Initiliaze SPI first.
2) To Send dummy data in spi tx buff and recieve the same in rx buff
3) Then Write data to memory (16 bit addr 8 bit data 0xa0). Each and every byte is echoed in rx buff
4) Then Read memory by sending dummy data 0x00.

Nikunj

  • This doesn't sound exactly right.

    Sure, first step is to initialize SPI module, then you must chip-select the SPI slave (this is done by any software-controlled GPIO line).
    What comes next, depends on the SPI slave. Usually, you send a command first, because else the slave doesn't know what to do. Or an address, or (as it seems to be by your description) a combination of both.

    Note that SPI is synchronous bi-directional. You always receive something when you send (even if no-one is sending, you'll receive dummy FF bytes), and when you receive, you'll also send (even if it is an idle line). In fact, sending a dummy byte (0xff equals an idle line - there is no difference electrically) is required to receive anything, as the sending process triggers the clock generation. (in MSP430 USCI module, that is)

    Also not that when you send something, you cannot immediately receive an answer to (or echo of) the command you're sending. Because you receive while the command hasn't been completely sent yet. Command and answer/echo are interleaved.

    An exception is the single-line SPI, where sending and receiving happens on the same line. This is strictly spoken no SPI and it is difficult to implement on 'real' SPI hardware, as the direction of the signal flow changes, and therefore the port configuration must be changed in time, to avoid multiple outputs speaking at the same time. But this isn't true in your case.

    To read from memory, the sequence is:
    - Set chip select line low
    - send READ command (0x03) (you'll receive dummy data during this - since input and output are high-impedance, it may be anything, including a crosstalk echo of the sent data)
    - send 24 bit start address of read transfer (you'll also receive dummy data)
    - send any number of dummy bytes(any value will do)  to receive any number of subsequent memory content bytes (reading continues at address 0x00000 after 0x3ffff has been read)
    - set chip select line high again.

    Write is similar, but command is 0x02 and a write enable command must be sent before.


  • Hi,

    Is there a working driver for this device ? would you please share the source code ? Thanks.

    -S

**Attention** This is a public forum