Hi to all. I am quite new to programming and embedded system design and could use some help. Most of the hardware/software that I have done has been fairly small and the software fitted into 1 C file without problem. I am now modifying some software written by someone else , and am having some trouble understanding some of his variable definitions.I don't need to know any of this part of the software to make the changes I need, but would like to know what he has done :0) I am working in Raisonance by the way. Most of the variable definitions are in a seperate file named global.h In the main C file(named Main.c for some reason :0) ) there is a #include statement at the beginning , so far so good. Further down this post I have copied the global.h file. I am having trouble understanding how these definitions work. Some of the EXTERN statements are in capitals and some not. This seems to make a difference.
What is happening in the first three lines if the file? I am happy with the xdata and idata as meaning external ram and internal ram.
Hope that I have made "some" sence to someone!! Any help that anyone can give would be appreciated , or any good pointers to online documentation would also be appreciated. Cheers Rob
-------------------------------------------------------------------------------------
//---------------------------------------------------------------------------- // Global Variables - global.h //---------------------------------------------------------------------------- #undef EXTERN #ifdef _GLOBAL_H_ #define EXTERN
unsigned int xdata at 0x500 dbase[30]; // Modbus Datbase unsigned int xdata at 0x500 offset_dummy; unsigned int xdata at 0x502 job_number[5]; // 40002-40006 unsigned int xdata at 0x504 reason_ptr; // 40007 unsigned int xdata at 0x506 user_ID; // 40008-HI,40009-LOW unsigned int xdata at 0x508 stop_secs; // 40010-HI,40011-LOW unsigned int xdata at 0x50a counter; // 40012_HI,40013-LOW unsigned int xdata at 0x51c counter_in; // 40014_HI,40015-LOW unsigned int xdata at 0x51e counter_out; // 40016_HI,40017-LOW unsigned int xdata at 0x520 spoilage; // 40018 unsigned int xdata at 0x522 dbase_address; // 40019 ///
#else #define EXTERN extern
extern unsigned int dbase[30]; // Modbus Datbase
extern unsigned int offset_dummy; extern unsigned int job_number[5]; extern unsigned int reason_ptr; extern unsigned int user_ID; extern unsigned int stop_secs; extern unsigned int counter; extern unsigned int counter_in; extern unsigned int counter_out; extern unsigned int spoilage; extern unsigned int dbase_address;
#endif
//---------------------------------------------------------------------------- //--- Other global variables --- EXTERN unsigned char idata barcode_buffer[16], reply, incomming_data, mm, clr, debounce_in, debounce_out, status_change, mode, edge_flag, update, sec_flag, wait;
EXTERN unsigned int idata temp_num, simple_tmr, delay, pwr_delay, tenths, dsp_address, dsp_timer, screen_ptr;
EXTERN unsigned long int idata temp_long, dsp_job_number;
EXTERN unsigned char xdata counted_in,counted_out;
//--- Constants ---- #define WDOG P1_6 #define COUNTER_IN ~P3_2 #define COUNTER_OUT ~P3_3 #define INP_3 ~P3_4 #define BL P1_0 #define DEBOUNCE 2 #define RUN 1 #define STOP 0