| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| pdswar 
 
 
 Joined: 18 Jul 2006
 Posts: 33
 Location: Maryland, USA
 
 
			    
 
 | 
			
				| porting codes from Microchip C18 compiler to CCS C Compiler |  
				|  Posted: Mon Aug 21, 2006 3:07 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Aug 21, 2006 3:18 pm |   |  
				| 
 |  
				| 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:
 
 
 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Aug 21, 2006 3:33 pm |   |  
				| 
 |  
				| Thank you PCM Programmer 
 Replaced 'byte' with 'data'.
 
 No ERRORS
 |  |  
		|  |  
		| Darren Rook 
 
 
 Joined: 06 Sep 2003
 Posts: 287
 Location: Milwaukee, WI
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Mon Aug 21, 2006 4:35 pm |   |  
				| 
 |  
				| 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.
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |