例如下面这个ISR:
#pragma CODE_SEG NON_BANKED
#pragma TRAP_PROC
void ISR_Spi(void)
{
SPI_data =SPIDR;
(void) SPISR;
}
#pragma CODE_SEG DEFAULT_ROM
因为中断要放到NON_BANKED里,所以ISR开始要加#pragma CODE_SEG NON_BANKED的吧,然后后面的还要放回默认位置,就需要加#pragma CODE_SEG DEFAULT_ROM.
但是上面这段程序会产生一个警告,警告代号C3804,描述是:
Description
A Segment name was recognized which is a predefined one. Predefined segment names are FUNCS, STRINGS, ROM_VAR, COPY, STARTUP, _PRESTART, SSTACK, DEFAULT_RAM, DEFAULT_ROM and _OVERLAP. If you use such segment names, this may raise conflicts during linking.
Example
#pragma CODE_SEG FUNCS // WARNING here
Tips
Use another name. Do not use predefined segment names.