Electronic – Which SPI mode to use

cc18picspisram

I'm interfacing a 23LC1024 SPI Serial SRAM with a PIC18, using the C18 compiler and the built-in functions from <spi.h> as described in the Compiler Libraries, section 2.8:

OpenSPI1 – Initialize the SSPx module.

void OpenSPI1(  
    unsigned char sync_mode, 
    unsigned char bus_mode, 
    unsigned char smp_phase);

For bus_mode, I can choose one of the following modes:

  • MODE_00 – data is read on the clock's rising edge (idle to active clock state)
  • MODE_01 – data is read on the clock's falling edge (active to idle clock state)
  • MODE_10 – data is read on the clock's falling edge (idle to active clock state)
  • MODE_11 – data is read on the clock's rising edge (active to idle clock state)

I can't find in the datasheet of the 23LC1024 what mode I should use. Doesn't it matter? Or is there a standard assumed?

Best Answer

This figure in the SRAM datasheet shows that the chip reads the data on the rising edge of the clock.

enter image description here

That corresponds to two of your options, I guess the choice between the two is the edge on which the chip changes its output data. The figure below shows that it does so after the falling edge, hence your micrcontroller should read the bit 'on' the rising edge.

enter image description here

There are other SPI configuration aspects, that have to do with the CS line.