Newbie question on memory access and exceptions on HCS12X

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Newbie question on memory access and exceptions on HCS12X

ソリューションへジャンプ
1,007件の閲覧回数
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 解決策
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 件の賞賛
返信
2 返答(返信)
702件の閲覧回数
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 件の賞賛
返信
701件の閲覧回数
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 件の賞賛
返信