My mcu is MC9S12XE.
For RAM saving,i want to put some const global variables into flash.Is there any conflict exist when S12X read code,meanwhile code excuting read the flash?Why?
There is no problem for storage the data in the any type of memory even in the memory the code is executed from.
The optimizer can exclude the variable from special space and use it as a part of the instruction if the variable is not used for another purpose. The solution in this case is to define the variable as “volatile const ….” And also put it into ENTRIES part in the *.prm file. “Volatile const” sounds strange but not for data placed in pflash, dflash or eeprom.
You can look at the example XEP100-FLASH-PFLASH-PFlashInitData.zip from the package at LAMA's S12XE unofficial examples. Of course there is also possibility to place data at exact place using operator “@” and remove the space from memory map defined in the prm file but I think this is not your requirement.
One thing to add, there are also options how to access the data. There are assembler instructions for global, local and paged access. In order to understand it is good to step the code via assembler and study how the access is processed by compiler following your variables definition.