AnsweredAssumed Answered

LPC54608 SST25VF016B SPI Flash Issue

Question asked by fatih ozen on Oct 9, 2018
Latest reply on Oct 16, 2018 by fatih ozen

Hello,

 

I have my own custom board and want to use sst25vf016b flash for bootloader. I have some problem about reading and writing. Actually reading.  I checked polarity and phase. In SPI_MasterGetDefaultConfig() function they arranged as spi mode 0 . sst25vf016b supports mode 0 and 3, so I didn't change it.

 

void vInitializeSpiFlash(void){

uint32_t srcFreq = 0;
spi_master_config_t MasterConfig = {0};

CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
RESET_PeripheralReset(kFC2_RST_SHIFT_RSTn);

IOCON->PIO[4][19] = 0x0303;
IOCON->PIO[4][20] = 0x0303;
IOCON->PIO[4][21] = 0x0303;
IOCON->PIO[3][23] = 0x0B01;

IOCON->PIO[3][24] = 0x0300;
SPI_MasterGetDefaultConfig(&MasterConfig);
MasterConfig.sselNum = kSPI_Ssel0;
MasterConfig.sselPol = (spi_spol_t)kSPI_SpolActiveAllLow;
srcFreq = CLOCK_GetFreq(kCLOCK_Flexcomm2);
SPI_MasterInit(SPI2, &MasterConfig, srcFreq);
}

 

Reading jedec id issue:

///////////////////////////////

 

uint32_t E_Flash_Read_JedecID(){
volatile uint8_t a,b,c;
volatile uint32_t d;

SPI_WriteData(SPI2, 0x9F, 0);
a = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, 0);
a = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, 0);
b = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, kSPI_FrameAssert);
c = SPI_ReadData(SPI2);
d = (a<<16) | (b<<8) | (c) ;
return(d);
}

 

When I use this function to read jedec id I see 41ffbf.

 

 

 

///////////////////

uint32_t E_Flash_Read_JedecID(){
volatile uint8_t a,b,c;
volatile uint32_t d;

SPI_WriteData(SPI2, 0x9F, 0);

SPI_WriteData(SPI2, DUMMY_BYTE, 0);
a = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, 0);
a = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, 0);
b = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE, kSPI_FrameAssert);
c = SPI_ReadData(SPI2);
d = (a<<16) | (b<<8) | (c) ;
return(d);
}

 

 

If I use this I see an expected data : bf2541. I just sent dummy data to flash after sending command data.
Anyway, When I want to read status register of flash I use this function. And I see "1c" as expected.

///////////////////////
int16_t E_Flash_Read_Status_Register(){
volatile int16_t pui32Data, dummy;
SPI_WriteData(SPI2, RDSR, 0);
dummy = SPI_ReadData(SPI2);
SPI_WriteData(SPI2, DUMMY_BYTE,kSPI_FrameAssert);
pui32Data = SPI_ReadData(SPI2);
return(pui32Data);
dummy = dummy;
}

 ///////////
When it comes to read both or calling two or more functions, I see meanless datas.

 

E_Flash_Read_JedecID();
n = E_Flash_Read_Status_Register();

 

Eg: When I call these 2 functions I expect to see status register "1c". But I see "41". The last data of jedec id.
Why  that happens ?

Outcomes