Small RAM footpring flash erase / write routines for S08PA4 S08PA16 etc

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Small RAM footpring flash erase / write routines for S08PA4 S08PA16 etc

753 Views
carlnormansuret
Contributor V

Hi All,

 

I am revisiting a very old project which needs updating to a more available processor (SH4 to PA4). Seems the flash changes quite a bit. I have some great ultra small RAM footprint flash erase / write code (attached) which has been used in production for years on hundreds of thousands of units, feel free to use it (it has been used on hundreds of thousands of units for many years without issue).

 

Has anyone got similar code that will work on PA4 (or similar family)? Or can you easily touch my code to make it work? This code works on every other processor I have used in this family, and works well. I did see some other posts but nothing complete and working. Obviously I can work through it, but if someone already has done the work it will save me a day of doing it myself, and its Christmas time

 

Would be nice if freescale adapted this type of code I have attached as a "standard" for their documentation as its far more practical than the cumbersome and selfish code they supply in their examples.

Original Attachment has been moved to: flash.h.zip

Original Attachment has been moved to: flash.c.zip

Labels (1)
0 Kudos
4 Replies

464 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Carl

Please check the application note

AN4570

Understanding S08P Flash and EEPROM

It can help you to migrate your code.

Regards

Vicente Gomez

0 Kudos

464 Views
carlnormansuret
Contributor V

Thanks, I was hoping not to have to re design my code or rework it. These really are fundamental routines and should not need to be written by every engineer who wants to read / write to flash/eeprom and NOT use the entire RAM memory as in the freescale examples. Surely someone in the community is willing to share some simple low RAM usage read / write flash/EEPROM routines?

0 Kudos

464 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Please check the TWR-S08PT60 Labs

There is a sample code for read and write on flash and eeprom

Regards

Vicente Gomez

0 Kudos

464 Views
carlnormansuret
Contributor V

Ok, so I used the application note to get flash erase / write working...

Just to write a long word (which is the least you can do now which is also annoying in itself as these are small processors its common to want to write a single byte, then, later write another byte straight after that byte), anyway, I compiled the code and it takes 80 bytes of RAM to program one long word. This processor only has 512 bytes of RAM.

The example I supplied in my first post only uses 8 bytes of RAM. So when someone gets time at freescale maybe have a look at my code and do it this way for future...? Making a 512 byte RAM processor then expecting us to allocate 80 of those bytes to write a byte to flash is a bit silly. For this project I can get away with the 80 bytes, but im sure people have had to, or, will have to make it happen in less.

And by the way, the application note has two mistakes in it:

1. There are no defines for the flash commands you have to go and manually work out what they are, and they are no descibed the same, maybe include references when you give examples, I added these two for the example as that is all I am using, not sure if they are correct, I have not tested my code yet:

#define FLASH_CMD_ERASE_SECTOR 0x0A

#define FLASH_CMD_PROGRAM 0x06

2. You need to add the arrays for reference, lucky I realised i had old code like this, but it took 15 minutes to work out why it would not work...

extern char __SEG_START_FLASH_ROUTINES[];      //Used for copying code to RAM

extern char __SEG_SIZE_FLASH_ROUTINES[];       //Used for copying code to RAM

0 Kudos