CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Table in ROM PIC18

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rolox



Joined: 25 Dec 2014
Posts: 33

View user's profile Send private message

Table in ROM PIC18
PostPosted: Sat Nov 07, 2015 8:09 am     Reply with quote

Hi,
i know, its a repeating topic, but could not find solution.
I'm changing from a PIC16F1877 to a PIC18F26K20
Changes in source are quite few - but i can't get my ROM tables work, the are created in RAM :-(

this line places a table in ROM for PIC16F :

Code:
char rom Font32x48Data1[]={ 0x01,0x02,0x03 ....}

Accessing via pointer works perfect.

But the same line puts Data into RAM (as i can see at the given RAM usage after compiling) , but all filled with 0x00 (as checked while debugging..

any hints ?
best regards
Roland
Ttelmah



Joined: 11 Mar 2010
Posts: 19494

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 8:39 am     Reply with quote

Classic first line for reply:

"What compiler version?".

It certainly doesn't put the data in RAM on any version I have here.

Just tried with the font from my ssd1306 driver, and simple code:
Code:

#include <18F26k20.h>
#device ADC=10
#use delay(crystal=20000000)

char rom font[] =
{
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char 
//.....140 font entries.
        0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE       //final one closing shape 140
};
//540 byte array

void main()
{
   int8 test,ctr;
   while(TRUE)
   {
      for (ctr=0;ctr<sizeof(font);ctr++)
         test=*(font+ctr);     
   }
}

and it is using 6 bytes of RAM. and 720 bytes ROM for the whole program.....
rolox



Joined: 25 Dec 2014
Posts: 33

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 9:56 am     Reply with quote

compiler is 5.051 ...pretty up-to-date....

your example is the construction i'm using too ...
tried it with my font files too ...and fonts go to ROM as expected.
Now i have to check where the difference is to the "big" code ...

best regrads
Roland
rolox



Joined: 25 Dec 2014
Posts: 33

View user's profile Send private message

PostPosted: Sat Nov 07, 2015 10:34 am     Reply with quote

i can reproduce the effect in my "big" code, but not in a small test program.
If i include my font files in a method as follows, the RAM is used :

Code:
void InitFonts()
{
   #ifdef USE_FLASH
       //do something
   #else
      #include "font 32x48.c"
      //do something else
   #endif
}


if i place the #ifdef statement OUTSIDE the function call, everything works as expected.
But : if i use this small method in a small example code, it works too.
And it worked with the PIC16. Anyway ...i'm happy with the solution so far.
best regards
Roland
Ttelmah



Joined: 11 Mar 2010
Posts: 19494

View user's profile Send private message

PostPosted: Sun Nov 08, 2015 2:41 am     Reply with quote

#including the file inside a routine, implies the variable will become local. Now it shouldn't really cause the behaviour you are seeing, but in some ways it makes a sort of warped 'sense', since a pointer accessible constant has to exist globally (after all it is constant).
It is worthy of reporting to CCS, if you can generate a repeatable example that does it...

At least you know how to work round this:
Code:

#ifndef USE_FLASH
   #include "font 32x48.c"
#endif

void InitFonts()
{
   #ifdef USE_FLASH
       //do something
   #else
      //do something else
   #endif
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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