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

question about xdata

I have just started using the keil compiler and had a simple question about getting data to and from an xdata buffer.

Say I have declared a buffer and two global integer variables as follows;

xdata volatile BYTE TEMPBUF[64];
int nTemperature, nTemperature2;

How do I get data from the TEMPBUF to the integer variables?

nTemperature = (int)TEMPBUF;
nTemperature2 = (int)TEMPBUF [2];

And how do I get integer data to the TEMPBUF?

(int)TEMPBUF = nTemperature;
(int)TEMPBUF[2] = nTemperature2;

Any help would be greatly appreciated,
JD

Parents Reply Children
  • Yes already familiar with 'C', it's just I tried the following code

    if (SETUPDAT[0] == VR_UPLOAD) {	// to host
    	*((WORD*)(EP0BUF+0)) = nShutter;
    	*((WORD*)(EP0BUF+2)) = nShutterSpeed;
    } else  {			// from host
    	nShutter 	= *((WORD*)(EP0BUF+0));
    	nShutterSpeed 	= *((WORD*)(EP0BUF+2));
    }
    
    

    And it returns the proper data in debug mode with breakpoints set, but returns the wrong data values on debug mode w/o breakpoints set.work