Dear Sir, It may be a simple question. I am using Atmel AT89C51ID2 for the development. The MCU having 256 Bytes Scratch Pad RAM and 1792 bytes on-chip XRAM, totally 2048 bytes of RAM. I am using uVsiion V2.40a with C51 V7.20. I can find the device and chose it in uVision. As our program will use more then 1792 bytes of RAM, after I compile the source code, it shows: Program Size: data=9.5 xdata=1802 code=825 0 WARNING(S), 0 ERROR(S) In the .lst file, it shows: MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 719 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = 1798 4 PDATA SIZE = ---- ---- DATA SIZE = ---- ---- IDATA SIZE = ---- ---- BIT SIZE = 5 ---- END OF MODULE INFORMATION. It seems have not problem as no warning and no error. But it shows larger then 1792 bytes in the XDATA (XRAM). I would like to know : 1) Is it normal? Does the program can run without any known hiding problem? 2) Does C51 can automatically assign the usage of RAM so that I can fully use the 1792 bytes of XRAM and 256 bytes of Scratch Pad RAM at the same time? or just can use 1792 bytes of XRAM or 256 bytes of Scratch Pad RAM and cannot use them at the same time? Thank you very much for your kindly help. P.S. I select the Memory Model as "Large" and didn't click the "Use on-Chip XRAM (0x0-0x6FF)" box.
Did you check 'Use On-Chip XRAM' in the Target options?
"Does the program can run without any known hiding problem?" No. "Does C51 can automatically assign the usage of RAM so that I can fully use the 1792 bytes of XRAM and 256 bytes of Scratch Pad RAM at the same time" With some help from you, yes. "I select the Memory Model as "Large" " Select small instead. Qualify the declaration of any variables you wish to put in the 'XRAM' area with the 'xdata' keyword. Unqualified variables will be placed in the 'data' area. You can place some variables in the 'idata' area but remember that this will reduce the stack size available for your program. "and didn't click the "Use on-Chip XRAM (0x0-0x6FF)" box." Please do click this box. Note, however, that you will still need to mofify the startup code to enable all 1792 bytes of XRAM, Keil will not do this for you.
Stefan, You hid the likely reason as an afterthought: Note, however, that you will still need to modify the startup code to enable
Chow Kin Hei said: "didn't click the 'Use on-Chip XRAM (0x0-0x6FF)' box." Sorry - I missed that PS! Yes, this is certainly the cause of your problem! By clicking this box, you tell the Linker that you will be using the 1792 bytes of on-chip XRAM. If you don't check the box, the Linker has no idea how much XRAM you have - so it just assumes a full 64K. That's why you don't get a warning that you've used >1792 bytes! Stefan Duncanson said: "Please do click this box. Note, however, that you will still need to mofify the startup code to enable all 1792 bytes of XRAM, Keil will not do this for you." Absolutely. The sole function of this box is to inform the Linker how much XRAM you have, and its address range - it does not generate any code to perform any necessary chip configuration!
Looks like you are using the LARGE memory model. The compiler puts all your variables into XDATA (data=9.5 xdata=1802). Now you should have a look at the C51 User Guide and find the chpater about the keywords 'idata' and 'data'. These allow to explicitly move variables into DATA and IDATA. (http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm)
Looks like you are using the LARGE memory model. ... Now you should have a look at the C51 User Guide and find the chpater about the keywords 'idata' and 'data'. These allow to explicitly move variables into DATA and IDATA. Even better, switch to the small model and start using the keyword XDATA. With the LARGE model, reducing XDATA by using DATA and IDATA will usually result in random variables being moved to "fast memory". With the SMALL model, where you explicitly move data to "slow memory" you have a better chance of getting the vatiables in the right places such as very frequently used: DATA frequently used: IDATA rarely used: XDATA Erik
"rarely used: XDATA" Plus, of course, anything that's too big to fit elsewhere!
Plus, of course, anything that's too big to fit elsewhere! which, by sheer coincidence, seems to be ehat is used rarely. Yes, you may access an array often, but how often do you acces any one element of an array. Erik