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.
Hello, I'm using a 8051 chip with 2K of internal data RAM (T89C51SND1). (I'm not using any external memory). May I know how should I set the IDATALEN, XDATASTART, XDATALEN variable in the startup.a51 file? Is this extended internal memory (after 256bytes) considered as IDATA or XDATA? How should I address it in C code? Regards KC
In 8051 architectural lingo, "external" and "internal" data really have nothing to do with where the memory is physically located. They're just two different memory spaces, addressed by different instructions and/or addressing modes. (Historically, "internal" data really was internal to the chip, and "external" data is often in a separate RAM chip, but, as with your part, there's no reason you can't integrate it all on a single die.) Glancing at the data sheet, it looks like your part has 256 bytes of internal RAM (128 bytes of "data" and 128 bytes of "idata") and 2K bytes of external RAM ("xdata"), which happens to be implemented on the same chip. See the "Data Memory" section on page 14 of the data sheet, where they note that it's 256 + 2048 bytes in two separate areas. Don't be confused by the rest of the data sheet that likes to show a total single block of 2304 bytes. I'd say you've got an IDATALEN of 100H, XDATASTART of 0H, and XDATALEN of 800H, if you want the Keil startup code to zero out all the memory for you. To use the different memory spaces in Keil C, you'd just the extra keywords to declare variables as data / idata / xdata. The compiler will take care of the details of using the different instructions and modes to access each memory space. It's worth being aware of how it actually works, because there are significant differences in efficiency (both time and space) for the internal and external data accesses. "data" space is the first 128 bytes of internal RAM, directly addressable. "idata" space is the second 128 bytes of internal RAM, addressable only indirectly. (Direct addressing in this address range maps to the SFR memory space instead.) "xdata" space is the 2k block of memory, accessed by loading the DPTR register (DPH and DPL) and using a MOVX instruction. You didn't ask, but "pdata" is a single 256-byte page of the xdata memory, addressed via indirection through R0 and R1, so it's a bit more efficient than XDATA. The upper 8 bits of the 16-bit address into XDATA usually come from the I/O port 2 (P2) register. On a quick look, I don't see a user guide on the Atmel web site that covers the 8051 programming model in more depth than the data sheet. So, take a look at this one for the Dallas parts. Just ignore all the Dallas-specific periperhals, and read the sections on the architecture and programming model, say sections 3-6. http://pdfserv.maxim-ic.com/arpdf/Design/hsmicro_userguide.pdf