|
|
View previous topic :: View next topic |
Author |
Message |
pinton.fabio@tin.it
Joined: 08 Jul 2007 Posts: 6
|
rom mapping of a constant |
Posted: Thu Oct 26, 2017 7:11 am |
|
|
Hi to all,
I've a problem regarding the rom position of a constant.
The code:
Code: |
#include <18F67K22.h>
...
#org 0x00800, 0x00C00, default // <<<------- desired position
rom unsigned int8 Logo1[] ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61,
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 };
rom unsigned int8 Logo2[] ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61,
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 };
#org default // <<<------
unsigned int8 Dsp_Map[DISPLAY_BUF_DIM];
//Put image on display
void Dsp_Logo(rom unsigned int8* pImg)
{
unsigned int16 Ptr;
for(Ptr=0; Ptr<OLED_BUF_DIM; Ptr++)
Dsp_Map[0][Ptr] = pImg[Ptr];
}
#ZERO_RAM
void main() {
//....init diaplay
Dsp_Logo(Logo1);
// Display refresh
} |
If I omit the "org" directive all work as I want but....the compiled put data on bottom of the memory (many time to program...).
If I try to force the compiler to map the constant on a specific position the "org" directive doesn't work to my expectations.
I need to declare the constant with "rom" because I need to pass the address to a function.
The bottom part of flash is reserved to a bootloader so I need to map the data on different addresses.
With the code above it seems that the compiler ignores the directive for the constant, the memory reserved is all 0xFF....any suggestions?
I already tried to declare:
const unsigned int8 ..... but doesn't work with subroutine Dsp_Logo.
Thanks _________________ Fabio |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu Oct 26, 2017 9:22 am |
|
|
If you #build your code offset above your bootloader, it will not place ROM variables below the build address. Perhaps you are not building the code as you should. If you #build with a maximum and minimum memory address, all code will be generated between those addresses, including rom tables.
You can put a rom table at a specific address using #ROM
Something like:
Code: |
#define Logo1 0x800
#define Logo2 0x840
#rom int8 Logo1 ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 , \
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61, \
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 , \
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 }
#rom int8 Logo2 ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 , \
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61, \
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 , \
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 }
|
|
|
|
pinton.fabio@tin.it
Joined: 08 Jul 2007 Posts: 6
|
|
Posted: Fri Oct 27, 2017 1:15 am |
|
|
Hi "Ttelmah",
I try with your suggested code but some error and warning was generated....
Quote: |
*** Error 27 "Graphics.c" Line 26(18,19): Expression must evaluate to a constant
*** Error 43 "Graphics.c" Line 28(2,6): Expecting a declaration
.. |
I've found an alternative way to map the constant on top part of the memory
Code: |
#include <18F67K22.h>
...
const unsigned int8 Logo1[] ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61,
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 };
rom unsigned int8 Logo2[] ={
0xFF, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x61 , 0x61,
0x01, 0x01, 0x01 , 0x01 , 0x01 , 0x01 ,
0xB1 , 0xB1 , 0x01 , 0x01 , 0x01 , 0x01 };
unsigned int8 Dsp_Map[DISPLAY_BUF_DIM];
//Put image on display
void Dsp_Logo(rom unsigned int8* pImg)
{
unsigned int16 Ptr;
for(Ptr=0; Ptr<OLED_BUF_DIM; Ptr++)
Dsp_Map[0][Ptr] = pImg[Ptr];
}
#ZERO_RAM
void main() {
//....init diaplay
Dsp_Logo((rom unsigned int8*)label_address(Logo1)); // <<<-------
// _________________________________________ type cast.....
// Display refresh |
On this way compiler is "free" to fill the program memory from top.
Thanks and regards _________________ Fabio |
|
|
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
|
Posted: Thu Nov 09, 2017 12:12 pm |
|
|
The following test program exemplifies my problem.
I am reading all related info at the forum plus ccs c manual, but till now could not find the right solution
My objective is to find out at execution time the length of the array row, as I will have several arrays, all having different width.
If the arrays are located at RAM, the example attached works all right, but when I move to ROM I get the following error:
*** Error 28 Line 191(63,64): Expecting an identifier.
The manual is clear that there are no pointers to ROM, so I am looking for another way to reach my objective
Sure must be a way, bat I am failing to find [spam]
Thanks for your time
jujoab
Follows silly example
Code: |
#include <16LF1705.h>
char TABLA111 [12] [5] =
{
// tabla ASCII para LCD NOKIA: 96 filas * 5 bytes = 480 bytes
0x20, 0x10, 0x08, 0x04, 0x02, // 2f /
0x3e, 0x51, 0x49, 0x45, 0x3e, // 30 0
0x00, 0x42, 0x7f, 0x40, 0x00, // 31 1
0x42, 0x61, 0x51, 0x49, 0x46, // 32 2
0x21, 0x41, 0x45, 0x4b, 0x31, // 33 3
0x18, 0x14, 0x12, 0x7f, 0x10, // 34 4
0x27, 0x45, 0x45, 0x45, 0x39, // 35 5
0x3c, 0x4a, 0x49, 0x49, 0x30, // 36 6
0x01, 0x71, 0x09, 0x05, 0x03, // 37 7
0x36, 0x49, 0x49, 0x49, 0x36, // 38 8
0x06, 0x49, 0x49, 0x29, 0x1e, // 39 9
0x00, 0x36, 0x36, 0x00, 0x00
}; // 3a :
CHAR TABLA1_LARGE111[13][24] =
{
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, // .
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // /
0x00, 0xfc, 0x7a, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xbc, 0x7e, 0x00, // 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 1
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // 2
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 3
0x00, 0xfc, 0x78, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3d, 0x7e, 0x00, // 4
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 5
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 6
0x00, 0x00, 0x02, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 7
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 8
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00 // 9
};
VOID main (void)
{
INT16 * digit_1, * digit_2 , * digit_3, * digit_4, kkk;
; //uso TABLA1
digit_1 = &TABLA1_LARGE111[0][0];
digit_3 = &TABLA1_LARGE111[1][0];
kkk = digit_3 - digit_1; // # of rows at the array
//uso TABLA1
digit_2 =&TABLA111[0][0];
digit_4 =&TABLA111[1][0];
kkk = digit_4 - digit_2; // # of rows at the other array
WHILE (1)
;
} |
//*** Error 28 Line 191(63 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu Nov 09, 2017 2:09 pm |
|
|
There is a major fault with what you are doing which would stop it working for anything real....
You are declaring pointers to a char array, as being to int16's. The problem here is if you incremented the pointers to get to the next element, they would increment by 16bits, and move forwards two elements. Not good....
For rom, you need:
Code: |
char rom TABLA111 [12] [5] =
{
// tabla ASCII para LCD NOKIA: 96 filas * 5 bytes = 480 bytes
0x20, 0x10, 0x08, 0x04, 0x02, // 2f /
0x3e, 0x51, 0x49, 0x45, 0x3e, // 30 0
0x00, 0x42, 0x7f, 0x40, 0x00, // 31 1
0x42, 0x61, 0x51, 0x49, 0x46, // 32 2
0x21, 0x41, 0x45, 0x4b, 0x31, // 33 3
0x18, 0x14, 0x12, 0x7f, 0x10, // 34 4
0x27, 0x45, 0x45, 0x45, 0x39, // 35 5
0x3c, 0x4a, 0x49, 0x49, 0x30, // 36 6
0x01, 0x71, 0x09, 0x05, 0x03, // 37 7
0x36, 0x49, 0x49, 0x49, 0x36, // 38 8
0x06, 0x49, 0x49, 0x29, 0x1e, // 39 9
0x00, 0x36, 0x36, 0x00, 0x00
}; // 3a :
char rom TABLA1_LARGE111[13][24] =
{
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, // .
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // /
0x00, 0xfc, 0x7a, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xbc, 0x7e, 0x00, // 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 1
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // 2
0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 3
0x00, 0xfc, 0x78, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3d, 0x7e, 0x00, // 4
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 5
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 6
0x00, 0x00, 0x02, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 7
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 8
0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00 // 9
};
VOID main (void)
{
char rom * digit_1, * digit_2 , * digit_3, * digit_4;
int16 kkk;
; //uso TABLA1
digit_1 = &TABLA1_LARGE111[0][0];
digit_3 = &TABLA1_LARGE111[1][0];
kkk = digit_3 - digit_1; // # of rows at the array
//uso TABLA1
digit_2 =&TABLA111[0][0];
digit_4 =&TABLA111[1][0];
kkk = digit_4 - digit_2; // # of rows at the other array
WHILE (1)
;
}
|
You need to be telling the compiler that the pointers are to characters in rom. |
|
|
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
|
Posted: Thu Nov 09, 2017 2:43 pm |
|
|
Ttelmah wrote: | There is a major fault with what you are doing which would stop it working for anything real....
You are declaring pointers to a char array, as being to int16's. The problem here is if you incremented the pointers to get to the next element, they would increment by 16bits, and move forwards two elements. Not good....
You need to be telling the compiler that the pointers are to characters in rom. |
Hi Ttelmah
Perfect. Working alright.
About your comment (you are declaring pointers to a char array, as being to int16's) I agree 100% it is not correct,
but I am using these pointers just to find the number of rows. Once that is known, the pointers will be forgotten and the resulting number of rows will be used by the LCD driver to accept automatically any array size (different font sizes).
Once again, thanks a lot.
jujoab |
|
|
|
|
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
|