MC9S08JM16CGT flash memory

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

MC9S08JM16CGT flash memory

Jump to solution
971 Views
russianspy1234
Contributor I

Hi, I am writing an application for this microprocessor and I have come to a point where I need to write a byte to the flash.  I am reading through the documentation and understand the basics of how to write a command to FCMD, however I do not see where I can specify the value or address I need to write.  I hoped the component would include methods to do it, but all it included was the initialization code.  I anyone could just give me a basic rundown of how to store a byte to the nonvolatile register (I am using 0xFFB0 but i'm not sure if thats write) it would be much appreciated.

Labels (1)
Tags (1)
0 Kudos
1 Solution
706 Views
kef
Specialist I

To specify address and byte, you need to write your byte to address you want to program.

 

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MCF51JM&nodeId=018rH3YTLC00M924B2&fps...

 

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN3942.pdf 

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN3942SW.ZIP

 

Also search forums for flash programming and copy rom to ram (since parts of flash programming code must run from RAM).

View solution in original post

0 Kudos
8 Replies
707 Views
kef
Specialist I

To specify address and byte, you need to write your byte to address you want to program.

 

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MCF51JM&nodeId=018rH3YTLC00M924B2&fps...

 

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN3942.pdf 

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN3942SW.ZIP

 

Also search forums for flash programming and copy rom to ram (since parts of flash programming code must run from RAM).

0 Kudos
706 Views
russianspy1234
Contributor I

Thank you, it seems to be working now.  I tried writing to the nonvolatile registed and it failed, then I tried writing to 0xC000 which is where the flash on processor should begin, but that didnt work either.  I moved the pointer address down to 0xE000 and it seems to be working fine.

0 Kudos
706 Views
bigmac
Specialist III

Hello,

 

With the inclusion of flash page erase and byte programming code, it is a good idea that flash block protection be enabled, to prevent the accidental erasure of the user program code.  The block protection setting represents the highest unprotected page - all pages above this will be protected.  This means that the non-volatile parameters should occupy the first flash page within the device - for the 'JM16 device, these should commence at address 0xC000.  Therefore, the user code should commence at address 0xC200, or above (page size is 512 bytes).

 

As has already been stated, a portion of the erase and programming code needs to execute from RAM, since flash memory does become inaccessible.  This applies from when the flash command is initiated, to the completion of the command (refer to the flow diagram within the datasheet).

 

Regards,

Mac

 

0 Kudos
706 Views
russianspy1234
Contributor I

For some reason, I seem to have code beginning at C000.  It looks like stuff I included with Codewarrior (Cpu_Delay100US, an interrupt, __EntryPoint).  So far, I've been putting address of my flash variable below my code (I only need 1 byte) but I am starting to run into trouble with that as well.  Also, I am not quite sure what you mean about running it from RAM, is the code kef pointed me to doing that automatically?  Because the data I am using does seem to be saving fine without me having done anything special.

0 Kudos
706 Views
bigmac
Specialist III

Hello,

 

Have you modified the PRM file so that the ROM segment commences at 0xC200, rather than 0xC000?  Even though you need only one byte of non-volatile storage, you will be erasing a flash page of 512 bytes.

 

If you are using the code associated with an application note, this will already provide the RAM based code, likely using the stack.

 

Regards,

Mac

 

0 Kudos
706 Views
russianspy1234
Contributor I

I had not.  I am still getting used to what is and isn't done automatically by CodeWarrior.  When I made the change using the processor expert, I got a warning of "The space is over the CPU address space" so I changed the ROM size from 3FAE to 3DAE, hopefully thats right?

0 Kudos
706 Views
bigmac
Specialist III

Hello,

 

If you are using Processor Expert utility, all bets are off with respect to what is "automatically" being done.  Even though you may manually modify the PRM file to suit your specific needs, it is quite possible that PE will overwrite this file with its own version.

 

I suggest you check the current contents of the PRM file to see whether your intent has been met.  You should also check the map file for the project to confirm the address of the non-volatile variable.

 

Regards,

Mac

 

0 Kudos
706 Views
BlackNight
NXP Employee
NXP Employee

You can prevent Processor Expert to change the linker file.

In the CPU component, there is a property page for Build Options. Here you can disable the generation of the linker file.

 

See http://mcuoneclipse.wordpress.com/2012/03/23/disable-my-code-generation/ for more details.

 

BK

0 Kudos