This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Global xdata variables

Hi!

I have a problem with global xdata variables. In main.c I have the following code to make two global arrays.

unsigned int xdata fordonsnummer[100] _at_ 0x000;
unsigned int xdata tomvikt[100] _at_ 0x0c8;  

Then in some heather files I have functions that uses the global variable. there for I have the following code:
extern unsigned int xdata fordonsnummer[];
extern unsigned int xdata tomvikt[];  
One function writes a value to a position in the array but when another reads the same value something goes wrong. The written value is for example 12345 and the read value is 257. What is wrong with my code. I have marked the "Use the onchip XRAM" in Options for target.

Regard Jonas Finell

Parents
  • Hello all!

    Now it works and the solution was to setup the SFR register to enable the xdata area. I thought this was automatically done by the compilator when I marked the "Use on chip xdata" box in the target dialog. Thank you all for your suggestions I'll keep them in mind.

    Regards Jonas Finell

Reply
  • Hello all!

    Now it works and the solution was to setup the SFR register to enable the xdata area. I thought this was automatically done by the compilator when I marked the "Use on chip xdata" box in the target dialog. Thank you all for your suggestions I'll keep them in mind.

    Regards Jonas Finell

Children
  • "Now it works and the solution was to setup the SFR register to enable the xdata area. I thought this was automatically done by the compilator when I marked the "Use on chip xdata" box in the target dialog."

    I think that checking the "Use on chip xdata/code" boxes is just a substitute for entering the start address and length of these memory areas. It is a bit misleading in that sense, if I had the choice I'd get rid of those check boxes.

  • "I think that checking the "Use on chip xdata/code" boxes is just a substitute for entering the start address and length of these memory areas."

    Yes, it is - see my earlier post.

    "It is a bit misleading in that sense"

    I agree.

    "if I had the choice I'd get rid of those check boxes."

    Dunno about getting rid of them - they just need a better better name!