Correct settings for C8051f120 microcontroller programs exceeding 64K
December 27 2024
29
Inquiry
Global electronic component supplier AMPHEO PTY LTD: Rich inventory for one-stop shopping. Inquire easily, and receive fast, customized solutions and quotes.
QUICK RFQ
ADD TO RFQ LIST
When writing programs for the C8051F120 microcontroller that exceed 64 KB, you need to configure the memory model and compiler settings correctly, as the C8051F120 uses a 8051-compatible architecture with extended memory addressing capabilities.
When writing programs for the C8051F120 microcontroller that exceed 64 KB, you need to configure the memory model and compiler settings correctly, as the C8051F120 uses a 8051-compatible architecture with extended memory addressing capabilities. Here’s a step-by-step guide:
📚 Understanding the Memory Model in C8051F120
- The C8051F120 microcontroller has 128 KB of Flash memory and 8 KB of internal RAM.
- The 8051 architecture inherently supports up to 64 KB of code memory and 64 KB of external data memory (XDATA).
- Programs exceeding 64 KB require far memory pointers and proper memory banking configuration.
⚙️ Compiler and Linker Settings
1. Enable Extended Memory Model (Far Memory Access)
- In your Keil µVision IDE:
- Go to Project → Options for Target → C/C++ Tab
- Set the Memory Model to Large (Far Pointers).
- Small Model: 64 KB limit
- Large Model: Supports more than 64 KB (far pointers)
2. Enable Far Memory Pointers
- Ensure far pointers are enabled in your compiler directives:
3. Configure the Linker for Larger Memory Spaces
- Go to Project → Options for Target → Linker Tab
- Ensure the Code Banking or Extended Code Memory (xmem) option is enabled.
- In the BL51 Locate Tab:
- Set the Code Memory Range to reflect the entire Flash memory (e.g.,
C:0x0000-0x1FFFF
). - If using banking, configure Code Banking (BANK0, BANK1, etc.).
- Set the Code Memory Range to reflect the entire Flash memory (e.g.,
4. Define Code Banking (If Required)
- Add the following to your linker control file (
L51_BANK.A51
): - Enable BANKED memory mode in your startup code.
5. Modify Startup File
- If using Keil, ensure the Startup Code (STARTUP.A51) is set up for far memory and code banking.
🛠️ Code Example for Memory Access
Accessing Far Memory in C
Memory Management Macros
- Some compilers offer macros for far access:
✅ Verification Checklist
- Memory Model: Set to Large (Far Pointers) in compiler settings.
- Linker Memory Range: Extended to cover the full Flash range.
- Code Banking Enabled (if needed): Set up in startup files and linker scripts.
- Startup File Configured: Ensure it supports large memory models.
- Variables/Functions Defined with
far
: Proper access syntax used.
📝 Final Notes
- Ensure your Linker Map File is reviewed to confirm the proper memory allocation.
- If issues persist, consult the C8051F120 reference manual and Keil µVision documentation for specific configurations.
Populer Posts
PD-9501GR/SP/AC-UK
Microchip Technology
INJ-C200G-60-24-T-AXI
Antaira Technologies
PD-3501G/AC-TW
Microchip Technology
CG-POE-CESAT
Coolgear
SIG FO-EC30040
Signamax
R0X40B
Hewlett Packard Enterprise
PD-6512G/AC/M-US
Microchip Technology
POE60U-1BTE-R
Phihong USA
POE16R-560L6
Phihong USA
PD-9501GC/AC
Microchip Technology
PD-9501GO/FN/AC-IN
Microchip Technology
TRE TPE-104GS
TRENDnet