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.

Internal flash write for 1 byte data

Other Parts Discussed in Thread: TM4C123GH6PM

Hi 

I am using Tiva C series launchpad board having TM4C123GH6PM controller.

I want to write data of length 1 byte and 2 byte( not multiple of 4) in internal flash that too at some address e.g. 0x3FFFF, 3FFF9 (not multiple of 4). How i can do that ?

I went through the peripheral driver library which has API "FlashProgram"  to write to internal flash. but for this the no of bytes to be written must b multiple of 4 and start address should also be multiple of 4. below is the description taken from peripheral driver library pdf :

 

9.2.2.8 FlashProgram
Programs flash.
Prototype:
int32_t
FlashProgram(uint32_t *pui32Data,
uint32_t ui32Address,
uint32_t ui32Count)
Parameters:
pui32Data is a pointer to the data to be programmed.
ui32Address is the starting address in flash to be programmed. Must be a multiple of four.
ui32Count is the number of bytes to be programmed. Must be a multiple of four.
Description:
This function programs a sequence of words into the on-chip flash. Each word in a page of
flash can only be programmed one time between an erase of that page; programming a word
multiple times results in an unpredictable value in that word of flash.
Because the flash is programmed one word at a time, the starting address and byte count
must both be multiples of four. It is up to the caller to verify the programmed contents, if such
verification is required.
This function does not return until the data has been programmed.
April 11, 2013 99
Flash
Returns:
Returns 0 on success, or -1 if a programming error is encountered.

Please suggest something how i can accomplish writing bytes single bytes(not multiple of 4) at addresses which are not multiple of 4.

Thanx in advance.

  • Straying from such a "well guide-posted" path likely will not play into your, "best interests." 

    You provide no justification for your "escape" from a path long, "proven, and well worn."

    Possibly - you're short of memory - but can the saving of 2 or 3 bytes be justified?  (very hard to imagine)

    You realize that your Flash page must first be "prepared" prior to your directed, Flash Programming.  Might this minimum size page operate against your, "single or dual byte" flash write objective?

    Possibly - you may resolve your issue by "assembling" your 1 or 2 bytes so that they properly reside w/in the 32 bit flash "chunk" - reserved by the function you've listed/identified.  That would be my approach.

    Your foraging - alone, away from the herd - may yield unwanted results - whether your plain be silicon or Serengeti...