I'm using two different SPI Flash memories with a TM4C129X. Same problem with both chips. I want to read, erase and write the whole chips in bulk.
I have some problems with the SPI it seems. I suspect it's a /CS signal problem. Flash command, Address and Datavector, needs to be read/written in one frame while /CS is contiguously low.
At the face of it writing the memories work (unverified!) but reading fails (at the comment below). Here is the code just a little simplified. SPI data width is set to 8-bits with SSIConfigSetExpClk()
// ******** erase the memory *********
// wait while busy
do {
SSIDataPut(DISPLAYFLASH_SSI, WB_RD_STATUSREG1);
SSIDataGet(DISPLAYFLASH_SSI, &status1);
}
while(status1 & 0x01);
// erase the whole chip
SSIDataPut(DISPLAYFLASH_SSI, WB_WREN);
SSIDataPut(DISPLAYFLASH_SSI, WB_CHIP_ERASE);
// ******** write the memory *********
SSIAdvModeSet(ssi_base, SSI_ADV_MODE_READ_WRITE);
// wait while busy
do {
SSIDataPut(DISPLAYFLASH_SSI, WB_RD_STATUSREG1);
SSIDataGet(DISPLAYFLASH_SSI, &status1);
}
while(status1 & 0x01);
SSIAdvFrameHoldEnable(ssi_base);
// write flash command
SSIDataPut(DISPLAYFLASH_SSI, WB_WREN)
SSIDataPut(DISPLAYFLASH_SSI, WB_PAGE_PRG);
// write 24-bit address
SSIDataPut(ssibase, addr1);
SSIDataPut(ssibase, addr2);
SSIDataPut(ssibase, addr3);
// write data
while(--putcount_minusone) {
SSIDataPut(ssi_base, (uint32_t)*dptr8++);
}
SSIAdvDataPutFrameEnd(ssi_base, (uint32_t)*dptr8);
SSIAdvFrameHoldDisable(ssi_base);
SSIAdvModeSet(ssi_base, SSI_ADV_MODE_LEGACY);
// ******** read the memory *********
SSIAdvModeSet(ssi_base, SSI_ADV_MODE_READ_WRITE);
// wait while busy
do {
SSIDataPut(DISPLAYFLASH_SSI, WB_RD_STATUSREG1);
SSIDataGet(DISPLAYFLASH_SSI, &status1);
}
while(status1 & 0x01);
SSIAdvFrameHoldEnable(ssi_base);
// write flash command
SSIDataPut(DISPLAYFLASH_SSI, WB_RD);
// write 24 bit address
SSIDataPut(ssibase, addr1);
SSIDataPut(ssibase, addr2);
SSIDataPut(ssibase, addr3);
// read data
while(getcount--) {
SSIDataGet(ssibase, &data32); /* <------------ SSIDataGet() does not return (blocks) on the fifth loop count --------------- */
*dptr8++ = (uint8_t)data32;
}
SSIAdvFrameHoldDisable(ssi_base);
SSIAdvModeSet(ssi_base, SSI_ADV_MODE_LEGACY);
