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

Function behaves differently... possible bug? ccs 4.023

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



Joined: 27 Feb 2007
Posts: 17

View user's profile Send private message

Function behaves differently... possible bug? ccs 4.023
PostPosted: Mon Mar 19, 2007 5:49 am     Reply with quote

Hello

I have a function that plots points at a graphical LCD 128x64. The interface is OK.



Code:

b=20;
a=10;
glcd_pixel(a,b,ON);
glcd_pixel(a*2,b*2,ON);
glcd_pixel(a*3,b*3,ON);
glcd_pixel(a+1,b-1,ON);
glcd_pixel(a-1,b+1,ON);

Only the first THREE pixels are set at the lcd. The last two don't appear. I have the same problem, if i do this:
Code:

a=10;
for(b=1;b<=20;b++)
{
glcd_pixel(a,b,ON);
}

At this case, nothing is at the screen, where a line should appear.

I can't imagine it is a problem of the glcd managing routine, but at least i put the glcd_pixel routine, which may be the conflictive one.

Code:

void glcd_pixel(int8 x, int8 y, int1 color)
{
   int8* p;
   int16 temp;
   temp =  y/8;
   temp *= 64;
   temp += x;

   if(x > 63)
   {
      p = displayData.right + temp - 64;
   }
   else
   {
      p = displayData.left + temp;
   }

   if(color)
   {
      bit_set(*p, y%8);
   }
   else
   {
      bit_clear(*p, y%8);
   }
}

Where displayData.left and displayData.right are two 512byte arrays. Writing directly at those arrays, and then updating the LCD screen, results in correct data, so LCD fault should be discarded.

I hope you can help me!


PD: This is shocking...

Code:

a=10;
do
{
a++;
glcd_pixel(a,b,ON);
}while(a<=30);

This piece of code does work... and it equals to a for(a=10;a<=30;++a), doesn't it? The for does not work...
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

Re: Function behaves differently... possible bug? ccs 4.023
PostPosted: Mon Mar 19, 2007 6:28 am     Reply with quote

I think your problem is at this lines:

Code:
   int16 temp;
   temp =  y/8;
   temp *= 64;


temp = y/8 and than temp *= 64 is very bad way. First of all you're wasting a division cyle which is the longest math operation.

Also Your code is equal to temp = y * 8 but with a difference. Your implementation truncates some values. Because temp is not a float. Therefore adding or subtracting values which are smaller than 8 generates same values. You should use "temp = y * 8"

Could you try it?
_________________
/// KMT
/// www.muratursavas.com
meepa123



Joined: 27 Feb 2007
Posts: 17

View user's profile Send private message

PostPosted: Mon Mar 19, 2007 6:43 am     Reply with quote

Thanks!

Problem got solved a bit...

Code:

b=20;
a=10;


for(a=1;a<=20;++a)
{
glcd_pixel(a,b,ON);
}

now draws a perfect line, but
Code:

b=20;
a=10;


for(b=1;b<=20;++b)
{
glcd_pixel(a,b,ON);
}

draws random points with some sense of logic... when it just should plot a vertical line.

It's driving me crazy... and the worst of all is, that the driver is from ccs, HDM64GS12.c . I don't know if I am the only person suffering this, but...

thanks!

PD: If I glcd_pixel(0,3,ON) for example, the pixel does not appear there. I think the /8 * 64 has been set intentionally...
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 19, 2007 8:06 am     Reply with quote

it's possibly because of the out of scope values. you should try all the values between 10 and 20 and most probably you'll find a breaking point for those random points. And I guess it will be 16.

This out of scope values probably generating the points after the line you intended. Like using WordWrap with notepad.

I don't have enough brain power to investigate this problem clearly. Because it's monday and I'm reserving some of my gray cells for the movie "300". I'll watch it at the evening Cool
_________________
/// KMT
/// www.muratursavas.com
meepa123



Joined: 27 Feb 2007
Posts: 17

View user's profile Send private message

PostPosted: Mon Mar 19, 2007 9:44 am     Reply with quote

May this be bug?

Code:

b=20;
a=10;
do
{
glcd_pixel(a,b,ON);
a=a+1;
b=b+1;
}while(b!=30);

Does not plot anything

Code:

b=20;
a=10;
do
{
a=a+1;
b=b+1;
glcd_pixel(a,b,ON);
}while(b!=30);

Does plot a diagonal line.

The library used is above. It's very strange. And very annoying. Of course, FOR statements don't plot a single point neither.

PD: tried with 18f4680 and 18f452 and same results.
nome
Guest







PostPosted: Tue Mar 20, 2007 4:00 am     Reply with quote

it may be a bug... dunno what ccs people thinks about it...
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