I have to establish a file transfer mode between C# and CCS. To make sure the text files has transferred properly, after sending a file I read it from C# to compare with the origin.

I need to look at the flash memory content all the time for these reasons:

  1. I get different results of writing to specific memory segments, for instance: if I start writing at 0x20000, some characters distord, but if I start at 0x20008, everything works OK then, 0x20016 half OK half garbage, etc..
  2. Even with the Non-problems mode (0x20008) just the transferring the first file works fine, if I send another file and try to read it then, all I get is just garbage.

This photo if anyone would like to see the writing/reading procedure code:

enter image description here

  • 1
    \$\begingroup\$ I think you can just use the memory browser in CCS. Run your program then load the memory browser "view->memory browser". You should be able to type in the address you want hit enter and it will show you the contents. \$\endgroup\$ Commented Aug 6, 2014 at 17:31

1 Answer 1


I believe the distortion you see may be because you don't erase the flash before programming it again.

You are using the WRITE bit but you must have a piece of code that uses ERASE bit set to erase the block.

With flash you must erase everything as a block before writing. This is the number one issue I see when helping customers do over the air updates and firmware updates.

The other reason is that the data didn't arrive properly for whatever reason.

  • \$\begingroup\$ I guess I do erase the block but not sure if it is the right way, in main I have this: FCTL1 = FWKEY+ERASE; *(unsigned int *)Flash_ptr = 0; \$\endgroup\$ Commented Aug 7, 2014 at 9:36
  • \$\begingroup\$ if I do the erasing operation after clearing the lock bit and before setting the WRT bit, I still have the same problem even worse, ALL THE TIME GARBAGE :) \$\endgroup\$ Commented Aug 7, 2014 at 9:58
  • \$\begingroup\$ Post the code you have now so we can see. You need to erase, then write. \$\endgroup\$ Commented Aug 7, 2014 at 17:11
  • \$\begingroup\$ Gustavo, How I am supposed to erase the segment? I guess I don't erase anything, cuz I tried just to erase and not to write anything but nothing has been deleted! Here is the steps: Firstly, before main: char * Flash_ptr = (char *) 0x30000; and then I implement the deletion in main (so that the deletion would be executed just once): FCTL1 = FWKEY+ERASE; *(unsigned int *)Flash_ptr = 0; while(!(WAIT & FCTL3)); am I missing something? \$\endgroup\$ Commented Aug 7, 2014 at 17:39
  • \$\begingroup\$ That looks good but make sure the pointer address is good. Then check in the memory window and all the bytes should be at 0xFF in the segment that was erased. \$\endgroup\$ Commented Aug 8, 2014 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.