Hi all i want to read RTC time parameters. RTC is treated as one of memory location,it gets enabled when parameters are refered. following where the codes:
struct tm{ unsigned char xdata second _at_(0xe000); unsigned char xdata minute _at_(0xe002); unsigned char xdata hour _at_(0xe004); }; void main() { struct tm time; printf("seconds %x",time.second) ... }
struct tm{ unsigned char second _at_(0xe000); }
xdata unsigned char second _at_(0xe000); xdata unsigned char minute _at_(0xe002); xdata unsigned char hour _at_(0xe004); void main() { printf("\nseconds %x",second); printf("\nminutes %x",minutes); printf("\nhours %x",hour); }
struct tm{ unsigned char xdata second _at_(0xe000); unsigned char xdata minute _at_(0xe002); unsigned char xdata hour _at_(0xe004); }; void main() { struct tm time1,time2; ......
I *think* that what you want is: struct tm { unsigned char sec _at_ 0xe000; unsigned char min _at_ 0xe002; }; void main() { struct tm xdata time; } Stefan
Or:
struct tm { unsigned char sec; unsigned char min; }; void main() { struct tm xdata time _at_ 0xe000; }
"1)what is wrong with the defn in struct?" Chapter 7 of the Manual describes the error messages - including this one. Read the explanation! You can also select the message in uVision and press F1 to see the same description!
What you need is:
struct tm { unsigned char second; unsigned char res1; unsigned char minute; unsigned char res2; unsigned char hour; }; struct tm xdata time _at_ 0xe000; // time starts at 0xe000 !! void main() { }
"You can specifiy addresses for variables and structures/unions - not for structure elements." Yes, I was surprised that he seemed to be suggesting that the compiler accepted _at_ within a structure definition!!?? Does it really????
"Yes, I was surprised that he seemed to be suggesting that the compiler accepted _at_ within a structure definition!!?? Does it really????" The compiler ignores the _at_ statement applied to structure elements! There is no compile error - I have tried it with V7.06a. The compiler calculates the addresses of structure elements from the beginning of the structure - and this is not 0xe000
"Yes, I was surprised that he seemed to be suggesting that the compiler accepted _at_ within a structure definition!!??" I assumed that if it compiled without warning... Silly me. Stefan
"I assumed that if it compiled without warning..." Yes sounds like a bug to me - the user should at least be warned!?
Thanks for reply. with following code:
struct tm xdata time1 _at_ 0xe000; struct tm xdata time2 _at_ 0xe000;
"will compiler assign following addrress for struct elements?" I think you need to go back to your 'C' textbook and read-up on the way structures work. what if i define:struct tm xdata time1 _at_ 0xe000; struct tm xdata time2 _at_ 0xe000; You have declared two different variables at the same memory address - this will probably give you a Linker error! Why would you want to do this?
Hello sir, When debuging program,the control is flowing in abnormal way.It is not following the correct sequense. I am using Keil microvision 2 for Philips P8WE6004 chip. thanks and regards Amit
Amit, so what is your question? Unless it is directly related to this current thread of discussion, please start a new thread