I try to access a large data buffer using a far pointer that can exceed the 64k boundary, using the method introduced in http://www.keil.com/support/docs/2663.htm.
But when I made the declaration as follows and compiled the codes, an compiling error came up: SF1PROG.C(82): error C129: missing ';' before '*'
#include <absacc.h> unsigned char far *farBuff = FARRAY(unsigned char, 0x110000);
Can anyone help me out? Thank you so much.
Is there any other method for me to access memory that locates in the range exceeding X:0xFFFF?
Can anybody help me out with this issue?
The declaration looks ok. You probably want a UL at the end of "0x110000UL".
Are you sure there's not an error in the line or so before this line? Since the line number is 82, it's obvious there's more than just these two lines involved.
FARRAY is a macro defined in absacc.h. You might want to look at the post-preprocessor source and see if there's an error once the substitutions have been made.
Thank you for your informative reply.
By the way, is there any other method for me to access memory that locates in the range exceeding X:0xFFFF?
The processor I am now using is Intel 8032.
Far memory implies some way to generate additional address bits beyond the 16 you normally get from an 8051 (or 8032) core. These might come from an additional SFR, or I/O port pins, or some sort of external latch. This hardware somehow has to be set before a far access so that when the core executes a MOVX instruction, which generates the low-order bits and r/w enables, the high-order address bits are available to the memory.
The XBANKING.A51 or L51_BANK.A51 files are the ones that actually implement the libraries to set this hardware. Details depend on your hardware. These files do contain example code for some of the common methods of extending the address bus.
Once these libraries are defined, the compiler automatically generates calls to them as needed to access far data.
Thank you so much. Now I feel much clearer with the problem.
Now I am using Keil and the source codes to do the simulation but I won't have any hardware before the simulation is successfully.
Can I still make access to and change the contents of the memory space exceeding X:0xFFFF based on the source codes even if I don't have any hardware I/O devices? Thank you again!
Without the hardware, I tried to read/write the content of the far memory area HDATA (X:0x020000-X:0x02FFFF) in KEIL uVision3. I have specified this user class in the LX51 Locate. The compiling was successful.
But when I entered the 'debug' process, executed the source code and observe the memory window, the memory area X:0x020000-X:0x02BFFF didn't change at all, but instead the area X:0x000000-X:0x00BFFF was changed according to my requirements. The source code is as follows:
#include <REG52.H> // SFR definition header file #include <stdio.h> // prototype declarations for I/O functions #include <absacc.h> unsigned char far large_array[0xC000]; void main (void) { unsigned int i; for (i = 0; i < sizeof (large_array); i++) { large_array[i] = (unsigned char) i; } }
I am using Intel 80C32 as the device. Can anyone here help me out of the strange trouble? Thanks a lot!
A normal 8032 does not have any hardware for far addressing. How is the simulator supposed to know that you intend to have such? You'd need to either pick a device that has built-in extended addressing, or configure the simulator to know that you have such hardware, even though the device you picked does not.
Unfortunately, I'm not very familiar with running code under the simulator. (My 8051 projects involve a core embedded in a fairly complex ASIC, and it would take a very long time to write a simulator for the ASIC just so the 8051 code could be executed. Easier to run on a real target.)
See the far memory examples such as the one in
C:\Keil\C51\EXAMPLES\FarMemory\4MB Variables on Classic 8051
Thank you for your kind help. You noted that:
or configure the simulator to know that you have such hardware, even though the device you picked does not.
Would you please explain in detail how I can configure the simulator? Do I need to configure XBANKING.A51?
Thank you!