PIC C18 compiler error can not fit the section. Solution

Publisher:Xiaoxue666Latest update time:2016-08-28 Source: eefocusKeywords:PIC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
=0x00000606
Errors: 1

I asked an expert and learned that the error was that the RAM allocation exceeded 256B.

Solution 1 is:

1. Open 18f452.lkr.

The RAM allocation is

ACCESSBANK NAME=accessram START=0x0 END=0x7F
DATABANK NAME=gpr0 START=0x80 END=0xFF DATABANK NAME=gpr1 START=0x100 END=0x1FF
DATABANK NAME=gpr2 START=0x200 END=
0x2FF
DATABANK NAME=gpr3 START=0x300 END=0x3FF DATABANK NAME=
gpr4 START=0x400 END=0x4FF
DATABANK NAME=gpr5 START=0x500 END=0x5FF
ACCESSBANK NAME=accesssfr START=0xF80 END=0xFFF PROTECTED

SECTION NAME=CONFIG ROM=config

STACK SIZE=0x100 RAM=gpr5

2. Change the gpr0 range to START=0x80 END=0x4FF

as follows:

DATABANK NAME=gpr0 START=0x80 END=0x4FF

and mask the rest. gpr5 is the stack address and does not need to be changed.

3. Recompile, OK~~

Method 2: Create an array area to store large arrays (refer to the paging in the 18f452.lkr file)
       For MPLAB C18 compiler, data can be placed in data memory or program memory. If there is no
additional code provided by the user, the data in the on-chip program memory can only be read but not written. If there is no additional code provided by the user,
the data in the off-chip program memory can generally only be read or written.
For example, the following statement declares a section for statically allocated uninitialized data (udata) at absolute address
0x120:
#pragma udata my_new_data_section=0x120
The rom keyword tells the compiler that the variable should be placed in program memory. The compiler will allocate this variable to
the current romdata type segment. For example:
#pragma romdata const_table 
const rom char my_const_array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
/* Resume allocation of romdata into the default section */
#pragma romdata
The linker forces the romdata section to be placed in program memory and the udata and idata sections to be placed in data memory;
however, data sections can also be located in specific memory areas. You can use the SECTION directive in the linker script
to allocate a section to a specific memory area.

Method 3: Define data in ROM (ROM is not paged)
Keywords:PIC Reference address:PIC C18 compiler error can not fit the section. Solution

Previous article:pic microcontroller, linker description file (*.lkr) meaning
Next article:pic's further understanding of header files (based on PIC microcontroller C18 compiler)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号