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

memcpy internal error CCS

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



Joined: 10 Jul 2006
Posts: 3
Location: Melb, Vic, Australia

View user's profile Send private message

memcpy internal error CCS
PostPosted: Mon Jul 10, 2006 12:57 am     Reply with quote

I am trying to drive a 128x64 KS1080 lcd, and am using graphics.c from the examples in CCS 3.150.
However in the graphics.c glcd_text57() gives internal error at memcpy.

int8 j, k, l, m; // Loop counters
int8 pixelData[5]; // Stores character data

for(; *textptr != '\0'; ++textptr, ++x)// Loop through the passed string
{
if(*textptr < 'S') // Checks if the letter is in the first font array
memcpy(pixelData, FONT[*textptr - ' '], 5);

else if(*textptr <= '~') // Check if the letter is in the second font array
memcpy(pixelData, FONT2[*textptr - 'S'], 5);

else
memcpy(pixelData, FONT[0], 5); // Default to space

internal error at the 5

Can anyone help with this please.

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 10, 2006 2:52 pm     Reply with quote

I think there's a problem with memcpy() in your version of the compiler.
The following test program works OK with PCM vs. 3.249, but with vs.
3.150 it gives an "internal error". The problem is the memcpy() in your
version won't accept FONT[m] as the starting address of a row of data
in a two-dimensional array. I tried other syntax, such as &FONT[m][0]
and it won't accept that either. I'm not sure if it's possible to make it
work in your version. You might have to upgrade the compiler.
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

const int8 FONT[3][5] =
{
0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x00, 0x00, 0x5F, 0x00, 0x00, // !
0x00, 0x03, 0x00, 0x03, 0x00, // "
};

int8 pixelData[5];                     

//========================
void main()
{
int8 m;
int8 i;


for(m = 0; m < 3; m++)
   {
    memcpy(pixelData, FONT[m], 5);

    for(i = 0; i < 5; i++)
        printf("%x ", pixelData[i]);

    printf("\n\r");
   }

while(1);
}
appy



Joined: 10 Jul 2006
Posts: 3
Location: Melb, Vic, Australia

View user's profile Send private message

memcpy error
PostPosted: Mon Jul 10, 2006 8:04 pm     Reply with quote

PCM programmer,

Thank you for this, I have been wracking my mind over it.
Is is possible to write a memcpy function and include it in string.h for ver 3.150?

Thanks again

appy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 10, 2006 9:02 pm     Reply with quote

The problem is that you can't pass a pointer to a constant string in CCS.

As a work-around, you can edit the glcd_text57() function in the
Graphics.c file. Comment out the three lines that have memcpy()
statements and put in the code shown in the for() loops. You also
have to add an int8 variable 'i' for a loop counter.

Code:

{
int8 j, k, l, m;             
int8 pixelData[5];         
int8 i;        // Add this line

if(*textptr < 'S')
  {
   // memcpy(pixelData, FONT[*textptr - ' '], 5);
   for(i = 0; i < 5; i++)    // Add this line
       pixelData[i] = FONT[*textptr - ' '][i]; // Add line
  }
else if(*textptr <= '~')
  {
   // memcpy(pixelData, FONT2[*textptr - 'S'], 5);
   for(i = 0; i < 5; i++)   // Add this line
       pixelData[i] = FONT[*textptr - 'S'][i]; // Add line
  }
else
  {
   // memcpy(pixelData, FONT[0], 5);   
   for(i = 0; i < 5; i++)     // Add this line
       pixelData[i] = FONT[0][i];    // Add this line
  }
appy



Joined: 10 Jul 2006
Posts: 3
Location: Melb, Vic, Australia

View user's profile Send private message

memcpy error
PostPosted: Tue Jul 11, 2006 5:44 pm     Reply with quote

PCM programmer,

Thank you this patch has worked very well.

appy
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