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.
I have 8051 with 2 DPTR, SFR register to switch data banks(32Kb/16Kb)... Both DPTRs used to increment read/write pointers. I need correct 32bit address increment over all accessible memory. How to widen DPTR to work with 32 bit address?
Install co-processor. ARM7, ARM9, PPC, MIIPS, x86, ...
The size of the DPTRs (and all other SFRs) is fixed by the hardware - you cannot change it except by changing to different hardware!
div
how to implement own full functionality 32 bit DPTR? Is it possible?
is it correct to use own record like as DPTR? typedef union U32 { unsigned long dword; //DPTR unsigned short word[2]; unsigned char byte[4]; struct { U16 msw; // DPH U16 lsw; // DPL }words; }U32;
The Keil tools support extended DPTRs by using far memory. You'll have to customize XBANKING.A51 or L51_BANK.A51 to support your exact hardware.
The 8051 variants I know with extended DPTRs have 24-bit DPTRs -- one additional byte per pointer. The Keil generic/far pointer scheme is also a 3-byte format, so it can't store 32-bit addresses.
If you really need 32-bit-wide DPTRs, you're going to have to do most of the work yourself. Create a type that is 32 bits (a structure, as you suggest). Then you'll need to create some library routines to write the upper bits of that value to your extended hardware, and the lower bits to the DPTR proper. You'll probably want routines to set a memory bank and to extract a far pointer from the 32-bit value.
The DPTR isn't an integer, so you can't glue together a number of integer variables to form a larger DPTR.
DPTR has special magic meaning to the processor, resulting in physical memory accesses. If the processor doesn't have the required hardware to address 4GB linear memory then it simply isn't possible to get a 4GB linear address space.
The only thing you can do when your processor has too little address space is to use memory overlays. But you must manually switch in the different memory banks, and it will not be fast unless your application has a high degree of locality-of-reference.
I need correct 32bit address increment over all accessible memory.
No can do. There's no such thing as "accessible memory" in an 8051 that would span a 32-bit memory range.
If you want to address more than 64 KB, you have to go beyond what the 8051 itself can do. There are extended 8051 variants like the 80390 by Maxim that have 24-bit DPTRs. But if you want 32-bit addressing, you really should stop thinking about 8051s for the job.
Thanks, so at the end my solution is:
typedef union U32 { unsigned long dword; unsigned short word[2]; unsigned char byte[4]; } bdata U32; ... unsigned long Inc32bitDPTR (unsigned long addr) { U32 idata tmp_dptr; tmp_dptr.dword = addr; tmp_dptr.dword++; switch (DPS) { case 0x00: DPL0 = tmp_dptr.byte[3]; DPH0 = tmp_dptr.byte[2]; break; case 0x01: DPL1 = tmp_dptr.byte[3]; DPH1 = tmp_dptr.byte[2]; } if (tmp_dptr.dword >= MAX_ADDR) tmp_dptr.dword = 0; return tmp_dptr.dword; } ... tmp_dptr_dst.dword = addr;//long addr; WriteByte (tmp_dptr_dst.dword, byte); tmp_dptr_dst.dword = Inc32bitDPTR(tmp_dptr_dst.dword); ...
May be anybody realized it better and faster?
I would avoid the use of "word" to mean "16 bits"
See: www.8052.com/.../read.phtml
Strictly, on an 8051, the word-size is 8 bits.
Micro$oft wouldn't :)
They currently uses it to mean half (and possibly also a quarter of) the size of an integer register...)
That's because they used it specifically in the context of their original 16-bit platform.
They are now stuck with it for 32- and 64-bit platforms.
Serves 'em right!
Learn form their mistake!