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

porting codes from Microchip C18 compiler to CCS C Compiler

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



Joined: 18 Jul 2006
Posts: 33
Location: Maryland, USA

View user's profile Send private message

porting codes from Microchip C18 compiler to CCS C Compiler
PostPosted: Mon Aug 21, 2006 3:07 pm     Reply with quote

The following is portion of a code that was written for Microchip C18 compiler while using PIC18C601/801 microcontroller.

..................................................................................

const char ROMpict[3][24][5];

char LineNow = 0; //Line counter for NKKsmartswitch
char Buffer = 0; // buffer for shifting out to NKKsw
char ucByte; // byte counter, 5 bytes per line
int uiCtrR = 0; // count display updates (red LED)
int uiCtrG = 0; // count display updates (grn LED)
int uiCtrP = 0; // count display updates (picture)
char ucPicture=0; // picture 0 will be displayed
char RAMarray[24][5];


void LeftShiftNKKDat(unsigned char byte)
{
DIN=((byte & 0x80)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x40)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x20)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x10)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x08)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x04)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x02)!=0);
SCP = 1;
SCP = 0;
DIN=((byte & 0x01)!=0);
SCP = 1;
SCP = 0;
}


void PlayROMInv(char ucPictNum)
{
for (ucByte=0;ucByte<=4;ucByte++)
{
Buffer=~(ROMpict[ucPictNum][LineNow][ucByte]); //Load Buffer
LeftShiftNKKDat(Buffer);
}
}

void PlayROMNom(char ucPictNum)
{
for (ucByte=0;ucByte<=4;ucByte++)
{
Buffer=ROMpict[ucPictNum][LineNow][ucByte]; //Load Buffer
LeftShiftNKKDat(Buffer);
}
}

void PlayRAMNom(void)
{
for (ucByte=0;ucByte<=4;ucByte++)
{
Buffer=RAMarray[LineNow][ucByte]; //Load Buffer
LeftShiftNKKDat(Buffer);
}
}

---------------------------------------------------------------
When I tried to modify the above codes into following, so that I can use it for PIC 18F6722 with CCS C Compiler, I am recieving 100 Errors which says

-Expecting an identifier

-Expecting a declaration (95% of errors)

----------------------------------------------------------------
#define FLM PIN_F3 //FLM is on PORTF,3 (first line)
#define LP PIN_F2 // LP is on PORTF,2 (line load)
#define SCP PIN_F1 //SCP is on PORTF,1 (clock)
#define DIN PIN_F0 //DIN is on PORTF,0 (data in)
#define BLED PIN_F5 //Blue LED (low is on)
#define DOUT PIN_F4 //DOUT is on PORTF,4 (data in)


void LeftShiftNKKDat(char byte)
{
output_bit(DIN,((byte & 0x80)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x40)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x20)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x10)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x08)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x04)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x02)!=0));
output_high(SCP);
output_low(SCP);
output_bit(DIN,((byte & 0x01)!=0));
output_high(SCP);
output_low(SCP);
}


Should I use bit_test(byte) instead of ((byte & 0xXX)!=0)?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 21, 2006 3:18 pm     Reply with quote

Don't use words like "byte" as a variable name. "Byte" is a data type.
CCS has this statement in all of its include files:
Quote:
#define BYTE int


In CCS, "byte" is the same as "int" (which is an unsigned 8-bit value).

Choose variable names which are not keywords.
pdswar



Joined: 18 Jul 2006
Posts: 33
Location: Maryland, USA

View user's profile Send private message

PostPosted: Mon Aug 21, 2006 3:33 pm     Reply with quote

Thank you PCM Programmer

Replaced 'byte' with 'data'.

No ERRORS
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

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

PostPosted: Mon Aug 21, 2006 4:35 pm     Reply with quote

Or -

use #case to make the compiler case sensitive, so byte the variable has a different name than BYTE the definition.
_________________
I came, I saw, I compiled.
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