Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error when converting graphic LCD routine to CCS C Compiler

Status
Not open for further replies.

Sobakava

Full Member level 6
Full Member level 6
Joined
Mar 27, 2002
Messages
350
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Activity points
3,342
PIC C Code Conversion

I'm converting a graphic LCD routine to CCS C Compiler:

Code:
void LCD_PutPixel(unsigned char x, unsigned char y, unsigned char Set)
{
unsigned int XY;
unsigned char bitByte;

   XY=0x200;
   XY=XY+(y*40);
   XY=XY+(x/6);

   LCD_SendData(XY & 0x00FF);
   LCD_SendData(XY>>8);
   LCD_SendCmd(0x24);      	//pointer set

   bitByte=5-(x % 6);

  Set? bitByte|=0xF8: bitByte|=0xF0;            

   LCD_SendCmd(bitByte);   //0b1111SXXX , s is set/reset, xxx is bit   
   ///number xxx 
   //(Each memorybyte i six graphics bits (pixels))
}


CCS Did not recognized this line:
      Set? bitByte|=0xF8: bitByte|=0xF0; 

is it the same thing with:

   if (Set==0) { bitByte|=0xf8;}
   else
      {bitByte|=0xf0;}

or should it be:
   if (Set==1) { bitByte|=0xf8;}
   else
      {bitByte|=0xf0;}



?
 

Re: PIC C Code Conversion

The last of your examples is almost correct, but not completely the same as Set?.




Code:
Set? bitByte|=0xF8: bitByte|=0xF0;
is it the same as:

Code:
if (Set)
   bitByte|=0xF8;       //If Set is true (not zero), i.e. 1, 2, 3 etc.
else 
   bitByte|=0xF0;       //If Set is false (zero).

You can also write if (Set != 0) it's the same thing as if (Set)

But you should not write if (Set == 1), that's not the same, because the if statement is true for every value different from 0, not only 1, but also 2, 3 etc.

Maybe Set can have the value 2, then the if statment should still be true, like it is when you write Set?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top