Papizo
Junior Member level 1
Hi guys am doing this project Vehicle security system with theft control and Accident Notification so before I start anything I want to test my PIC16F877A if is going to work with CCS C, so I want to test my 2 LED blinking I have found program online which will work but is not working at all
main.c
so when am trying to compile getting this error
So what is the problem with my code? can you show me where I have done wrong please...
main.c
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 // PIC16F877A LED Blinking //=============================================================== //device definition header file #include <16F877A.h> #include "htc.h" //device configuration bit __CONFIG(0x3F3A); //define #define LED1 RB7 #define LED2 RB6 //function prototype void blink_LED1(unsigned char n); void blink_LED2(unsigned char n); //main function //================================================================ void main(void) { //device peripheral configuration TRISB7=0; //set RB7 as output TRISB6=0; //set RB6 as output //infinity loop while(1) { //blink LED1 for 3 times blink_LED1(3); //blink LED2 for 3 times blink_LED2(3); } } //function to blink LED1 for n times void blink_LED1(unsigned char n) { //loop for n times for(n+=1;n>0;n-=1) { //set LED1 to 1 LED1=1; //short delay for(unsigned int i=0;i<20000;i+=1); //max value is 65535 //set LED1 to 1 LED1=0; //short delay for(unsigned int i=0;i<20000;i+=1); //max value is 65535 } } //function to blink LED2 for n times void blink_LED2(unsigned char n) { //loop for n times for(n+=1;n>0;n-=1) { //set LED2 to 1 LED2=1; //short delay for(unsigned int i=0;i<20000;i+=1); //max value is 65535 //set LED2 to 1 LED2=0; //short delay for(unsigned int i=0;i<20000;i+=1); //max value is 65535 } } header filer //=============================================================== //device definition header file #include <htc.h> //device configuration bit __CONFIG(0x3F3A); //define #define LED1 RB7 //main function //================================================================ void main(void) { //device peripheral configuration TRISB7=0; //infinity loop while(1) { //set LED1 to 1 LED1=1; //short delay for(unsigned int i=0;i<30000;i+=1); //set RB7 to 0 LED1=0; //short delay for(unsigned int i=0;i<30000;i+=1); } }
so when am trying to compile getting this error
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" "main.c" +FM +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 17 "C:\Users\User\Desktop\mplab\htc.h" Line 4(10,11): Too many nested #INCLUDEs
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Fri Oct 26 14:26:32 2012
So what is the problem with my code? can you show me where I have done wrong please...
Last edited by a moderator: