Hi all,
I am trying to read and write from SM28VLT32 bare-die memory Via SPI communication, and I am using Arduino Uno for that. Following the datasheet, timing diagrams and the command codes that are given in datasheet, I modified the available SM28VLT32 API to suit with Arduino.
I am getting always 0 when I am trying to read from the memory whether its a quick status register or normal read operation. I have copied the write and read APIs here for reference. Any help and suggestions are welcome.
I am trying to write 0x1212 at address 0x00000100.
void FRAM_Write(uint32_t FRAM_address, uint16_t FRAM_data)
{
uint16_t error ;
// F-RAM WRITE OPERATION
digitalWrite(CS,LOW); //chip select
SPI.transfer(WRITE); //transmit write opcode 0x17
SPI.transfer(MSB_ADDR_BYTE(FRAM_address)); //send MSByte address first
SPI.transfer(MSB2_ADDR_BYTE(FRAM_address)); //send MSByte2 address middle
SPI.transfer(LSB_ADDR_BYTE(FRAM_address)); //send LSByte address
SPI.transfer((uint8_t)MSB_DATA_BYTE(FRAM_data)); //send MSB data
SPI.transfer((uint8_t)LSB_DATA_BYTE(FRAM_data)); //send 1 byte data
SPI.transfer(0); //dummy byte
digitalWrite(CS,HIGH); //release chip, signal end of transfer
// Send 0xFF to get Quick status
error = Flash_SendFF();
// If SPI frame error or Invalid data or Command Error , return
if(((uint8_t)error & FLASH_QS_COMMAND_ERROR) ||
((uint8_t)error & FLASH_QS_INVALID_DATA_ERROR) ||
((uint8_t)error & FLASH_QS_SPI_FRAME_ERROR))
{
Serial.print("\n error in code is \t");
Serial.print(error, HEX);
}
// Poll till Write busy bit is reset
while((uint8_t)error & FLASH_QS_WRITE_BUSY)
{
error = Flash_SendFF();
}
// error status comes only after Write busy bit is reset
error = Flash_SendFF();
Serial.print("\nQuick register status after writing is \t");
Serial.print(error, HEX);
}
uint16_t FRAM_SPI_Read(uint32_t FRAM_address)
{
uint16_t data;
uint16_t error;
//FRAM READ OPERATION
digitalWrite(CS,LOW); //chip select
SPI.transfer(READ); //transmit read opcode 0x15
SPI.transfer(MSB_ADDR_BYTE(FRAM_address)); //send MSByte address first
SPI.transfer(MSB2_ADDR_BYTE(FRAM_address)); //send MSByte2 address first
SPI.transfer(LSB_ADDR_BYTE(FRAM_address)); //send LSByte address
SPI.transfer(0); //dummy byte
// Data byte on SO - MSB
data = SPI.transfer(0);
data = data << 8;
//Data byte on SO - LSB
data |= SPI.transfer(0); //get data byte from F-RAM
digitalWrite(CS,HIGH); //release chip, signal end of transfer
// Send 0xFF to get Quick status
error = Flash_SendFF();
// If SPI frame error or Invalid data or Command Error , return
if(((uint8_t)error & FLASH_QS_COMMAND_ERROR) ||
((uint8_t)error & FLASH_QS_INVALID_DATA_ERROR) ||
((uint8_t)error & FLASH_QS_SPI_FRAME_ERROR))
{
Serial.print("\n error in code is \t");
Serial.print(error, HEX);
return error;
}
// error = Flash_SendFF();
Serial.print("\nQuick register status after reading is \t");
Serial.print(error, HEX);
return data; // Return data byte
}
Thanks and regards,
Sohail