maniac84
Full Member level 6
- Joined
- Mar 4, 2012
- Messages
- 337
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,298
- Activity points
- 3,661
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
These 256-byte regions need to be combined into larger regions to fit the new sections:
DATABANK NAME=large_udata START=0x100 END=0x389 PROTECTED
DATABANK NAME=large_idata START=0x38A END=0x519 PROTECTED
DATABANK NAME=gpr5 START=0x51A END=0x5FF
The Optional Keyword PROTECTED is used to identify and area in RAM, that can be assigned only to a variable that are specifically identified in a source code.
#pragma udata NokiaBank // 2 bank = 512 bytes
const char table[480] = {
0x00,0x00,0x00,0x00,0x00, // 20 space ASCII table for NOKIA LCD: 96 rows * 5 shorts= 480 shorts
0x00,0x00,0x5f,0x00,0x00, // 21 ! Note that this is the same set of codes for character you
0x00,0x07,0x00,0x07,0x00, // 22 " would find on a HD44780 based character LCD.
0x14,0x7f,0x14,0x7f,0x14, // 23 # Also, given the size of the LCD (84 pixels by 48 pixels),
0x24,0x2a,0x7f,0x2a,0x12, // 24 $ the maximum number of characters per row is only 14.
0x23,0x13,0x08,0x64,0x62, // 25 %
0x36,0x49,0x55,0x22,0x50, // 26 &
0x00,0x05,0x03,0x00,0x00, // 27 '
0x00,0x1c,0x22,0x41,0x00, // 28 (
... etc ....
0x10,0x08,0x08,0x10,0x08, // 7e Right Arrow ->
0x78,0x46,0x41,0x46,0x78}; // 7f Left Arrow <-
#pragma
// File: 18f46k22_g.lkr
// Generic linker script for the PIC18F46K22 processor
#DEFINE _CODEEND _DEBUGCODESTART - 1
#DEFINE _CEND _CODEEND + _DEBUGCODELEN
#DEFINE _DATAEND _DEBUGDATASTART - 1
#DEFINE _DEND _DATAEND + _DEBUGDATALEN
LIBPATH .
#IFDEF _CRUNTIME
#IFDEF _EXTENDEDMODE
FILES c018i_e.o
FILES clib_e.lib
FILES p18f46k22_e.lib
#ELSE
FILES c018i.o
FILES clib.lib
FILES p18f46k22.lib
#FI
#FI
#IFDEF _DEBUGCODESTART
CODEPAGE NAME=page START=0x0 END=_CODEEND
CODEPAGE NAME=debug START=_DEBUGCODESTART END=_CEND PROTECTED
#ELSE
CODEPAGE NAME=page START=0x0 END=0xFFFF
#FI
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF003FF PROTECTED
#IFDEF _EXTENDEDMODE
DATABANK NAME=gpre START=0x0 END=0x5F
#ELSE
ACCESSBANK NAME=accessram START=0x0 END=0x5F
#FI
DATABANK NAME=gpr0 START=0x60 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=NokiaBank START=0x500 END=0x6FF
// DATABANK NAME=gpr5 START=0x500 END=0x5FF
// DATABANK NAME=gpr6 START=0x600 END=0x6FF
SECTION NAME=NokiaBank RAM=NokiaBank
DATABANK NAME=GrosseBank START=0x700 END=0x9FF
// DATABANK NAME=gpr7 START=0x700 END=0x7FF
// DATABANK NAME=gpr8 START=0x800 END=0x8FF
// DATABANK NAME=gpr9 START=0x900 END=0x9FF
SECTION NAME=GrosseBank RAM=GrosseBank
DATABANK NAME=gprA START=0xA00 END=0xAFF
DATABANK NAME=gprB START=0xB00 END=0xBFF
DATABANK NAME=gprC START=0xC00 END=0xCFF
DATABANK NAME=gprD START=0xD00 END=0xDFF
#IFDEF _DEBUGDATASTART
DATABANK NAME=gprE START=0xE00 END=_DATAEND
DATABANK NAME=dbgspr START=_DEBUGDATASTART END=_DEND PROTECTED
#ELSE //no debug
DATABANK NAME=gprE START=0xE00 END=0xEFF
#FI
DATABANK NAME=gprF START=0xF00 END=0xF37
DATABANK NAME=sfr15 START=0xF38 END=0xF5F PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
#IFDEF _CRUNTIME
SECTION NAME=CONFIG ROM=config
#IFDEF _DEBUGDATASTART
STACK SIZE=0x100 RAM=gprD
#ELSE
STACK SIZE=0x100 RAM=gprE
#FI
#FI
#define MAX_LEN1 128
#define MAX_LEN2 128
#define MAX_LEN3 128
#define MAX_LEN4 120
#pragma udata GrossBank
static unsigned char buffer[MAX_LEN1];
static unsigned char EdfInfo[MAX_LEN2];
static unsigned char Texte[MAX_LEN3];
static unsigned char BT[MAX_LEN4];
#pragma
hello,
have a look on this example for a 18F46K22
very easy with this MCU because a lot of RAM available..
i reserve 512 bytes RAM for a nokia LCD caracteres table..
don't forget, you can not use all of RAM databank, because the C compiler will use some udata or idtata area..
declaration in my C programm
Code:#pragma udata NokiaBank // 2 bank = 512 bytes const char table[480] = { 0x00,0x00,0x00,0x00,0x00, // 20 space ASCII table for NOKIA LCD: 96 rows * 5 shorts= 480 shorts 0x00,0x00,0x5f,0x00,0x00, // 21 ! Note that this is the same set of codes for character you 0x00,0x07,0x00,0x07,0x00, // 22 " would find on a HD44780 based character LCD. 0x14,0x7f,0x14,0x7f,0x14, // 23 # Also, given the size of the LCD (84 pixels by 48 pixels), 0x24,0x2a,0x7f,0x2a,0x12, // 24 $ the maximum number of characters per row is only 14. 0x23,0x13,0x08,0x64,0x62, // 25 % 0x36,0x49,0x55,0x22,0x50, // 26 & 0x00,0x05,0x03,0x00,0x00, // 27 ' 0x00,0x1c,0x22,0x41,0x00, // 28 ( ... etc .... 0x10,0x08,0x08,0x10,0x08, // 7e Right Arrow -> 0x78,0x46,0x41,0x46,0x78}; // 7f Left Arrow <- #pragma
and the modified linker file :
Code:// File: 18f46k22_g.lkr // Generic linker script for the PIC18F46K22 processor #DEFINE _CODEEND _DEBUGCODESTART - 1 #DEFINE _CEND _CODEEND + _DEBUGCODELEN #DEFINE _DATAEND _DEBUGDATASTART - 1 #DEFINE _DEND _DATAEND + _DEBUGDATALEN LIBPATH . #IFDEF _CRUNTIME #IFDEF _EXTENDEDMODE FILES c018i_e.o FILES clib_e.lib FILES p18f46k22_e.lib #ELSE FILES c018i.o FILES clib.lib FILES p18f46k22.lib #FI #FI #IFDEF _DEBUGCODESTART CODEPAGE NAME=page START=0x0 END=_CODEEND CODEPAGE NAME=debug START=_DEBUGCODESTART END=_CEND PROTECTED #ELSE CODEPAGE NAME=page START=0x0 END=0xFFFF #FI CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED CODEPAGE NAME=eedata START=0xF00000 END=0xF003FF PROTECTED #IFDEF _EXTENDEDMODE DATABANK NAME=gpre START=0x0 END=0x5F #ELSE ACCESSBANK NAME=accessram START=0x0 END=0x5F #FI DATABANK NAME=gpr0 START=0x60 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=NokiaBank START=0x500 END=0x6FF // DATABANK NAME=gpr5 START=0x500 END=0x5FF // DATABANK NAME=gpr6 START=0x600 END=0x6FF SECTION NAME=NokiaBank RAM=NokiaBank DATABANK NAME=GrosseBank START=0x700 END=0x9FF // DATABANK NAME=gpr7 START=0x700 END=0x7FF // DATABANK NAME=gpr8 START=0x800 END=0x8FF // DATABANK NAME=gpr9 START=0x900 END=0x9FF SECTION NAME=GrosseBank RAM=GrosseBank DATABANK NAME=gprA START=0xA00 END=0xAFF DATABANK NAME=gprB START=0xB00 END=0xBFF DATABANK NAME=gprC START=0xC00 END=0xCFF DATABANK NAME=gprD START=0xD00 END=0xDFF #IFDEF _DEBUGDATASTART DATABANK NAME=gprE START=0xE00 END=_DATAEND DATABANK NAME=dbgspr START=_DEBUGDATASTART END=_DEND PROTECTED #ELSE //no debug DATABANK NAME=gprE START=0xE00 END=0xEFF #FI DATABANK NAME=gprF START=0xF00 END=0xF37 DATABANK NAME=sfr15 START=0xF38 END=0xF5F PROTECTED ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED #IFDEF _CRUNTIME SECTION NAME=CONFIG ROM=config #IFDEF _DEBUGDATASTART STACK SIZE=0x100 RAM=gprD #ELSE STACK SIZE=0x100 RAM=gprE #FI #FI
and other buffer for communications
in GrosseBank area of 512 bytes (2 banks)
Code:#define MAX_LEN1 128 #define MAX_LEN2 128 #define MAX_LEN3 128 #define MAX_LEN4 120 #pragma udata GrossBank static unsigned char buffer[MAX_LEN1]; static unsigned char EdfInfo[MAX_LEN2]; static unsigned char Texte[MAX_LEN3]; static unsigned char BT[MAX_LEN4]; #pragma
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
These 256-byte regions need to be combined into larger regions to fit the new sections:
DATABANK NAME=large_udata START=0x100 END=0x389 PROTECTED
DATABANK NAME=large_idata START=0x38A END=0x519 PROTECTED
DATABANK NAME=gpr5 START=0x51A END=0x5FF
DATABANK NAME=NokiaBank START=0x500 END=0x6FF PROTECTED
DATABANK NAME=GrosseBank START=0x700 END=0x9FF
DATABANK NAME=NokiaBank START=0x500 END=0x6FF
DATABANK NAME=GrosseBank START=0x700 END=0x9FF PROTECTED
ACCESSBANK NAME=accessram START=0x0 END=0x5F
DATABANK NAME=gpr0 START=0x60 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
DATABANK NAME=udata1 START=0x600 END=0x7FF
//DATABANK NAME=gpr7 START=0x700 END=0x7FF
DATABANK NAME=sfr15 START=0xF53 END=0xF5F PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF
#pragma udata udata1
static BYTE RS485RXDATA[511];
#pragma udata udata1
static BYTE RS485RXDATA[511];
[COLOR="#FF0000"][B]#pragma[/B][/COLOR]
/ rev PF 8_12_2013 pour SD card
// File: 18f26k22_g.lkr
// Generic linker script for the PIC18F26K22 processor
#DEFINE _CODEEND _DEBUGCODESTART - 1
#DEFINE _CEND _CODEEND + _DEBUGCODELEN
#DEFINE _DATAEND _DEBUGDATASTART - 1
#DEFINE _DEND _DATAEND + _DEBUGDATALEN
LIBPATH .
#IFDEF _CRUNTIME
#IFDEF _EXTENDEDMODE
FILES c018i_e.o
FILES clib_e.lib
FILES p18f26k22_e.lib
#ELSE
FILES c018i.o
FILES clib.lib
FILES p18f26k22.lib
#FI
#FI
#IFDEF _DEBUGCODESTART
CODEPAGE NAME=page START=0x0 END=_CODEEND
CODEPAGE NAME=debug START=_DEBUGCODESTART END=_CEND PROTECTED
#ELSE
CODEPAGE NAME=page START=0x0 END=0xFFFF
#FI
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF003FF PROTECTED
#IFDEF _EXTENDEDMODE
DATABANK NAME=gpre START=0x0 END=0x5F
#ELSE
ACCESSBANK NAME=accessram START=0x0 END=0x5F
#FI
DATABANK NAME=gpr0 START=0x60 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
DATABANK NAME=gr6 START=0x600 END=0x6FF
//DATABANK NAME=gpr7 START=0x700 END=0x7FF
//DATABANK NAME=gpr8 START=0x800 END=0x8FF
//DATABANK NAME=gpr9 START=0x900 END=0x9FF
DATABANK NAME=BigBuffer START=0x700 END=0x9FF PROTECTED
DATABANK NAME=gprA START=0xA00 END=0xAFF
DATABANK NAME=gprB START=0xB00 END=0xBFF
DATABANK NAME=gprC START=0xC00 END=0xCFF
DATABANK NAME=gprD START=0xD00 END=0xDFF
#IFDEF _DEBUGDATASTART
DATABANK NAME=gprE START=0xE00 END=_DATAEND
DATABANK NAME=dbgspr START=_DEBUGDATASTART END=_DEND PROTECTED
#ELSE //no debug
DATABANK NAME=gprE START=0xE00 END=0xEFF
#FI
DATABANK NAME=gprF START=0xF00 END=0xF37
DATABANK NAME=sfr15 START=0xF38 END=0xF5F PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
SECTION NAME=BigBuffer RAM=BigBuffer
#IFDEF _CRUNTIME
SECTION NAME=CONFIG ROM=config
#IFDEF _DEBUGDATASTART
STACK SIZE=0x100 RAM=gprD
#ELSE
STACK SIZE=0x100 RAM=gprE
#FI
#FI
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?