Stefan Bongs

Bitfield in Zeropage / Simulator Problems

Discussion created by Stefan Bongs on Jul 21, 2009
Latest reply on Feb 2, 2010 by Stefan Bongs

Using a small code example from a well known book about HCS08...

I tried it out with CW6.02:


#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

volatile struct {
  unsigned char first   : 1;
  unsigned char second  : 1;
  unsigned char third   : 6;
} near my_bit_field;

void main(void) {

  EnableInterrupts; /* enable interrupts */
  /* include your code here */

  my_bit_field.first   = 0;
  my_bit_field.second  = 0;
  my_bit_field.third   = 0;

  for(;:smileywink: {
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */


From the CW startup dialog

I'm using:


Rapid application: None


Memory model: Tiny

Float: None

PC-lint: No.


The behaviour is:

Invoking the Simulator lets the routine stop at

Label "Zero_2:" of the Startup code.


The code stops with the lines:

Error: At location 0060 -
Error: Attempt to write to a read-only location.

My question is:

How can I resolve this problem?


May I use the "linker parameter file"? - and how?