Bitfield in Zeropage / Simulator Problems

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bitfield in Zeropage / Simulator Problems

2,370 Views
hello_from_berl
Contributor I

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 */

#pragma DATA_SEG __DIRECT_SEG MY_ZEROPAGE
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

Startup:ANSI

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?

 

 

Regards

 

Stefan

Labels (1)
Tags (1)
0 Kudos
7 Replies

566 Views
hello_from_berl
Contributor I

The problem is solved with the current Code Warrior V6.3.

Thanks to the CW staff.

0 Kudos

566 Views
hello_from_berl
Contributor I

Yes,

I use the project wizard of CW 6.2 and the default linker command file.

For me there was no reason to modify this file because of the standard usage of the line:

"#pragma DATA_SEG __DIRECT_SEG MY_ZEROPAGE" in the example.

 

In the linker command file it looks for me, that with the lines:

    Z_RAM                    =  READ_WRITE   0x0060 TO 0x00FF;

and

    _DATA_ZEROPAGE,                     /* zero page variables */
    MY_ZEROPAGE, DEFAULT_RAM                         INTO  Z_RAM;
 

 the bitfield is mapped into RAM area of 0x60.

But the simulator stops at the point where it tries to clear this location with the known messages:

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

But why?

Regards

 

Stefan

 

0 Kudos

566 Views
CompilerGuru
NXP Employee
NXP Employee

You forgot to mention the most important selection in the wizard, which derivative are you using?

 

Given the description it appears that the simulator and the prm file you are using have a different opinion if there is RAM at 0x60. Of course, both the simulator and the prm file are derivative specific, so impossible to know which one of the two is in error.

 

Daniel

0 Kudos

566 Views
hello_from_berl
Contributor I

Oh, I'm sorry.

I have selected the MC9S08QE8 .

Maybe this information helps you to find a solution.

 

Stefan

 

0 Kudos

566 Views
bigmac
Specialist III

Hello Stefan,

 

Is it possible that the project, and therefore the simulator, assumes that the target is a QE128, rather than a QE8?  For the larger device, RAM commences at 0x80.

 

Regards,

Mac

 

0 Kudos

566 Views
hello_from_berl
Contributor I

Hello Mac,

now I setup the project again, this time not with an ad-hoc configuration but with a specific one. Now I'am using the MC9S08QE8_20.

In the reference manual for this device (MC9S08QE8RM.pdf) the RAM area starts at 0x0060 upto 0x025F. When I'im using the pragma line:

#pragma DATA_SEG __DIRECT_SEG MY_ZEROPAGE

the known error "Error: At location 0060 -" comes again.

 

When I remove this line, the compiler/linker takes the default RAM and places the variable at address 0x0080 and further and everything works fine and the bitfield is placed in the RAM area below 0x100 as it should do.

 

The concerning lines in the PRM-Files are:

    Z_RAM                   =  READ_WRITE   0x0060 TO 0x007F;
    RAM                      =  READ_WRITE   0x0080 TO 0x025F;
 

Now my question is: what topic gives the simulator the information, that the RAM area between 0x0060 and 0x007F is: "not assigned or read-only", in general - a kind of not available? For me it looks like that the specification of the device for the simulator is not properly. Is there a possibility to check this configuration manually? And if so - in which file is it located?

 

Stefan

0 Kudos

566 Views
J2MEJediMaster
Specialist I

I assume that the bok example was written in CodeWarrior? If so, what version was it? Are you using the linker command file from the book's example code, or from--another assumption--the CodeWarrior 6.2 New Project wizard?

 

---Tom

0 Kudos