need urgent help....PIC C lite

Thread Starter

riad_00

Joined Feb 9, 2008
19
Hi,

I m trying to learn pic c lite. Here is a simple program to flash a LED.

HTML:
#include <pic.h>
_CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT 
   &
   MCLRDIS &PWRTEN WDTDIS & INTIO);
   
   int i;
   
   main()
   {
	   PORTA = 0;
	   CMCON0 = 0;
	   ANSEL = 0;
	   TRISA4 = 0;
	   TRISA5 = 0;
	   while (1=1)
	   {
		   for i=0; i<25000; i++;
		   RA4 = RA4^1;
		   
	    }
	    
    }
And the output for the program is given below.

HTML:
Build E:\New Folder\flash for device 16F84
Using driver C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe

Executing: "C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe" -C "E:\New Folder\flash.c" --chip=16F84 -P --opt=default -q -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s" 
Error   [194] E:\New Folder\flash.c; 2.16 ")" expected
Warning [349] E:\New Folder\flash.c; 4.32 non-prototyped function declaration for "_CONFIG"
Error   [313] E:\New Folder\flash.c; 4.32 function body expected
Error   [192] E:\New Folder\flash.c; 11.1 undefined identifier "CMCON0"
Error   [192] E:\New Folder\flash.c; 12.1 undefined identifier "ANSEL"
Error   [192] E:\New Folder\flash.c; 14.1 undefined identifier "TRISA5"
Error   [202] E:\New Folder\flash.c; 15.11 only lvalues may be assigned to or modified
Error   [317] E:\New Folder\flash.c; 17.5 "(" expected
Error   [195] E:\New Folder\flash.c; 17.6 expression syntax
Error   [194] E:\New Folder\flash.c; 17.22 ")" expected

********** Build failed! **************
Can some body tell me plz what I am doing wrong here !!!!
 

hgmjr

Joined Jan 28, 2005
9,027
Hi,

I m trying to learn pic c lite. Here is a simple program to flash a LED.

HTML:
#include <pic.h>
_CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT 
   &
   MCLRDIS &PWRTEN WDTDIS & INTIO);
 
   int i;
 
   main(void)  /* <----------  */
   {
       PORTA = 0;
       CMCON0 = 0;
       ANSEL = 0;
       TRISA4 = 0;
       TRISA5 = 0;
       while (1=1)
       {
           for (i=0; i<25000; i++);  /*  <----  */
           RA4 = RA4^1;
 
        }
 
    }
And the output for the program is given below.

HTML:
Build E:\New Folder\flash for device 16F84
Using driver C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe
 
Executing: "C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe" -C "E:\New Folder\flash.c" --chip=16F84 -P --opt=default -q -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s" 
Error   [194] E:\New Folder\flash.c; 2.16 ")" expected
Warning [349] E:\New Folder\flash.c; 4.32 non-prototyped function declaration for "_CONFIG"
Error   [313] E:\New Folder\flash.c; 4.32 function body expected
Error   [192] E:\New Folder\flash.c; 11.1 undefined identifier "CMCON0"
Error   [192] E:\New Folder\flash.c; 12.1 undefined identifier "ANSEL"
Error   [192] E:\New Folder\flash.c; 14.1 undefined identifier "TRISA5"
Error   [202] E:\New Folder\flash.c; 15.11 only lvalues may be assigned to or modified
Error   [317] E:\New Folder\flash.c; 17.5 "(" expected
Error   [195] E:\New Folder\flash.c; 17.6 expression syntax
Error   [194] E:\New Folder\flash.c; 17.22 ")" expected
 
********** Build failed! **************
Can some body tell me plz what I am doing wrong here !!!!
You might try these minor changes.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
Hi,

I m trying to learn pic c lite. Here is a simple program to flash a LED.

HTML:
#include <pic.h>
_CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT 
   &
   MCLRDIS &PWRTEN WDTDIS & INTIO);
 
   int i;
 
   main()
   {
       PORTA = 0;
       CMCON0 = 0;
       ANSEL = 0;
       TRISA4 = 0;
       TRISA5 = 0;
       while (1)                  /* <----------  */
       {
           for i=0; i<25000; i++;
           RA4 = RA4^1;
 
        }
 
    }
Can some body tell me plz what I am doing wrong here !!!!
oh yeah! And this change also.

hgmjr
 

Thread Starter

riad_00

Joined Feb 9, 2008
19
I have tried the corrected code but didn't work. Here is the result again,

