![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
munchiez
Joined: 22 May 2011 Posts: 3
|
Porting Code for GLCD |
Posted: Sun May 22, 2011 10:08 am |
|
|
I'm trying to port code that working in C18 to CCS but haven't had any luck. It to display a bitmap on the SED1335 controller based GLCD. I can display 5x7 fonts in the library that CCS provided and draw some basic shapes. But bitmaps are a no go right now. I've look through various threads and here's what I've come up but the code isn't displaying anything. I'm porting it as I need to use the PIC16F877 for this project and not the 18F4520 which can work with C18 code below.
C18 Routines from en.radzio.dxp.pl:
Routine to Display Bitmaps which is working on my PIC18F4520:
Code: | void GLCD_Bitmap(rom const unsigned char * bmp, int x, int y, int width, int height)
{
unsigned int i, j;
for(i = 0; i < height ; i++)
{
GLCD_GraphicGoTo(x, y+i);
GLCD_WriteCommand(SED1335_MWRITE);
for(j = 0; j < width/8; j++)
GLCD_WriteData(GLCD_ReadByteFromROMMemory(bmp+j+(40*i)));
}
} |
Code: | unsigned char GLCD_ReadByteFromROMMemory(rom const unsigned char * ptr)
{
return *ptr;
} |
Calling the function:
Code: | GLCD_Bitmap((rom const unsigned char *) nus, 0, 0, 320, 240); |
Data stored as:
Code: | rom far const unsigned char nus[9600] = {...}; |
Here my CCS Code:
Routine to Display Bitmaps on my PIC16F877 not working:
Code: | void glcd_bitmap(unsigned int16 addr, unsigned int16 x, unsigned int16 y, unsigned int16 width, unsigned int16 height)
{
int16 i, j;
char tmp;
for(i = 0; i < height ; i++)
{
glcd_graphic_goto(x, y+i);
glcd_sendByte(GLCD_CMD_DISPLAY_WRITE);
for(j = 0; j < width/8; j++)
{
tmp = read_eeprom(addr+j+(40*i));
output_low(GLCD_A0); //Sets up for Data Mode
glcd_sendByte(tmp);
}
}
} |
Calling the function:
Code: | glcd_bitmap(0x0000, 0, 0, 320, 240); |
Data stored as:
Code: | #rom 0x2100 = {....} |
The CCS program leaves a blank screen where the bitmap supposed to be. Many thanks for all everyone's help!! ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 22, 2011 1:52 pm |
|
|
Quote: |
I'm porting it as I need to use the PIC16F877 for this project.
#rom 0x2100 = {....}
tmp = read_eeprom(addr+j+(40*i));
void glcd_bitmap(unsigned int16 addr, unsigned int16 x, unsigned int16 y, unsigned int16 width, unsigned int16 height)
glcd_bitmap(0x0000, 0, 0, 320, 240);
|
Are you aware that this is 'data eeprom' and the 16F877 only has 256
bytes of it ? It looks like you're trying to draw a huge 320x240 bitmap
(which takes 9600 bytes) with only 256 bytes of data eeprom.
Do you actually want the bitmap to be stored in Flash ROM ? The 16F877
has 8192 14-bit words of that. What are the dimensions of the bit map
that you actually want to draw ? 9600 bytes is too much for the 16F877.
The 18F4520 has 32K bytes of Flash ROM.
Quote: | glcd_bitmap(0x0000, 0, 0, 320, 240); |
What does this 0x0000 address mean ? What does it refer to ?
Post a clickable link to the C18 code so I can see the whole thing and
get a better idea of what you want to do.
Also post your compiler version. The version number looks like the
ones in this list:
http://www.ccsinfo.com/devices.php?page=versioninfo |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Sun May 22, 2011 4:19 pm |
|
|
The code he is porting is ARM/AVR code not PIC. He got it from here:
http://en.radzio.dxp.pl/sed1335/index.html _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 22, 2011 5:05 pm |
|
|
How about, instead using that code, use the CCS sed1335 driver.
Here's the file location:
Quote: |
c:\program files\picc\drivers\sed1335.c
|
The current compiler version (vs. 4.121) has all the bug fixes listed in
this post, incorporated into the driver code. So it probably will work:
http://www.ccsinfo.com/forum/viewtopic.php?t=40867
You could use the CCS driver, and in this post, MikeP has got code to
draw a bitmap. He stores the bitmap data in Flash ROM.
http://www.ccsinfo.com/forum/viewtopic.php?t=40834&start=25
Using CCS code would be a lot faster than trying to port some generic
code. Just make sure you use a late version of CCS so it has the bug
fixes in sed1335.c. |
|
![](templates/subSilver/images/spacer.gif) |
munchiez
Joined: 22 May 2011 Posts: 3
|
|
Posted: Sun May 22, 2011 8:10 pm |
|
|
PCM programmer wrote: | Are you aware that this is 'data eeprom' and the 16F877 only has 256
bytes of it ? It looks like you're trying to draw a huge 320x240 bitmap
(which takes 9600 bytes) with only 256 bytes of data eeprom.
Do you actually want the bitmap to be stored in Flash ROM ? The 16F877
has 8192 14-bit words of that. What are the dimensions of the bit map
that you actually want to draw ? 9600 bytes is too much for the 16F877.
The 18F4520 has 32K bytes of Flash ROM. |
I was quite confused about this. I read that the 18F4520 also has 256 bytes too but somehow it managed to store it somewhere within the uC with the rom directive.
Code: | glcd_bitmap(0x0000, 0, 0, 320, 240); |
I tested writing a bunch of number like #rom 0x2100 = {1,2,3,4,5,4,3,2,1} and printing on my glcd it worked using 0x0000 as the address of the first number. Then I tried loading the bitmap with #rom when it fell apart. 0x0000 means the start of the rom?
Yup, I'm using the driver from the CCS compiler to draw and display everything else just the bitmap. I'm using 4.106 gonna update it soon if this is the problem.
Thanks alot to all ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
munchiez
Joined: 22 May 2011 Posts: 3
|
|
Posted: Sun May 22, 2011 9:02 pm |
|
|
Tried Mike's method, I'm afraid 14K of words ain't gonna cut it. I tried to lower it from 9600 to 4266 but it still ain't working. But this time CCS says there's no room in the ram :(
Thanks alot PCM! |
|
![](templates/subSilver/images/spacer.gif) |
MikeP
Joined: 07 Sep 2003 Posts: 49
|
|
Posted: Mon May 23, 2011 3:49 pm |
|
|
The code I made is simple way to display a splash screen for your project.
How much gfx data do you need access to?
As PCM programmer already said program code plus gfx data is to much for the pic you are trying to use.
You going to only be able to draw the top half of your screen you want to play and/or learn if forced to use the PIC16F877 until you can get a hold of a bigger PIC16 chip.
Use the #rom int8 option in the manual it says #rom defaults to 16bit(really?) without it and don't use char as it will pack two bytes into one 14 bit word. The default option will waste rom and the char option will mess with your data.
You have to split the gfx data into 2048 byte chunks, trying to write it as one big one will give you out rom errors. I am pretty sure this is why I did that.
If you are going to set the rom address yourself you need to set it to the first free block of PROGRAM MEMORY ADDRESS.
Try this we will leave 4k for C code in program memory
Code: |
#rom int8 0x1000 = {....}
#rom int8 0x1800 = {....}
|
Also change the read_eeprom function to read_program_eeprom in your glcd_bitmap
function.
Code: |
glcd_bitmap(0x1000, 0, 0, 320, 120);
|
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|