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

URGENT

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







URGENT
PostPosted: Tue Apr 25, 2006 1:59 pm     Reply with quote

I am using a PIC16F874. When I program the PIC it shows the error-There are more program codes at <EEO> after <EDF>.

Some part of my code doesnot work.is it due to this?
How do i fix this??
thanx
marc
my code:

// You must include the header file for the PIC
#include <16F874.H>

// Setting the number of Hz the PIC is at
#use delay(clock=20000000)

// Initializing variables
char event;
int distance, count;
float temp;

void main()
{
enable_interrupts(INT_rb);
enable_interrupts(global);
output_low(PIN_E0);
count = 0;


while(1){

if(event == 's' || event == 'r' || event == 'g' || event == 'h'){
while(event == 's')
{
count = 2000;
//motor forward
output_high(PIN_D3);
output_low(PIN_D2);
delay_ms(1);
//count = 1000; // worked with 0


}



if(event == 'g')


{
//Turn transmitter on
output_high(PIN_E0);

temp = 9*((4000 + count)/(2000));
distance = (int) temp;

switch(distance) //outputting data to wireless
{


case 65 :
output_high(PIN_C0);
output_high(PIN_C6);
break;

case 64 :
output_high(PIN_C6);
break;

case 63:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 62:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 61:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 60:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
break;

case 59:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 58:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C1);
break;

case 57:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C0);
break;

case 56:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C3);
break;

case 55:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 54:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 53:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 52:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C2);
break;

case 51:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 50:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C1);
break;

case 49:
output_high(PIN_C5);
output_high(PIN_C4);
output_high(PIN_C0);
break;

case 48:
output_high(PIN_C5);
output_high(PIN_C4);
break;

case 47:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 46:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 45:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 44:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C2);
break;

case 43:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 42:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C1);
break;

case 41:
output_high(PIN_C5);
output_high(PIN_C3);
output_high(PIN_C0);
break;

case 40:
output_high(PIN_C5);
output_high(PIN_C3);
break;

case 39:
output_high(PIN_C5);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 38:
output_high(PIN_C5);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 37:
output_high(PIN_C5);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 36:
output_high(PIN_C5);
output_high(PIN_C2);
break;

case 35:
output_high(PIN_C5);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 34:
output_high(PIN_C5);
output_high(PIN_C1);
break;

case 33:
output_high(PIN_C5);
output_high(PIN_C0);
break;

case 32:
output_high(PIN_C5);
break;

case 31:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 30:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 29:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 28:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C2);
break;

case 27:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 26:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C1);
break;

case 25:
output_high(PIN_C4);
output_high(PIN_C3);
output_high(PIN_C0);
break;

case 24:
output_high(PIN_C4);
output_high(PIN_C3);
break;

case 23:
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 22:
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 21:
output_high(PIN_C4);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 20:
output_high(PIN_C4);
output_high(PIN_C2);
break;

case 19:
output_high(PIN_C4);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 18:
output_high(PIN_C4);
output_high(PIN_C1);
break;

case 17:
output_high(PIN_C4);
output_high(PIN_C0);
break;

case 16:
output_high(PIN_C4);
break;

case 15:
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 14:
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 13:
output_high(PIN_C3);
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 12:
output_high(PIN_C3);
output_high(PIN_C2);
break;

case 11:
output_high(PIN_C3);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 10:
output_high(PIN_C3);
output_high(PIN_C1);
break;

case 9:
output_high(PIN_C3);
output_high(PIN_C0);
break;

case 8:
output_high(PIN_C3);
break;

case 7:
output_high(PIN_C2);
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 6:
output_high(PIN_C2);
output_high(PIN_C1);
break;

case 5:
output_high(PIN_C2);
output_high(PIN_C0);
break;

case 4:
output_high(PIN_C2);
break;

case 3:
output_high(PIN_C1);
output_high(PIN_C0);
break;

case 2:
output_high(PIN_C1);
break;

case 1:
output_high(PIN_C0);
break;

case 0:
output_low(PIN_C7);
output_low(PIN_C6);
output_low(PIN_C5);
output_low(PIN_C4);
output_low(PIN_C3);
output_low(PIN_C2);
output_low(PIN_C1);
output_low(PIN_C0);
break;


default :
output_high(PIN_C7);
}
output_low(PIN_D3);
output_high(PIN_D2);



}

}





if (event == 'h'){

output_low(PIN_D3); // stop motor
output_low(PIN_D2);
delay_ms(500);

//motor forward
//output_high(PIN_D3);
//output_low(PIN_D2);
//delay_ms(25);

//output_low(PIN_D3); // stop motor
//output_low(PIN_D2);

output_high(PIN_C7); //operation complete
delay_ms(500);

//reset values
output_low(PIN_C7);
output_low(PIN_C6);
output_low(PIN_C5);
output_low(PIN_C4);
output_low(PIN_C3);
output_low(PIN_C2);
output_low(PIN_C1);
output_low(PIN_C0);

delay_ms(500);
//turn off transmitter/
output_low(PIN_E0);
delay_ms(500);

count = 0;
distance = 0;
event = 'r';

}
}

}







#int_rb
rb_isr ( )

{

// Initializing everything
byte changes;
int last_b;
int port_b;
changes = last_b ^ port_b;
last_b = port_b;

// if bob hit grain
if (!input(PIN_b6)){event = 'g';
}

// if bob is at housing
if (!input(PIN_b5)){event = 'h';

}

// if start
if (!input(PIN_b4)){event = 's';}

//debounce
delay_ms(100);


}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 25, 2006 2:07 pm     Reply with quote

"Urgent" probably means homework. But here's one small tip:

You have tons and tons of code which outputs the 'distance' to Port C.
Why not just do it with one line of code ? Like this:

Code:
output_c(distance);
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed Apr 26, 2006 8:04 am     Reply with quote

Yep it's getting to the end of the school year and this board will be expected to do term papers. Many might think that due to the large number of repetitive questions ( Ex RS232 issues) that the search function on this board must be broken.
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