|
|
View previous topic :: View next topic |
Author |
Message |
giuseppe
Joined: 09 Apr 2013 Posts: 6
|
Problem with large data array in ROM and #rom |
Posted: Tue Apr 09, 2013 6:26 am |
|
|
On my PIC24FJ256GA106 project I've defined a large data array for character's map for my LCD graphic display, and I've defined it as constant
Code: |
const char MappaCaratteri[]={
0x00,0x00,0x00,0x00,0x00, //' ' 0x00
0x00,0x00,0x00,0x00,0x00, //' ' 0x01
0x00,0x00,0x00,0x00,0x00, //' ' 0x02
0x00,0x00,0x00,0x00,0x00, //' ' 0x03
0x00,0x00,0x00,0x00,0x00, //' ' 0x04
0x00,0x00,0x00,0x00,0x00, //' ' 0x05
0x00,0x00,0x00,0x00,0x00, //' ' 0x06
0x00,0x00,0x00,0x00,0x00, //' ' 0x07
0x00,0x00,0x00,0x00,0x00, //' ' 0x08
0x00,0x00,0x00,0x00,0x00, //' ' 0x09
0x00,0x00,0x00,0x00,0x00, //' ' 0x0A
0x00,0x00,0x00,0x00,0x00, //' ' 0x0B
0x00,0x00,0x00,0x00,0x00, //' ' 0x0C
0x00,0x00,0x00,0x00,0x00, //' ' 0x0D
0x00,0x00,0x00,0x00,0x00, //' ' 0x0E
0x00,0x00,0x00,0x00,0x00, //' ' 0x0F
0x00,0x00,0x00,0x00,0x00, //' ' 0x10
0x00,0x00,0x00,0x00,0x00, //' ' 0x11
0x00,0x00,0x00,0x00,0x00, //' ' 0x12
0x00,0x00,0x00,0x00,0x00, //' ' 0x13
0x00,0x00,0x00,0x00,0x00, //' ' 0x14
0x00,0x00,0x00,0x00,0x00, //' ' 0x15
0x00,0x00,0x00,0x00,0x00, //' ' 0x16
0x00,0x00,0x00,0x00,0x00, //' ' 0x17
0x00,0x00,0x00,0x00,0x00, //' ' 0x18
0x00,0x00,0x00,0x00,0x00, //' ' 0x19
0x00,0x00,0x00,0x00,0x00, //' ' 0x1A
0x00,0x00,0x00,0x00,0x00, //' ' 0x1B
0x00,0x00,0x00,0x00,0x00, //' ' 0x1C
0x00,0x00,0x00,0x00,0x00, //' ' 0x1D
0x00,0x00,0x00,0x00,0x00, //' ' 0x1E
0x00,0x00,0x00,0x00,0x00, //' ' 0x1F
0x00,0x00,0x00,0x00,0x00, //' ' 0x20
0x00,0x00,0x4F,0x00,0x00, //' ! ' 0x21
0x00,0x07,0x00,0x07,0x00, //' " ' 0x22
0x14,0x7F,0x14,0x7F,0x14, //' # ' 0x23
0x24,0x2A,0x7F,0x2A,0x12, //' $ ' 0x24
0x23,0x13,0x08,0x64,0x62, //' % ' 0x25
0x36,0x49,0x55,0x22,0x50, //' & ' 0x26
0x00,0x05,0x03,0x00,0x00, //' ' ' 0x27
0x00,0x1C,0x22,0x41,0x00, //' ( ' 0x28
0x00,0x41,0x22,0x1C,0x00, //' ) ' 0x29
0x14,0x08,0x3E,0x08,0x14, //' * ' 0x2A
0x08,0x08,0x3E,0x08,0x08, //' + ' 0x2B
0x00,0x50,0x30,0x00,0x00, //' , ' 0x2C
0x08,0x08,0x08,0x08,0x08, //' - ' 0x2D
0x00,0x60,0x60,0x00,0x00, //' . ' 0x2E
0x20,0x10,0x08,0x04,0x02, //' / ' 0x2F
0x3E,0x51,0x49,0x45,0x3E, //' 0 ' 0x30
0x00,0x42,0x7F,0x40,0x00, //' 1 ' 0x31
0x42,0x61,0x51,0x49,0x46, //' 2 ' 0x32
0x21,0x41,0x45,0x4B,0x31, //' 3 ' 0x33
0x18,0x14,0x12,0x7F,0x10, //' 4 ' 0x34
0x27,0x45,0x45,0x45,0x39, //' 5 ' 0x35
0x3C,0x4A,0x49,0x49,0x30, //' 6 ' 0x36
0x01,0x71,0x09,0x05,0x03, //' 7 ' 0x37
0x36,0x49,0x49,0x49,0x36, //' 8 ' 0x38
0x06,0x49,0x49,0x29,0x1E, //' 9 ' 0x39
0x00,0x36,0x36,0x00,0x00, //' : ' 0x3A
0x00,0x56,0x36,0x00,0x00, //' ; ' 0x3B
0x08,0x14,0x22,0x41,0x00, //' < ' 0x3C
0x14,0x14,0x14,0x14,0x14, //' = ' 0x3D
0x00,0x41,0x22,0x14,0x08, //' > ' 0x3E
0x02,0x01,0x51,0x09,0x06, //' ? ' 0x3F
0x32,0x49,0x79,0x41,0x3E, //' @ ' 0x40
0x7E,0x11,0x11,0x11,0x7E, //' A ' 0x41
0x7F,0x49,0x49,0x49,0x36, //' B ' 0x42
0x3E,0x41,0x41,0x41,0x22, //' C ' 0x43
0x7F,0x41,0x41,0x22,0x1C, //' D ' 0x44
0x7F,0x49,0x49,0x49,0x41, //' E ' 0x45
0x7F,0x09,0x09,0x09,0x01, //' F ' 0x46
0x3E,0x41,0x49,0x49,0x7A, //' G ' 0x47
0x7F,0x08,0x08,0x08,0x7F, //' H ' 0x48
0x00,0x41,0x7F,0x41,0x00, //' I ' 0x49
0x20,0x40,0x41,0x3F,0x01, //' J ' 0x4A
0x7F,0x08,0x14,0x22,0x41, //' K ' 0x4B
0x7F,0x40,0x40,0x40,0x40, //' L ' 0x4C
0x7F,0x02,0x0C,0x02,0x7F, //' M ' 0x4D
0x7F,0x04,0x08,0x10,0x7F, //' N ' 0x4E
0x3E,0x41,0x41,0x41,0x3E, //' O ' 0x4F
0x7F,0x09,0x09,0x09,0x06, //' P ' 0x50
0x3E,0x41,0x51,0x21,0x5E, //' Q ' 0x51
0x7F,0x09,0x19,0x29,0x46, //' R ' 0x52
0x46,0x49,0x49,0x49,0x31, //' S ' 0x53
0x01,0x01,0x7F,0x01,0x01, //' T ' 0x54
0x3F,0x40,0x40,0x40,0x3F, //' U ' 0x55
0x1F,0x20,0x40,0x20,0x1F, //' V ' 0x56
0x3F,0x40,0x38,0x40,0x3F, //' W ' 0x57
0x63,0x14,0x08,0x14,0x63, //' X ' 0x58
0x07,0x08,0x70,0x08,0x07, //' Y ' 0x59
0x61,0x51,0x49,0x45,0x43, //' Z ' 0x5A
0x00,0x7F,0x41,0x41,0x00, //' [ ' 0x5B
0x15,0x16,0x7C,0x16,0x15, //' YEN ' 0x5C
0x00,0x41,0x41,0x7F,0x00, //' ] ' 0x5D
0x04,0x02,0x01,0x02,0x04, //' ^ ' 0x5E
0x40,0x40,0x40,0x40,0x40, //' _ ' 0x5F
0x00,0x01,0x02,0x04,0x00, //' ' 0x60
0x20,0x54,0x54,0x54,0x78, //' a ' 0x61
0x7F,0x48,0x44,0x44,0x38, //' b ' 0x62
0x38,0x44,0x44,0x44,0x20, //' c ' 0x63
0x38,0x44,0x44,0x48,0x7F, //' d ' 0x64
0x38,0x54,0x54,0x54,0x18, //' e ' 0x65
0x08,0x7E,0x09,0x01,0x02, //' f ' 0x66
0x0C,0x52,0x52,0x52,0x3E, //' g ' 0x67
0x7F,0x08,0x04,0x04,0x78, //' h ' 0x68
0x00,0x44,0x7D,0x40,0x00, //' i ' 0x69
0x20,0x40,0x44,0x3d,0x00, //' j ' 0x6A
0x7F,0x10,0x28,0x44,0x00, //' k ' 0x6B
0x00,0x41,0x7F,0x40,0x00, //' l ' 0x6C
0x7C,0x04,0x18,0x04,0x78, //' m ' 0x6D
0x7C,0x08,0x04,0x04,0x78, //' n ' 0x6E
0x38,0x44,0x44,0x44,0x38, //' o ' 0x6F
0x7C,0x14,0x14,0x14,0x08, //' p ' 0x70
0x08,0x14,0x14,0x18,0x7C, //' q ' 0x71
0x7C,0x08,0x04,0x04,0x08, //' r ' 0x72
0x48,0x54,0x54,0x54,0x20, //' s ' 0x73
0x04,0x3F,0x44,0x40,0x20, //' t ' 0x74
0x3C,0x40,0x40,0x20,0x7C, //' u ' 0x75
0x1C,0x20,0x40,0x20,0x1C, //' v ' 0x76
0x3C,0x40,0x30,0x40,0x3C, //' w ' 0x77
0x44,0x28,0x10,0x28,0x44, //' x ' 0x78
0x0C,0x50,0x50,0x50,0x3C, //' y ' 0x79
0x44,0x64,0x54,0x4C,0x44, //' z ' 0x7A
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x7B
0x00,0x00,0x7F,0x00,0x00, //' | ' 0x7C
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x7D
0x08,0x08,0x2A,0x1C,0x08, //' ' 0x7E
0x08,0x1C,0x2A,0x08,0x08, //' ' 0x7F
0x07,0x05,0x07,0x00,0x00, //' ° ' 0x80
0x01,0x01,0x01,0x01,0x01, //' trattino alto per il sottolineato ' 0x81
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x82
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x83
0xF0,0x90,0x90,0x90,0x90, // Gaguge Sx 0x84
0x90,0x90,0x90,0x90,0xF0, // Gauge Dx 0x85
0x90,0x90,0x90,0x90,0x90, // Gauge Body 0x86
0x00,0x7F,0x41,0x41,0x41, // quadrato vuoto 0x87
0x41,0x41,0x41,0x7F,0x00, // quadrato vuoto 0x88
0x00,0x7F,0x59,0x71,0x71, // quadrato checkato 0x89
0x59,0x4D,0x47,0x7F,0x00 // quadrato chckato 0x8A
};
|
When taking values using the follow routine the compiler not point to the right array element (but the index value is correct!).
Code: |
void NewLCDSendBigChar(unsigned int8 n, unsigned int8 half, unsigned int8 width)
{
unsigned int16 index;
unsigned int8 i,j;
index = n*5;
for (i=0; i<5; i++)
{
for (j= 0; j<width; j++)
{
if (half == LCD_LOWER)
{
LCD_Draft_Double_Col((MappaCaratteri[index]), LCD_LOWER);
}
else
{
LCD_Draft_Double_Col((MappaCaratteri[index]), LCD_UPPER);
}
}
index = (index +1);
}
for (j= 0; j<width; j++)
{
LCD_Draft_Col(0x00); // blank column between characters
}
}
|
The value obtained by MappaCaratteri[index] (when index = 0) is the previous array value [index -1]. The strange issue is that at successive array readings (index + 1) all the obtained values are correct.
Maybe there's something strange in reading from ROM.
Using the #device CONST=ROM directive the code below works properly but I've other problem with this instruction!
Code: |
SERIAL_ADDR 0x0002ABE0
#rom int16 SERIAL_ADDR= {'0','0','0','0','0','0'}
|
the data at 0x002ABE0 in Program memory will be overwritten by the compiler with "MappaCaratteri" array values.
Anyone know some workaround to do this? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Tue Apr 09, 2013 8:17 am |
|
|
How can you say:
"The value obtained by MappaCaratteri[index] (when index = 0) is the previous array value [index -1]". There is not and cannot be an entry for array-1. Doesn't make sense.
However there are inherent faults in what you do, that may be causing you problems:
index = n*5;
n is an int8. So is '5', so this is going to wrap into the wrong part of the array when n is greater than 51.
index = n*5L;
or
index = (int16)n*5;
are needed to ensure the arithmetic does not overflow.
#ROM, tells the compiler to put an array at an address in ROM. If you do it inside a block of code, a segment will be created, but if you do it outside (as for a global variable), the memory space won't be reserved. Reserve the memory space with an #ORG to avoid it being overwritten.
Best Wishes |
|
|
giuseppe
Joined: 09 Apr 2013 Posts: 6
|
|
Posted: Tue Apr 09, 2013 9:18 am |
|
|
Hi!
I've fixed this potential bug, but I was sure the n cannot be greater than 24.
Ttelmah wrote: | How can you say:
"The value obtained by MappaCaratteri[index] (when index = 0) is the previous array value [index -1]". There is not and cannot be an entry for array-1. Doesn't make sense.
However there are inherent faults in what you do, that may be causing you problems:
index = n*5;
n is an int8. So is '5', so this is going to wrap into the wrong part of the array when n is greater than 51.
index = n*5L;
or
index = (int16)n*5;
are needed to ensure the arithmetic does not overflow.
|
Quote: |
#ROM, tells the compiler to put an array at an address in ROM. If you do it inside a block of code, a segment will be created, but if you do it outside (as for a global variable), the memory space won't be reserved. Reserve the memory space with an #ORG to avoid it being overwritten.
|
I've tried to put in ROM with #org directive like this:
Code: |
org 0x1C00, 0x1F00
char MappaCaratteri[695]={
0x00,0x00,0x00,0x00,0x00, //' ' 0x00
0x00,0x00,0x00,0x00,0x00, //' ' 0x01
0x00,0x00,0x00,0x00,0x00, //' ' 0x02
0x00,0x00,0x00,0x00,0x00, //' ' 0x03
0x00,0x00,0x00,0x00,0x00, //' ' 0x04
0x00,0x00,0x00,0x00,0x00, //' ' 0x05
0x00,0x00,0x00,0x00,0x00, //' ' 0x06
0x00,0x00,0x00,0x00,0x00, //' ' 0x07
0x00,0x00,0x00,0x00,0x00, //' ' 0x08
0x00,0x00,0x00,0x00,0x00, //' ' 0x09
0x00,0x00,0x00,0x00,0x00, //' ' 0x0A
0x00,0x00,0x00,0x00,0x00, //' ' 0x0B
0x00,0x00,0x00,0x00,0x00, //' ' 0x0C
0x00,0x00,0x00,0x00,0x00, //' ' 0x0D
0x00,0x00,0x00,0x00,0x00, //' ' 0x0E
0x00,0x00,0x00,0x00,0x00, //' ' 0x0F
0x00,0x00,0x00,0x00,0x00, //' ' 0x10
0x00,0x00,0x00,0x00,0x00, //' ' 0x11
0x00,0x00,0x00,0x00,0x00, //' ' 0x12
0x00,0x00,0x00,0x00,0x00, //' ' 0x13
0x00,0x00,0x00,0x00,0x00, //' ' 0x14
0x00,0x00,0x00,0x00,0x00, //' ' 0x15
0x00,0x00,0x00,0x00,0x00, //' ' 0x16
0x00,0x00,0x00,0x00,0x00, //' ' 0x17
0x00,0x00,0x00,0x00,0x00, //' ' 0x18
0x00,0x00,0x00,0x00,0x00, //' ' 0x19
0x00,0x00,0x00,0x00,0x00, //' ' 0x1A
0x00,0x00,0x00,0x00,0x00, //' ' 0x1B
0x00,0x00,0x00,0x00,0x00, //' ' 0x1C
0x00,0x00,0x00,0x00,0x00, //' ' 0x1D
0x00,0x00,0x00,0x00,0x00, //' ' 0x1E
0x00,0x00,0x00,0x00,0x00, //' ' 0x1F
0x00,0x00,0x00,0x00,0x00, //' ' 0x20
0x00,0x00,0x4F,0x00,0x00, //' ! ' 0x21
0x00,0x07,0x00,0x07,0x00, //' " ' 0x22
0x14,0x7F,0x14,0x7F,0x14, //' # ' 0x23
0x24,0x2A,0x7F,0x2A,0x12, //' $ ' 0x24
0x23,0x13,0x08,0x64,0x62, //' % ' 0x25
0x36,0x49,0x55,0x22,0x50, //' & ' 0x26
0x00,0x05,0x03,0x00,0x00, //' ' ' 0x27
0x00,0x1C,0x22,0x41,0x00, //' ( ' 0x28
0x00,0x41,0x22,0x1C,0x00, //' ) ' 0x29
0x14,0x08,0x3E,0x08,0x14, //' * ' 0x2A
0x08,0x08,0x3E,0x08,0x08, //' + ' 0x2B
0x00,0x50,0x30,0x00,0x00, //' , ' 0x2C
0x08,0x08,0x08,0x08,0x08, //' - ' 0x2D
0x00,0x60,0x60,0x00,0x00, //' . ' 0x2E
0x20,0x10,0x08,0x04,0x02, //' / ' 0x2F
0x3E,0x51,0x49,0x45,0x3E, //' 0 ' 0x30
0x00,0x42,0x7F,0x40,0x00, //' 1 ' 0x31
0x42,0x61,0x51,0x49,0x46, //' 2 ' 0x32
0x21,0x41,0x45,0x4B,0x31, //' 3 ' 0x33
0x18,0x14,0x12,0x7F,0x10, //' 4 ' 0x34
0x27,0x45,0x45,0x45,0x39, //' 5 ' 0x35
0x3C,0x4A,0x49,0x49,0x30, //' 6 ' 0x36
0x01,0x71,0x09,0x05,0x03, //' 7 ' 0x37
0x36,0x49,0x49,0x49,0x36, //' 8 ' 0x38
0x06,0x49,0x49,0x29,0x1E, //' 9 ' 0x39
0x00,0x36,0x36,0x00,0x00, //' : ' 0x3A
0x00,0x56,0x36,0x00,0x00, //' ; ' 0x3B
0x08,0x14,0x22,0x41,0x00, //' < ' 0x3C
0x14,0x14,0x14,0x14,0x14, //' = ' 0x3D
0x00,0x41,0x22,0x14,0x08, //' > ' 0x3E
0x02,0x01,0x51,0x09,0x06, //' ? ' 0x3F
0x32,0x49,0x79,0x41,0x3E, //' @ ' 0x40
0x7E,0x11,0x11,0x11,0x7E, //' A ' 0x41
0x7F,0x49,0x49,0x49,0x36, //' B ' 0x42
0x3E,0x41,0x41,0x41,0x22, //' C ' 0x43
0x7F,0x41,0x41,0x22,0x1C, //' D ' 0x44
0x7F,0x49,0x49,0x49,0x41, //' E ' 0x45
0x7F,0x09,0x09,0x09,0x01, //' F ' 0x46
0x3E,0x41,0x49,0x49,0x7A, //' G ' 0x47
0x7F,0x08,0x08,0x08,0x7F, //' H ' 0x48
0x00,0x41,0x7F,0x41,0x00, //' I ' 0x49
0x20,0x40,0x41,0x3F,0x01, //' J ' 0x4A
0x7F,0x08,0x14,0x22,0x41, //' K ' 0x4B
0x7F,0x40,0x40,0x40,0x40, //' L ' 0x4C
0x7F,0x02,0x0C,0x02,0x7F, //' M ' 0x4D
0x7F,0x04,0x08,0x10,0x7F, //' N ' 0x4E
0x3E,0x41,0x41,0x41,0x3E, //' O ' 0x4F
0x7F,0x09,0x09,0x09,0x06, //' P ' 0x50
0x3E,0x41,0x51,0x21,0x5E, //' Q ' 0x51
0x7F,0x09,0x19,0x29,0x46, //' R ' 0x52
0x46,0x49,0x49,0x49,0x31, //' S ' 0x53
0x01,0x01,0x7F,0x01,0x01, //' T ' 0x54
0x3F,0x40,0x40,0x40,0x3F, //' U ' 0x55
0x1F,0x20,0x40,0x20,0x1F, //' V ' 0x56
0x3F,0x40,0x38,0x40,0x3F, //' W ' 0x57
0x63,0x14,0x08,0x14,0x63, //' X ' 0x58
0x07,0x08,0x70,0x08,0x07, //' Y ' 0x59
0x61,0x51,0x49,0x45,0x43, //' Z ' 0x5A
0x00,0x7F,0x41,0x41,0x00, //' [ ' 0x5B
0x15,0x16,0x7C,0x16,0x15, //' YEN ' 0x5C
0x00,0x41,0x41,0x7F,0x00, //' ] ' 0x5D
0x04,0x02,0x01,0x02,0x04, //' ^ ' 0x5E
0x40,0x40,0x40,0x40,0x40, //' _ ' 0x5F
0x00,0x01,0x02,0x04,0x00, //' ' 0x60
0x20,0x54,0x54,0x54,0x78, //' a ' 0x61
0x7F,0x48,0x44,0x44,0x38, //' b ' 0x62
0x38,0x44,0x44,0x44,0x20, //' c ' 0x63
0x38,0x44,0x44,0x48,0x7F, //' d ' 0x64
0x38,0x54,0x54,0x54,0x18, //' e ' 0x65
0x08,0x7E,0x09,0x01,0x02, //' f ' 0x66
0x0C,0x52,0x52,0x52,0x3E, //' g ' 0x67
0x7F,0x08,0x04,0x04,0x78, //' h ' 0x68
0x00,0x44,0x7D,0x40,0x00, //' i ' 0x69
0x20,0x40,0x44,0x3d,0x00, //' j ' 0x6A
0x7F,0x10,0x28,0x44,0x00, //' k ' 0x6B
0x00,0x41,0x7F,0x40,0x00, //' l ' 0x6C
0x7C,0x04,0x18,0x04,0x78, //' m ' 0x6D
0x7C,0x08,0x04,0x04,0x78, //' n ' 0x6E
0x38,0x44,0x44,0x44,0x38, //' o ' 0x6F
0x7C,0x14,0x14,0x14,0x08, //' p ' 0x70
0x08,0x14,0x14,0x18,0x7C, //' q ' 0x71
0x7C,0x08,0x04,0x04,0x08, //' r ' 0x72
0x48,0x54,0x54,0x54,0x20, //' s ' 0x73
0x04,0x3F,0x44,0x40,0x20, //' t ' 0x74
0x3C,0x40,0x40,0x20,0x7C, //' u ' 0x75
0x1C,0x20,0x40,0x20,0x1C, //' v ' 0x76
0x3C,0x40,0x30,0x40,0x3C, //' w ' 0x77
0x44,0x28,0x10,0x28,0x44, //' x ' 0x78
0x0C,0x50,0x50,0x50,0x3C, //' y ' 0x79
0x44,0x64,0x54,0x4C,0x44, //' z ' 0x7A
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x7B
0x00,0x00,0x7F,0x00,0x00, //' | ' 0x7C
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x7D
0x08,0x08,0x2A,0x1C,0x08, //' ' 0x7E
0x08,0x1C,0x2A,0x08,0x08, //' ' 0x7F
0x07,0x05,0x07,0x00,0x00, //' ° ' 0x80
0x01,0x01,0x01,0x01,0x01, //' trattino alto per il sottolineato ' 0x81
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x82
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x83
0xF0,0x90,0x90,0x90,0x90, // Gaguge Sx 0x84
0x90,0x90,0x90,0x90,0xF0, // Gauge Dx 0x85
0x90,0x90,0x90,0x90,0x90, // Gauge Body 0x86
0x00,0x7F,0x41,0x41,0x41, // quadrato vuoto 0x87
0x41,0x41,0x41,0x7F,0x00, // quadrato vuoto 0x88
0x00,0x7F,0x59,0x71,0x71, // quadrato checkato 0x89
0x59,0x4D,0x47,0x7F,0x00 // quadrato chckato 0x8A
};
#org default
|
but I've obtained this error:
Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FD LINK="BUCs_Changeover.hex=24LC256.o,GLCD_8802P02012.o,LCD4lines.o,main.o,Manager.o,memory.o,PCComm.o,randomlib.o,serial.o,Startup.o,timers.o,Utilities.o" +DF +LN +T +A +M +Z +Y=9 +EA #__PIC24FJ256GA106__=TRUE
*** Error 71 "BUCs_Changeover.c" Line 1(0,1): Out of ROM, A segment or the program is too large MAIN
Seg 00200-003FE, 0200 left, need 00B74
Any suggestion?
Best regards. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1343
|
|
Posted: Tue Apr 09, 2013 9:53 am |
|
|
In your last example, you created a ram array instead of a rom array by mistake. My guess is that when main goes to initialize the ram array, the code needed pushes the size of main past the allowed boundary. Remember that #org is for organizing ROM, not RAM |
|
|
giuseppe
Joined: 09 Apr 2013 Posts: 6
|
|
Posted: Wed Apr 10, 2013 1:08 am |
|
|
jeremiah wrote: | In your last example, you created a ram array instead of a rom array by mistake. My guess is that when main goes to initialize the ram array, the code needed pushes the size of main past the allowed boundary. Remember that #org is for organizing ROM, not RAM |
How I can declare a ROM array?
I've do in this way.... but this ROM array will not be placed at specified ORG location but at the end of the program memory. Why?
Quote: |
#org 0x1C00, 0x1FFF
rom char MappaCaratteri[]={
0x00,0x00,0x00,0x00,0x00, //' ' 0x00
0x00,0x00,0x00,0x00,0x00, //' ' 0x01
0x00,0x00,0x00,0x00,0x00, //' ' 0x02
0x00,0x00,0x00,0x00,0x00, //' ' 0x03
0x00,0x00,0x00,0x00,0x00, //' ' 0x04
0x00,0x00,0x00,0x00,0x00, //' ' 0x05
0x00,0x00,0x00,0x00,0x00, //' ' 0x06
0x00,0x00,0x00,0x00,0x00, //' ' 0x07
0x00,0x00,0x00,0x00,0x00, //' ' 0x08
0x00,0x00,0x00,0x00,0x00, //' ' 0x09
0x00,0x00,0x00,0x00,0x00, //' ' 0x0A
0x00,0x00,0x00,0x00,0x00, //' ' 0x0B
0x00,0x00,0x00,0x00,0x00, //' ' 0x0C
0x00,0x00,0x00,0x00,0x00, //' ' 0x0D
0x00,0x00,0x00,0x00,0x00, //' ' 0x0E
0x00,0x00,0x00,0x00,0x00, //' ' 0x0F
0x00,0x00,0x00,0x00,0x00, //' ' 0x10
0x00,0x00,0x00,0x00,0x00, //' ' 0x11
0x00,0x00,0x00,0x00,0x00, //' ' 0x12
0x00,0x00,0x00,0x00,0x00, //' ' 0x13
0x00,0x00,0x00,0x00,0x00, //' ' 0x14
0x00,0x00,0x00,0x00,0x00, //' ' 0x15
0x00,0x00,0x00,0x00,0x00, //' ' 0x16
0x00,0x00,0x00,0x00,0x00, //' ' 0x17
0x00,0x00,0x00,0x00,0x00, //' ' 0x18
0x00,0x00,0x00,0x00,0x00, //' ' 0x19
0x00,0x00,0x00,0x00,0x00, //' ' 0x1A
0x00,0x00,0x00,0x00,0x00, //' ' 0x1B
0x00,0x00,0x00,0x00,0x00, //' ' 0x1C
0x00,0x00,0x00,0x00,0x00, //' ' 0x1D
0x00,0x00,0x00,0x00,0x00, //' ' 0x1E
0x00,0x00,0x00,0x00,0x00, //' ' 0x1F
0x00,0x00,0x00,0x00,0x00, //' ' 0x20
0x00,0x00,0x4F,0x00,0x00, //' ! ' 0x21
0x00,0x07,0x00,0x07,0x00, //' " ' 0x22
0x14,0x7F,0x14,0x7F,0x14, //' # ' 0x23
0x24,0x2A,0x7F,0x2A,0x12, //' $ ' 0x24
0x23,0x13,0x08,0x64,0x62, //' % ' 0x25
0x36,0x49,0x55,0x22,0x50, //' & ' 0x26
0x00,0x05,0x03,0x00,0x00, //' ' ' 0x27
0x00,0x1C,0x22,0x41,0x00, //' ( ' 0x28
0x00,0x41,0x22,0x1C,0x00, //' ) ' 0x29
0x14,0x08,0x3E,0x08,0x14, //' * ' 0x2A
0x08,0x08,0x3E,0x08,0x08, //' + ' 0x2B
0x00,0x50,0x30,0x00,0x00, //' , ' 0x2C
0x08,0x08,0x08,0x08,0x08, //' - ' 0x2D
0x00,0x60,0x60,0x00,0x00, //' . ' 0x2E
0x20,0x10,0x08,0x04,0x02, //' / ' 0x2F
0x3E,0x51,0x49,0x45,0x3E, //' 0 ' 0x30
0x00,0x42,0x7F,0x40,0x00, //' 1 ' 0x31
0x42,0x61,0x51,0x49,0x46, //' 2 ' 0x32
0x21,0x41,0x45,0x4B,0x31, //' 3 ' 0x33
0x18,0x14,0x12,0x7F,0x10, //' 4 ' 0x34
0x27,0x45,0x45,0x45,0x39, //' 5 ' 0x35
0x3C,0x4A,0x49,0x49,0x30, //' 6 ' 0x36
0x01,0x71,0x09,0x05,0x03, //' 7 ' 0x37
0x36,0x49,0x49,0x49,0x36, //' 8 ' 0x38
0x06,0x49,0x49,0x29,0x1E, //' 9 ' 0x39
0x00,0x36,0x36,0x00,0x00, //' : ' 0x3A
0x00,0x56,0x36,0x00,0x00, //' ; ' 0x3B
0x08,0x14,0x22,0x41,0x00, //' < ' 0x3C
0x14,0x14,0x14,0x14,0x14, //' = ' 0x3D
0x00,0x41,0x22,0x14,0x08, //' > ' 0x3E
0x02,0x01,0x51,0x09,0x06, //' ? ' 0x3F
0x32,0x49,0x79,0x41,0x3E, //' @ ' 0x40
0x7E,0x11,0x11,0x11,0x7E, //' A ' 0x41
0x7F,0x49,0x49,0x49,0x36, //' B ' 0x42
0x3E,0x41,0x41,0x41,0x22, //' C ' 0x43
0x7F,0x41,0x41,0x22,0x1C, //' D ' 0x44
0x7F,0x49,0x49,0x49,0x41, //' E ' 0x45
0x7F,0x09,0x09,0x09,0x01, //' F ' 0x46
0x3E,0x41,0x49,0x49,0x7A, //' G ' 0x47
0x7F,0x08,0x08,0x08,0x7F, //' H ' 0x48
0x00,0x41,0x7F,0x41,0x00, //' I ' 0x49
0x20,0x40,0x41,0x3F,0x01, //' J ' 0x4A
0x7F,0x08,0x14,0x22,0x41, //' K ' 0x4B
0x7F,0x40,0x40,0x40,0x40, //' L ' 0x4C
0x7F,0x02,0x0C,0x02,0x7F, //' M ' 0x4D
0x7F,0x04,0x08,0x10,0x7F, //' N ' 0x4E
0x3E,0x41,0x41,0x41,0x3E, //' O ' 0x4F
0x7F,0x09,0x09,0x09,0x06, //' P ' 0x50
0x3E,0x41,0x51,0x21,0x5E, //' Q ' 0x51
0x7F,0x09,0x19,0x29,0x46, //' R ' 0x52
0x46,0x49,0x49,0x49,0x31, //' S ' 0x53
0x01,0x01,0x7F,0x01,0x01, //' T ' 0x54
0x3F,0x40,0x40,0x40,0x3F, //' U ' 0x55
0x1F,0x20,0x40,0x20,0x1F, //' V ' 0x56
0x3F,0x40,0x38,0x40,0x3F, //' W ' 0x57
0x63,0x14,0x08,0x14,0x63, //' X ' 0x58
0x07,0x08,0x70,0x08,0x07, //' Y ' 0x59
0x61,0x51,0x49,0x45,0x43, //' Z ' 0x5A
0x00,0x7F,0x41,0x41,0x00, //' [ ' 0x5B
0x15,0x16,0x7C,0x16,0x15, //' YEN ' 0x5C
0x00,0x41,0x41,0x7F,0x00, //' ] ' 0x5D
0x04,0x02,0x01,0x02,0x04, //' ^ ' 0x5E
0x40,0x40,0x40,0x40,0x40, //' _ ' 0x5F
0x00,0x01,0x02,0x04,0x00, //' ' 0x60
0x20,0x54,0x54,0x54,0x78, //' a ' 0x61
0x7F,0x48,0x44,0x44,0x38, //' b ' 0x62
0x38,0x44,0x44,0x44,0x20, //' c ' 0x63
0x38,0x44,0x44,0x48,0x7F, //' d ' 0x64
0x38,0x54,0x54,0x54,0x18, //' e ' 0x65
0x08,0x7E,0x09,0x01,0x02, //' f ' 0x66
0x0C,0x52,0x52,0x52,0x3E, //' g ' 0x67
0x7F,0x08,0x04,0x04,0x78, //' h ' 0x68
0x00,0x44,0x7D,0x40,0x00, //' i ' 0x69
0x20,0x40,0x44,0x3d,0x00, //' j ' 0x6A
0x7F,0x10,0x28,0x44,0x00, //' k ' 0x6B
0x00,0x41,0x7F,0x40,0x00, //' l ' 0x6C
0x7C,0x04,0x18,0x04,0x78, //' m ' 0x6D
0x7C,0x08,0x04,0x04,0x78, //' n ' 0x6E
0x38,0x44,0x44,0x44,0x38, //' o ' 0x6F
0x7C,0x14,0x14,0x14,0x08, //' p ' 0x70
0x08,0x14,0x14,0x18,0x7C, //' q ' 0x71
0x7C,0x08,0x04,0x04,0x08, //' r ' 0x72
0x48,0x54,0x54,0x54,0x20, //' s ' 0x73
0x04,0x3F,0x44,0x40,0x20, //' t ' 0x74
0x3C,0x40,0x40,0x20,0x7C, //' u ' 0x75
0x1C,0x20,0x40,0x20,0x1C, //' v ' 0x76
0x3C,0x40,0x30,0x40,0x3C, //' w ' 0x77
0x44,0x28,0x10,0x28,0x44, //' x ' 0x78
0x0C,0x50,0x50,0x50,0x3C, //' y ' 0x79
0x44,0x64,0x54,0x4C,0x44, //' z ' 0x7A
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x7B
0x00,0x00,0x7F,0x00,0x00, //' | ' 0x7C
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x7D
0x08,0x08,0x2A,0x1C,0x08, //' ' 0x7E
0x08,0x1C,0x2A,0x08,0x08, //' ' 0x7F
0x07,0x05,0x07,0x00,0x00, //' ° ' 0x80
0x01,0x01,0x01,0x01,0x01, //' trattino alto per il sottolineato ' 0x81
0x7F,0x3E,0x1C,0x08,0x00, //' triangolo pieno verso destra ' 0x82
0x00,0x08,0x1C,0x3E,0x7F, //' triangolo pieno verso sinistra ' 0x83
0xF0,0x90,0x90,0x90,0x90, // Gaguge Sx 0x84
0x90,0x90,0x90,0x90,0xF0, // Gauge Dx 0x85
0x90,0x90,0x90,0x90,0x90, // Gauge Body 0x86
0x00,0x7F,0x41,0x41,0x41, // quadrato vuoto 0x87
0x41,0x41,0x41,0x7F,0x00, // quadrato vuoto 0x88
0x00,0x7F,0x59,0x71,0x71, // quadrato checkato 0x89
0x59,0x4D,0x47,0x7F,0x00 // quadrato chckato 0x8A
};
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Wed Apr 10, 2013 2:44 am |
|
|
The way to declare a const array at a location, is:
Code: |
#org 0x1c00,0x1FFF default {}
//This creates a segment occupying the space
const int8 MappaCaratteri[]={
0x00,0x00,0x00,0x00,0x00, //' ' 0x00
0x00,0x00,0x00,0x00,0x00, //' ' 0x01
0x00,0x00,0x00,0x00,0x00, //' ' 0x02
0x00,0x00,0x00,0x00,0x00, //' ' 0x03
0x00,0x00,0x00,0x00,0x00, //' ' 0x04
//etc..
};//This now creates a const table at the required address
#org default
//This now sets the compiler back to using the normal default addresses
void main()
{ //This now locates in the normal locations
}
|
#rom, and rom are different constructs. #rom, tells the compiler to create a raw memory table at an address. If you do this inside a routine, it automatically creates a segment to hold it, but if you do it in the external 'global' declaration area it doesn't. rom, creates a constant table, but with a header table with it to allow pointers to be constructed. The main table will always be constructed in the 'code' area (default).
Const, forms a similar table, in the default area, but without the ability to support pointers.
Why?, because it is not your code. There are two parts to an org declaration. Where your code is to go, and where the compiler is to put it's 'default' parts. This is what the default keyword controls.
Use the default keyword, and your table can be located where you want. Be aware that the table will always be slightly larger than it's entries, since the code to access the table is included in the segment declared.
So, using the declarations above:
Code: |
01C00: CLR 32 //This is the access code.
01C02: MOV #1D0,W3
01C04: SUB W0,W3,W3
01C06: BRA C,1C12
01C08: MOV #1C1C,W3
01C0A: ADD W3,W0,W0
01C0C: TBLRDL.B[W0],W0L
01C0E: CLR.B 1
01C10: RETURN
01C12: MOV #1C1C,W0
01C14: ADD W3,W3,W3
01C16: ADD W3,W0,W3
01C18: TBLRDH [W3],W0
01C1A: RETURN
01C1C: DATA 00,00,15 //This is the actual table
01C1E: DATA 00,00,00
01C20: DATA 00,00,41
01C22: DATA 00,00,41
01C24: DATA 00,00,7F
01C26: DATA 00,00,00
|
The table actually starts at 0x1c1c, with the code to access it in front.
To put it as a 'raw' table, without the ability to access it as an array (have to use read_program_memory instead), but with the compiler stopping other things writing to the same area, use:
Code: |
#org 0x1c00,0x1FFF default {}
#ROM int8 0x1c00={
0x00,0x00,0x00,0x00,0x00, //' ' 0x00
0x00,0x00,0x00,0x00,0x00, //' ' 0x01
0x00,0x00,0x00,0x00,0x00, //' ' 0x02
0x00,0x00,0x00,0x00,0x00, //' ' 0x03
0x00,0x00,0x00,0x00,0x00, //' ' 0x04
0x00,0x00,0x00,0x00,0x00, //' ' 0x05
0x00,0x00,0x00,0x00,0x00, //' ' 0x06
0x00,0x00,0x00,0x00,0x00, //' ' 0x07
0x00,0x00,0x00,0x00,0x00, //' ' 0x08
//etc
}
#org default
//then read the bytes with:
read_program_memory(index+0x1c00,&temp,1);
//where temp is an 8bit variable to hold the value read, and index is the
//array index.
|
The point in both cases is that you have to declare a memory segment at the location you want, that is specified to take your code, _and_ the code the compiler generates.
Best Wishes |
|
|
giuseppe
Joined: 09 Apr 2013 Posts: 6
|
|
Posted: Mon Apr 15, 2013 9:12 am |
|
|
OK, thank you, Now It works... I've some problems with memory organization but I hope to solve also it. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|