<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>question about xdata</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/16108/question-about-xdata</link><description> 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,</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: question about xdata</title><link>https://community.arm.com/thread/86558?ContentTypeID=1</link><pubDate>Fri, 31 Oct 2003 16:04:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:db3494c6-e17c-4e37-b8bd-1246a967992c</guid><dc:creator>John  D</dc:creator><description>&lt;p&gt;Yes already familiar with &amp;#39;C&amp;#39;, it&amp;#39;s just I tried the following code&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
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));
}

&lt;/pre&gt;
&lt;br /&gt;
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&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: question about xdata</title><link>https://community.arm.com/thread/41182?ContentTypeID=1</link><pubDate>Fri, 31 Oct 2003 13:47:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:16428f18-d19c-4be1-a769-d00ef0ae8b24</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;I have just started using the keil compiler&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Are you already familiar with &amp;#39;C&amp;#39; in general?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: question about xdata</title><link>https://community.arm.com/thread/41179?ContentTypeID=1</link><pubDate>Thu, 30 Oct 2003 18:46:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1bc0a049-0bd0-4f9f-9a39-2981af49b4bc</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;Simple assignment should work fine to move data between memory spaces.  The compiler will figure out what sort of instructions it needs to do the job.  Do you have a problem with those statements?&lt;br /&gt;
&lt;br /&gt;
The first example should probably be TEMPBUF[0].  (Otherwise, you&amp;#39;ll get the address of the array, not value of the first entry.)&lt;br /&gt;
&lt;br /&gt;
If 8 bits is enough for your samples, why not declare all the relevant variables (TEMPBUF as well as nTemp*) with the same type?  Maybe even&lt;br /&gt;
&lt;br /&gt;
typedef char TempSample;&lt;br /&gt;
xdata volatile TempSample TempBuf[64];&lt;br /&gt;
TempSample nTemp, nTemp2;&lt;br /&gt;
&lt;br /&gt;
so that you can change the representation of every related variable in one swoop if necessary.  Conversely, if the samples are really 16 bits wide (as it appears from the attemps to store them at multiples of 2 bytes), then just declare TEMPBUF as a U16 (unsigned int).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>