Storing variable in flash

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

Storing variable in flash

Jump to solution
1,193 Views
rmaier
Contributor III

Hello,

 

I'm using an MC9S12P128 MCU, and I'd like to store some constants in D-flash. I have the D-flash segment defined as

 

DFLASH        = READ_ONLY   0x010400 TO 0x0113FF;

 

So, when I go to write the constant, I use the following:

 

#pragma CONST_SEG CAL_VAL
volatile const unsigned char __near constant1=0x7F;

 

When I look at where this is in the memory, it shows up as 0xC015. To me, that's nowhere in the range define above. What am I missing here?

Labels (1)
0 Kudos
1 Solution
1,042 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Robert.

I just made a quick test but I didn't reproduce your problem.

see attached demo code and video.

 

Have a great day,
Jennie Zhang
 
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
5 Replies
1,043 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Robert.

I just made a quick test but I didn't reproduce your problem.

see attached demo code and video.

 

Have a great day,
Jennie Zhang
 
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,042 Views
rmaier
Contributor III

I do not see any attachments. Can you please post?

0 Kudos
1,042 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Can't you see it?

here is the screenshot of it

pastedImage_1.png

0 Kudos
1,042 Views
rmaier
Contributor III

Thank you, Jennie. The video was very helpful. I missed some items in the prm file.

Not sure how I missed the video. My appologies.

0 Kudos
1,042 Views
rmaier
Contributor III

I hacked a solution. I defined constant1 in D-flash as follows:

const unsigned char constant1 @ 0x0400;

Then I can write to D-flash at this location, and all is well...

0 Kudos