HTML:
#include <pic.h>
_CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT 
   &
   MCLRDIS &PWRTEN WDTDIS & INTIO);
 
   int i;
 
   main(void)
   {
       PORTA = 0;
       CMCON0 = 0;
       ANSEL = 0;
       TRISA4 = 0;
       TRISA5 = 0;
       while (1)                  /* <----------  */
       {
           for i=0; i<25000; i++;
           RA4 = RA4^1;
 
        }
 
    }
Output....

HTML:
Build C:\New Folder\flash for device 16F84
Using driver C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe

Executing: "C:\Program Files\HI-TECH Software\PICC\LITE\9.60\bin\picl.exe" -C "C:\New Folder\flash.c" --chip=16F84 -P --opt=default -q -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s" 
Error   [194] C:\New Folder\flash.c; 2.16 ")" expected
Warning [349] C:\New Folder\flash.c; 4.32 non-prototyped function declaration for "_CONFIG"
Error   [313] C:\New Folder\flash.c; 4.32 function body expected
Error   [192] C:\New Folder\flash.c; 11.1 undefined identifier "CMCON0"
Error   [192] C:\New Folder\flash.c; 12.1 undefined identifier "ANSEL"
Error   [192] C:\New Folder\flash.c; 14.1 undefined identifier "TRISA5"
Error   [317] C:\New Folder\flash.c; 17.5 "(" expected
Error   [195] C:\New Folder\flash.c; 17.6 expression syntax
Error   [194] C:\New Folder\flash.c; 17.22 ")" expected

********** Build failed! **************

I don't know what to do now !!!:(
 

nanovate

Joined May 7, 2007
666
change your config macro to...

Rich (BB code):
__CONFIG( FCMDIS & IESODIS & BORDIS & UNPROTECT & MCLRDIS & PWRTEN & WDTDIS & INTIO );
 

AlexR

Joined Jan 16, 2008
732
Read your error report! It tell you that the compiler knows nothing about various register names. This implies that you need to include a header file that is specific to the PIC you are using and contains definitions of register names and addresses.
Once you get the program to compile you can sort out your pragma fuse setting command which has a couple of typos in it. Also if you want to see the LED blink you will need to add some sort of delay in the toggle loop.

I just followed my own advice and had a close look at your error report.
It says that its compiling code for a PIC16F84!
The 16F84 does not have an ANSEL register and although I've not checked I suspect that neither does it have the other registers that the compiler is complaining about.
 

Thread Starter

riad_00

Joined Feb 9, 2008
19
Thanks for the replies,

HTML:
#include <pic.h>
__CONFIG( FCMDIS & IESODIS & BORDIS & UNPROTECT & MCLRDIS & PWRTEN & WDTDIS & INTIO );
 
   int i;
 
   main(void)
   {
       PORTA = 0;
       
       TRISA = 0;
       
       while (1)                  /* <----------  */
       {
           for i=0; i<25000; i++;     /* Error
			{
           		RA4 = RA4^1;
			}
 	   }
 
    }
The error it's showing up there. But this is the right format (for i=0; i<25000; i++; ) isn't!!!
 
what is the aim of this code? are you just trying to flash a LED or you are trying to flash a LED the hard way?!! what is wrong with something as simple as this:

#include <htc.h>
#include <pic.h>
#include <delay.c>

void Wait_A_Second(void)
{
int j;
for(j=1;j<=4;j++)
{
DelayMs(250);
}
}

main()
{
TRISB=0; // port b is output, you can use A if u want

for(;;)//do forever
{
RB0=0;
Wait_A_Second();
RB0=1;
Wait_A_Second();
}
}// end main
 
Last edited:
Assuming you're (or were) very new to c and PICs, just like me, you've probably wanted to get started just like me and got the same problem:

You have selected the flash code from the examples on the PicKit CD and try to build your own project. That code is for 16F684 and if your PIC is e.g. 16F84 the header pic.h redirects to (pic 1684.h) does not contain a CMCON0, but lots of other thingies, so you have to find the corresponding one to build you project.

I'm using a 16F690 and try to compile with the Hi-Tech compiler, which doesnt have a PIC16F690.h header available so I guess it uses the PIC16F6x.h, am I right?

edit: it uses pic16F685.h. For you other newcomers: Look in the pic.h to see which header file it redirects to for you very PIC.

Comparing the two enormous data sheets of the PIC in the example (16F684) and my 16F690, I found that C1ON and C2ON = 0 did the same job for the 16F690 as the CMCON0 = 0 did for the 16F684.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Daniel, you've pulled up a thread that's been dead for six months. Doubtful that the OP is still "listening".

You should start your own thread to avoid confusion.
 
Top