This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129XNCZAD: Not able to read more than 256 byte from flash

Part Number: TM4C129XNCZAD


Dear Sir,

We are using TM4C129XCNZAD interface with Macronix 512MB flash.

We are able to read and write data  less than 256 but not able to read data more than 256.

We are writing structure to the flash and read flash to again fill the structure.

If data length is less than 256  function working fine but more than 256 reading 0 value.

//*****************************************************************************
//
// This function write data to SSI External Flash 
//
//*****************************************************************************
void SSIFlashWrite(uint32_t ulAddress, uint32_t ulLen,uint8_t *pucData)
{
	uint32_t ui32Index;
	uint8_t*ucData;
	uint32_t ulLength;
	
	ucData=pucData;
	ulLength=ulLen;
	
	SSILibSendPageProgram(SSI3_BASE,ulAddress,INS_PAGE_PROGRAM);
		
	for(ui32Index=0;ui32Index<ulLength;ui32Index++)
	{
			SSIDataPut(SSI3_BASE,ucData[ui32Index]);
			pui32DataTx[ui32Index]=ucData[ui32Index];
	}
		
		SSIAdvDataPutFrameEnd(SSI3_BASE,ucData[ulLength]);

}

//*****************************************************************************
//
// This function read data from SSI External Flash 
//
//*****************************************************************************
void SSIFlashRead(uint32_t ulAddress1, uint32_t ulLen1,uint8_t *puc1Data)
{
	uint32_t ui32Index;
	uint32_t ulAddress;
	uint8_t*ucData;
	uint32_t ulLength;
	
	ucData=puc1Data;
	ulLength=ulLen1;
	ulAddress=ulAddress1;
	
	
	SSILibSendReadDataAdvBi(SSI3_BASE,ulAddress,INS_READ_DATA);
	
	for(ui32Index=0;ui32Index<ulLength;ui32Index++)
	{
		
		SSIDataPut(SSI3_BASE,DUMMY_BYTE);
		SSIDataGet(SSI3_BASE,&pui32DataRx[ui32Index]);
		ucData[ui32Index] = pui32DataRx[ui32Index];
	}
	
	SSIAdvDataPutFrameEnd(SSI3_BASE,DUMMY_BYTE);
//  SSIDataGet(SSI3_BASE,&pui32DataRx[ui32Index]);
//	ucData[ui32Index] = pui32DataRx[ui32Index];	
	
}


/*****************************************************************************
//
// This function read Meter from SSI External Flash 
//
//*****************************************************************************	
void Meter_Data_read(void)	
{
    SSIFlashRead(0, DATA_LENGTH, (unsigned char *)(&Meter_data.First_boot));  

}

//*****************************************************************************
//
// This function write Meter data to SSI External Flash 
//
//*****************************************************************************	
void Meter_Data_write(void)
{
	SSILibSendEraseCommand(SSI3_BASE,0,INS_SECTOR_ERASE_4KB);
	SSIFlashWrite(0, DATA_LENGTH, (unsigned char *)(&Meter_data.First_boot));
	
}	




My structure

_packed struct Stored_Meter_data
{
	unsigned char First_boot;						//1		 //0
	float software_ver;								//4		 //1-4
	float hardware_ver;								//4		 //5-8
	unsigned int database_log_cnt;					//4		 //9-12
	unsigned char database_log_ov;					//1		 //13
	char Device_serial_no[11];						//11	 //14-24
	float PTRatio;									//4	 	 //25-28	
	float CTRatio;									//4		 //29-32
	char Port_no[6];								//5		 //33-38
	char ip_buffer[16];								//16	 //39-54
	char null_ip_position;							//1		 //55
	char port_position;								//1		 //56
	unsigned int total_log_cnt;						//4		 //57
	unsigned int reg_database_log_ov;			    //4		 //61
	unsigned int reg_log_cnt;						//4      //65
	unsigned char lattitude[10];					//10 	 //69
	unsigned char longitude[10];					//10     //79
	char lattitude_position;						//1      //89
	char longitude_position;                         //1     //90
	unsigned char E_key[16];						//16	 //91-106
	unsigned char A_key[16];						//16	 //107-122
	unsigned char D_key[16];					   //16		 //123-138
	unsigned char S_Title[8];					   //8		 //139-146
	unsigned char S_T[20];						   //20     //147-166 			
	unsigned char EKey0[20];					   //20		//167-186
	unsigned char EKey1[20];					   //20		//187-206
	unsigned char AKey0[20];					   //20		//207-226
	unsigned char AKey1[20];					   //20		//227-246
	unsigned char DKey0[20];					   //20		//247-266
	unsigned char DKey1[20];					   //20		//267-286

}Meter_data;	//-------------------------->>287






Attaching file for  flash read  and write function .

Also show structure which are to be written to flash.

  • Which Macronix device are you using?

    The data sheet for the MX25L51245G (PM2006 Rev 1.7) Sec 9-31 says that it has a 256-byte page size so dealing with something >256 Bytes requires breaking it up into (a) <= 256-byte transactions (b) with addresses aligned to 256 bytes. Item (b) might require you to read/modify/write a given page.

    [Edit: You don't need a RMW. I was thinking of NAND flash.]

  • Dear sir,

    We are using the same part no. Which come alongwith the TM4C129x devlopment board.

    MX66L51235FZ2I-10G

  • The MX66L51235FZ2I-10G data sheet (PM1832 Rev 1.1) Section 9-26 appears to say the same thing (maybe even the same words).

    If you have a choice, you'll probably make your life easier by assigning your structure a (Flash) address which is a multiple of 256, and just writing it as two consecutive pages (page N then (N+1), with a wait for completion in between).

    If you're writing an array of these structures, you might consider rounding-up such that each structure occupies (all of) two consecutive pages -- this would waste some space, which may or may not be a big deal.

    If this chip came on a TI-supplied board, maybe (?) they offer some sample code to do some of this.

  • If this chip came on a TI-supplied board, maybe (?) they offer some sample code to do some of this.

    Looking in TivaWare_C_Series-2.2.0.295 there are:

    1. Driver files TivaWare_C_Series-2.2.0.295/examples/boards/dk-tm4c129x/drivers/mx66l51235f.h and TivaWare_C_Series-2.2.0.295/examples/boards/dk-tm4c129x/drivers/mx66l51235f.c
    2. TivaWare_C_Series-2.2.0.295/examples/boards/dk-tm4c129x/usb_dev_msc example which makes use of the driver
  • Thanks.

    It looks like it has the same limitation, though. For MX66L51235FPageProgram:

    //! This function programs data into the MX66L51235F.  This function will not
    //! return until the data has be programmed.  The addresses to be programmed
    //! must not span a 256-byte boundary (in other words, ``\e ui32Addr & ~255''
    //! must be the same as ``(\e ui32Addr + \e ui32Count) & ~255'').