Jump to content
lilyhack

How to store data in TM4C

Recommended Posts

I am building a control system (TM4C129/123) that generates many data. These data are sent back to a higher level controller (Raspberry Pi) through ZigBee.

 

Now, instead of TI always sending the data, I want to change the system so that when Raspberry Pi request data, only then TI sends data. So that means storing those data until the data request come. The data can be lost after the power off. 

 

How do I do that? I understand there is a limit to how long we can store the data depending on the size of the data. 

Share this post


Link to post
Share on other sites

You could also use some kind of external storage.

 

If the data isn't too much you could store in an external eeprom chip. I2c or spi. Alternatively you could use an sd card.

Share this post


Link to post
Share on other sites

You can use internal EEPROM or the flash.

The TM4C1294 should have more than enough flash, and the tm4c123 should be enough depending on your code size and data size.

Share this post


Link to post
Share on other sites

Note that the EEPROM is kinda small compared to the flash.

The TM4C123 has 2KB and the TM4C1294 has 6KB.

You access it in blocks of 16 word.

There is probably a example in Tivaware.

Here is how I enable it:
 

	bool eeprom_good = false;
	if(!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
	{
		SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
		while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0)));
	}
	if(EEPROMInit() == EEPROM_INIT_OK)
	{
		eeprom_good = true;
	}
	return(eeprom_good);

How I read it:
 

	uint32_t temp;
	EEPROMRead(&temp, address, 4);
	return temp;

And how I write into it:
 

	uint32_t	temp;
	uint32_t	result;
	temp = value;
	result = EEPROMProgram(&temp,address,4);
	return(result);

Share this post


Link to post
Share on other sites

btw, using the flash should be easy.

The problem is you have to erase an entire block to write it.
The TM4C123 has blocks 1KB and the TM4C1294 is of 16KB. 

So you can for example simply erase an entire block and then write 1 word (or just byte? I don't remember how specific you can write) as data arrives. Since you erased the entire block you can do that.
Problem is, if you want to go back and start over the block, or change a value, you have to erase the entire block! Just be aware if you end up using flash

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...