We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have had a rather ugly problem caused due to the optimization. I am reading data from a fifo. The read port is at address 0x8200 (read only access). It also has a read reset port. Its address is also 0x8200 (both xdata) (write onle access). When I declare the varables for accessing the fifo like this:
xdata uchar fifo_data _at_ 0x8200; xdata uchar fifo_rres _at_ 0x8200;
xdata uchar fifo_data _at_ 0x8200; #define fifo_rres fifo_data
fifo_rres = 0xff; // reset fifo read jpg_adr = 1; // set jpg file address to the next address to be read fbuf_start = 0; // set buffer start pointer to zero fbuf_in = 1; // set buffer input pointer to next free byte in buffer fbuf_pos = 0; // set buffer read pointer to zero fbuf_startadr = 0; // set buffer startadress to zero fbuf[0] = fifo_data; // read first byte from jpg file
keyword: volatile Have fun, Erik
To flesh out a bit;
volatile xdata uchar fifo_data _at_ 0x8200; #define fifo_rres fifo_data
what about
Hi there, thanks for the quick help. I had heard something about "volatile" before, but I couldn't find anything about it in my Keil books. After I got the reply, I have found it as a footnote in the Kernighan&Ritchie. So what I have done is:
#define FIFO_READ_ADR 0x8200 [...] xdata volatile uchar fifo_data _at_ FIFO_READ_ADR; // fifo data register (read only) #define fifo_rres fifo_data
Just a suggestion: File fifoin.c:
xdata uchar fifo_data _at_ 0x8200;
extern xdata uchar fifo_data; #define fifo_rres XBYTE[0x8200]
#include <absacc.h> #include "fifoin.h" /* now fifo_data and fifo_rres are */ /*competely different to the Compiler*/
I'd like to cancel my prevoius message.
If you're hell-bent on having 2 variables at the same address, there is an easy way to handle it. 1. In your C code, create external definitions. For example:
extern unsigned char xdata var1; extern unsigned char xdata var2;
xseg at 0x8000 public var1 public var2 var1: var2: DS 1 end