Newbie question on memory access and exceptions on HCS12X

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Newbie question on memory access and exceptions on HCS12X

跳至解决方案
1,006 次查看
holder
Contributor I

Hi Folks,

  I am new to the HCS12x and have a question regarding memory access and exceptions. If this is FAQ my apology upfront.

 

Setup

CodeWarrior 5.1, target is mc9s12xdt512 and FCS.

 

My question:

What happens to a memory write to a variable in a C program that is const and placed in onboard flash (READ_ONLY) segment C000? Does the program continue running or will it raise an exception and halt?

 

When I run the program on the target hardware it seems to run ok. But when I run it under the Full Chip Simulator (FCS) the simulator halts the program at the write call with error message "Protected at XXXX".

 

On x86 Windows/Linux a bad write like this would cause global protection fault/segmentation fault and core dump.

Will the physical mc9s12xdt512 allow/ignore this bad write but the simulator will stop and alert me?

 

thank you

bob

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
700 次查看
kef
Specialist I
  • What happens to a memory write to a variable in a C program that is const and placed in onboard flash (READ_ONLY) segment C000? Does the program continue running or will it raise an exception and halt? 

It is uncommon to write to RO memory. On target S12XD program will continue running. But simulator can help you detecting reads from not initialized memory and writes to read only memories. Simulator allows to modify or create your own memory layout in which all or parts of the flash can be made RW and you won't see those write access errors.

 

S12XE has memory protection unit (MPU), which allows to restrict accesses to read and execute, read and write, or only read. On S12XD there's no MPU, you can only restrict write accesses to RAM, but not to flash.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
701 次查看
kef
Specialist I
  • What happens to a memory write to a variable in a C program that is const and placed in onboard flash (READ_ONLY) segment C000? Does the program continue running or will it raise an exception and halt? 

It is uncommon to write to RO memory. On target S12XD program will continue running. But simulator can help you detecting reads from not initialized memory and writes to read only memories. Simulator allows to modify or create your own memory layout in which all or parts of the flash can be made RW and you won't see those write access errors.

 

S12XE has memory protection unit (MPU), which allows to restrict accesses to read and execute, read and write, or only read. On S12XD there's no MPU, you can only restrict write accesses to RAM, but not to flash.

0 项奖励
回复
700 次查看
holder
Contributor I

Agreed. Writing to RO segment in flash is not what we want and most likely a bug.

You answered my question - specifically that the physical processor will continue running but the sim will halt.

Thank you for the help.

bob

 

0 项奖励
回复