title: When do I use xdata?
body: <p>I am new at embedded system programming. I am working on a device that uses an 8051 chipset. I have noticed in the sample programs that when defining variables, sometimes they use the keyword xdata. like this...</p>
  
  <p><em>static unsigned char xdata PatternSize;</em></p>
  
  <p>while other times the xdata keyword is omitted.</p>
  
  <p>My understanding is that the xdata keyword instructs the compiler that that variable is to be stored in external, flash, memory. </p>
  
  <p>In what cases should I store variables externally with xdata? Accessing those variables takes longer, right? Values stored using xdata do not remain after a hard reset of the device do they?</p>
  
  <p>Also, I understand that the static keyword means that the variable will persist through every call to the function it is defined in. Do static and xdata have to be used together?</p>