Hey
I am stuck with Memory project.
I can read memory ID so SPI communication works.
But when I write a byte and read it back, it comes back invalid.
My code:
I assume that SPI works because "read memory ID" command returns correct values, compared to the ones with Datasheet.
But read always returns the same value and I don't know where the problem is. It might be in write, it might be in read.
I am using PIC18.
I checked SPI read/write order with Datasheet and it's OK:
From the above picture it's not clear what board you're using, but apparently the atmega32u4 microcontroller is being powered with 5v, whereas the SST25VF memory should be powered with the maximum voltage 3.6v.
From the above picture it's not clear what board you're using, but apparently the atmega32u4 microcontroller is being powered with 5v, whereas the SST25VF memory should be powered with the maximum voltage 3.6v.
As you found out, your original setting was wrong. But it's not different for usual flash memories, all are using SPI mode 0/3 as described in the Micron datasheet. Standard mode 0 settings for PIC are CKP = 0, CKE = 1 and SMP = 0.
Mikro C SPI library is slightly confusing things by adding new descriptions for the SPI modes.
Why are you calling your "SPI_INIT" macro (i.e calling the initialisation function) before each operation? That is just a waste of time.
Initialise the SPI peripheral during the overall application setup and then just use it after that.
Susan