Question

Programming on a XC888 microcontroller, I want to save a buffer for some data in the external memory xdata.

I am doing it like this (just an example, where I got rid of unnecessary code):

Header.h

extern ubyte xdata rec_buffer[32];

Function.c

ubyte xdata rec_buffer[32] = {0};

void foo()
{
    //Option 1
    rec_buffer[0] = 0xFF;    // Doesn't work

    //Option 2
    ubyte xdata *ptr_buf = rec_buffer;
    ptr_buf[0] = 0xFF        // Doesn't work
}

So I just can't figure out what I am missing here. In both cases, there is no data written into the buffer. (Checked it with the debugger). I also checked the address where the pointers point it --> It actually points in the External memory (Address 0x000000, but there should be nothing wrong with that).

When I do it without defining the buffer in the xdata it works totally fine. What am I doing wrong? Is there some special way I have to write into the xdata?

Was it helpful?

Solution

Shouldn't XRAM be at 0xF000 (not 0x000000)? According to Figure 7 here:

http://www.keil.com/dd/docs/datashts/infineon/xc88xclm_ds.pdf

Is the linker configuration wrong somewhere?

OTHER TIPS

Use volatile keyword for your buffer, most probably variable is skipped by compiler. If you write a value to a memory or I/O space but not observe the value or any change, most probably your variable is optimized by compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top