Writing data to Flash on MC9S12DP512

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

Writing data to Flash on MC9S12DP512

3,554 Views
mohamed
Contributor I
Hi all,
I'm working on the Adapt9S12DP512 board. I'm downloading my code onto RAM using DBUG12. I'm currently running an experiment and I would like to store the data collected through the ATD in Flash.
I've followed the steps detailed in the application note AN2720 available on the Freescale website.

However, when I run my program, nothing gets written to Flash. For a start, I tried writing the word 0xABCD at location 0x380002. I then used the MD command in DBUG12 to check whether the word was indeed written at, I suppose, location $8002 given that the PPAGE = $38. Unfortunately, nothing was written.
As a further check, I tried setting PPAGE to $30. Upon entering the "MD 0039" in MiniIDE, the PPAGE register still reads $38!
Can anyone help me solve this problem?
Thanks in advance.
Labels (1)
0 Kudos
Reply
5 Replies

1,511 Views
mohamed
Contributor I

 

Hi,
I've been trying to write to Flash EEPROM for quite some time now but with no luck. I'm using DBUG12 to download my code onto RAM and then storing data received through the ATD in Flash.
I got source code for writing on Flash from the Freescale Technical Support. The code compiles without any errors and the .s19 file gets generated. However, when I come to download the file onto the microcontroller, I get the following error:
"Can't Write Target Memory".
I've attached a .zip folder containing the project. I would be grateful if someone can have a look at the code and help me resolve this issue.

Thanks in advance

 

 

Flash4.zip

Message Edited by t.dowe on 2009-10-20 11:44 PM
0 Kudos
Reply

1,511 Views
kef
Specialist I

     ... DBUG12 ... "Can't Write Target Memory".

This has nothing to do with code for writing data to flash. Interesting that in your first post it didn't look like you aren't able to upload your code into your board. Check if your prm-file settings are compatible with dBug12, also if interrupt vectors are where dBug12 expects them to be. Serach box at the bottom of this page may help you.


 

0 Kudos
Reply

1,511 Views
mohamed
Contributor I
Hi Kef,
Thanks for your reply. Indeed, in my first post I didn't have a problem with downloading to the microcontroller; the problem was in writing to the Flash memory.
Its when I tried running the code Freescale sent me that I started facing this problem.
Anyways, I'll check the prm-settings as you have recommended.
Thanks again.

Regards,
Mohamed
0 Kudos
Reply

1,511 Views
mohamed
Contributor I
Hi,
I believe there is some contradiction between the Flash EEPROM datasheet and AN2720. In the datasheet, it is stated that, in order to be able to write to Flash, bits FPOPEN, FPHDIS & FPLDIS of the FPROT register should be set to 1 to disable protection. However, in the code found in AN2720 ("flash.c" to be specific) FPROT is set to 0x00 to disable all protection!
Which one is correct?

Thanks in advance/
0 Kudos
Reply

1,511 Views
Lundin
Senior Contributor IV
Unless you have some utterly custom memory map, there is no address 380000. Try writing to 388000 instead. If that isn't working, please post the code.
0 Kudos
Reply