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 support@ccsinfo.com

Repetitive pattern on GLCD
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Wed Feb 08, 2017 5:34 am     Reply with quote

Your changes did work, PCM programmer. Even though by placing all the font of a certain size occupies of the RAM more, as predicted. Is there any other way to display letters that doesn't include the placing all the font inside the RAM?
Because what I am encountering right now is that I can not include any other size that is higher that Tahoma 10 because of RAM space. And, of course, I can not include different font sizes because that implies the usage of too much RAM.

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Feb 08, 2017 6:22 am     Reply with quote

It should work if you declare the array as rom, rather than const, and change the pointer declarations in the calls to char rom *.
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 1:08 pm     Reply with quote

Ttelmah wrote:
It should work if you declare the array as rom, rather than const, and change the pointer declarations in the calls to char rom *.


i have stored the font successfully in the rom but idk how to call it. When I use it a random set of pixels appears were the font should be. Any ideas how to successfully call the stored font?

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 11:20 pm     Reply with quote

Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.

Changes are shown in bold below:

In the font_tahoma.h file:
Quote:
unsigned char rom Tahoma10[] =


Function prototypes in the main file:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font);


The declaration of the draw_text() function:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.


The declaration of the draw_char() function:
Quote:
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Sun Feb 12, 2017 4:26 pm     Reply with quote

PCM programmer wrote:
Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.

Changes are shown in bold below:

In the font_tahoma.h file:
Quote:
unsigned char rom Tahoma10[] =


Function prototypes in the main file:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font);


The declaration of the draw_text() function:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.


The declaration of the draw_char() function:
Quote:
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.


Hi PCM programmer, I did also try this solution but forgot to get rid off the "unsigned char" thing, thank you Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Feb 13, 2017 2:41 am     Reply with quote

It should have worked with the "unsigned char". However the declarations in the function definitions would need to be "rom unsigned char *". It's a bit of a 'black art' (unfortunately poorly documented), with the order having to be 'just right' or it won't compile or work correctly. By omitting the type (as PCM_programmer shows), the compiler 'assumes' int8 *, which happens to be treated identically to unsigned char *, so works and is a lot shorter to type...... Where the declaration would be needed, is if declaring something of a different size in rom (int16, int32 etc.).
One of those 'very poorly documented' abilities/features. Very useful (allowing you to work with tables of stuff stored in rom, without having to use a ram buffer), but requiring 'practice' to make work correctly. Smile
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Mon Feb 13, 2017 9:51 am     Reply with quote

By now trying this rom sol'n on the display itself nothing appears where the letters should be. My compiler version is 4.104. Rolling Eyes
Any ideas on why?

thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Feb 13, 2017 9:59 am     Reply with quote

Ouch 4.104...

There were quite a lot of problems with V4 around this point.

Historically V4, only started working reasonably around 4.059. Then around 4.099, they had several versions with faults again. The use of rom pointers, was a new feature, only introduced about then (about 4.090), and it didn't work reliably for quite a few versions... Sad
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Feb 13, 2017 10:23 am     Reply with quote

I may have maligned it.
Just tried a basic test accessing data declared in rom, and with a rom * pointer, and it works OK.
You need to do some basic debugging.
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Tue Feb 14, 2017 8:23 am     Reply with quote

Ttelmah wrote:
I may have maligned it.
Just tried a basic test accessing data declared in rom, and with a rom * pointer, and it works OK.
You need to do some basic debugging.


Can it be something to do with that I am trying to display letters from the ROM and RAM at the same time?
jaume
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Feb 14, 2017 8:43 am     Reply with quote

Undoubtedly.

You need to rethink your code. Fundamental understanding of the PIC needed. The PIC uses a Harvard architecture. The ROM and the RAM are in two different address spaces. This is different from chips like the Intel 808x and it's derivatives, which have a 'unified' memory architecture (Von Neumann architecture). On these latter chips, everything has a unique address, with RAM and ROM at different points in the address range. On the PIC this isn't the case. There is an 'address 0' in ROM, and another in RAM. You can't mix addresses from one to the other. This is why there is a separate rom pointer type.
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Tue Feb 21, 2017 9:17 am     Reply with quote

PCM programmer wrote:
Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.

Changes are shown in bold below:

In the font_tahoma.h file:
Quote:
unsigned char rom Tahoma10[] =


Function prototypes in the main file:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font);


The declaration of the draw_text() function:
Quote:
bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.


The declaration of the draw_char() function:
Quote:
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.


When here you say "functions prototype in the main file" you mean that have to be made also in the <graphic.h> file in addition to the changes made to the <graphics.h> and in the <font_tahoma.h>? I have been trying it out lately and when the changes are made in the above mentioned files nothing appears where the letters should be.

If when here you say "functions prototype in the main file" you mean in the <main.c> file, it says not enough RAM when writing the code in the void main loop, as expected.
Any ideas how to fix this?
thanks
jaume
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 21, 2017 11:37 am     Reply with quote

Quote:
If when here you say "functions prototype in the main file" you mean in the <main.c> file

Yes, I mean in main.c.
If you have function prototypes, wherever they are located, they and
the actual function declarations must match. If the function has 'rom'
in the declaration, then so must the prototype.

Quote:

it says not enough RAM when writing the code in the void main loop, as expected

Why would it be "as expected" ? Didn't you place the font files in 'rom' ?
They might use up a lot of ROM (flash memory), but not ram.
I don't know what is in your program. Maybe you added code to use up
all the RAM.
jamalavedra



Joined: 25 Oct 2016
Posts: 62

View user's profile Send private message

PostPosted: Tue Feb 21, 2017 11:45 am     Reply with quote

Well it says that there is not enough space for all the variables when I write it in the void main() but not when written out of the loop.
Not sure why I said as expected there.
Shouldn't this change from unsigned char*font to rom*char be also made in <graphics.h> ?

thanks
jaume
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 21, 2017 12:02 pm     Reply with quote

I looked at page 2 of this thread, at graphics.h, and it has function
prototypes that have the font array as a parameter. So yes, if the font
array is declared as 'rom', then you must edit all functions and function
prototypes to declare *font as 'rom'.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5  Next
Page 3 of 5

 
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