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.
Hi guys,
I tried to construct a waveform with more than 6000 points. the program is like:
arg.h . . int xdata wave[6000] . . main(){ . . for...{ wave[i]=i*10; . } .
it passed the compiling and linking. it showed that xdata=12131. but when i ran the program, it's actually showing a messed up waveform. it only works correctly when i reduced the size of the wave[] to 4000, which makes xdata=8131.
i m using version 7.2, and the xram on the board is 128k. i think it's something missing in the program but couldnt figure it out yet since i m just a beginner of mcu programing in c. any suggestion? i really appreciate it.
thanks for the advice. i dont have a simulator. and i dont think it's the banking problem either. I changed the compile option to fixed the variables order. It actually allow the program doing what it's supposed to do with the wave[] as large as 32000, except any point higher than index 4000, goes back to the value of index 0, which makes me think it might be related to that '8k' problem.
Of course you do - uVision has a built-in simulator!
... you, like many others, did not see a reason to tell us which uC you are using.
I guess you are using a SILabs or NXP (or other) with 8k internal XRAM and have not modified (a local copy of) startup.a51 to enable access to your external XRAM.
Erik
On what basis?
But that is specifically related to initialised arrays, and it would produce a compiler error - neither of which applies in your case!
ok, i appreciate all you guys' advice, i m using the silab f120. since i just began working on mcu, let me work on it a bit more and see what i find out.
Are you sure you have enabled external XRAM? By default on F120 only internal 8K of XRAM is enabled. That can explain the odd behaviour of your program.
To use external XRAM, you should propperly initialize EMI interface and the crossbar...
regards
Dejan
i m using the silab f120 my guess was correct, had you stated your processor in your first post you would be running by now.
DO NOT set the "memory model SFRs" in main(), you MUST set them in startup.a51.
mov SFRPAGE,# mov EMI0CF,# mov EMI0TC,#
the datasheet will tell you the values that match your app
Thank you Dejan, I might be mistaken the xram with the 128k on-chip programmable flash memory. what i need to use is actually this banked 128k. suppose that i have enabled it, how should i put the large array in it instead of the 8k ram? I guess it should not be xdata anymore or i configure something in the ide. right?
Thank you Erik. now correct me if i m wrong. in order to enable the 128 k flash memory as xram beyond that internal 8k+256 ram, i need to configure the SFRs of external data memory interface, and the banking(PSbank, PSCTL). and let the compiler arrange the array location in it.
for >8k, just set it up for 64k not banked.
If I have misunderstood your posts and you DO need more than 64k, then there is a SILabs appnote how to do it (it is NOT done the "keil way" but works with Keil).
Banking will slow down XDATA access dramatically
ok. i read the flash memory part of the datasheet. it's for code and non-volatile data storage. does it mean that i can only put the codes there? i am not sure if i can use it as xram for xdata. if set up the memory >8k, say up to 64k, in EMI0CF, so all the memory beyond 8k is from the flash memory, or i actually need some memory chip?
YOU NEED TO READ "THE BIBLE" (not just for this) the '51 is a harvard architecture
ok. i read the flash memory part of the datasheet. it's for code and non-volatile data storage. does it mean that i can only put the codes there? i am not sure if i can use it as xram for xdata. It is for code only (and possibly some constants)
if set up the memory >8k, say up to 64k, in EMI0CF, so all the memory beyond 8k is from the flash memory, or i actually need some memory chip do you play "air guitar"? then, possibly you can figure out how to use "air memory" :) YES, for more than 8k data memory you need an external RAM
here are the links to "the bible" Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
you can have anything in flash (code) memory that you do not change. Thus if you have an array of constants using the 'code' keyword will place it in flash.
Thanks for the answer.
Thanks Erik, I read the doc from those links, it's a great resource. I finally figured out these things.