This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

put const variables into code-segment

Hi.

I want to put a (large) table of constant values into the code-segment, because I'm very low on RAM but have plenty of program-ROM.

The C51-manual on page 88 says "Constant variables may also be stored in program memory".

How is this possible?

Thanks, Patrick

Parents
  • Well, that's no argument, since a) interrupt service routines can't be written in the "C" that provides the applicable definition of these terms (i.e. the ISO C standard), and b) even if they could, there's no conforming way to get access to a const object that would allow the ISR to write to an object the main code can't. Whichever way you try (pointer casts, trick unions): you always cross an "undefined behaviour beyond this line".

Reply
  • Well, that's no argument, since a) interrupt service routines can't be written in the "C" that provides the applicable definition of these terms (i.e. the ISO C standard), and b) even if they could, there's no conforming way to get access to a const object that would allow the ISR to write to an object the main code can't. Whichever way you try (pointer casts, trick unions): you always cross an "undefined behaviour beyond this line".

Children
No data