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

Serial port input code... could be my hardware hook up

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







Serial port input code... could be my hardware hook up
PostPosted: Thu Feb 17, 2005 10:00 pm     Reply with quote

Code:


#include <16F876.h>

//set fuses

#fuses HS,NOWDT,NOPROTECT,PUT//,//BROWNOUT,NOLVP

#use delay(clock=20000000)// 20mhz clock

//set up PC communications
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7)

void main()
{

char input;
int input_pos =0;
int temp_input=0;
     printf("\n\rStart\n\r",input);
     printf("Booting\n\r",input);
 do {
     input=getc();

     if (input == '1') temp_input =temp_input + 1+10^input_pos;
     if (input == '2') temp_input =temp_input + 2+10^input_pos;
     if (input == '3') temp_input =temp_input + 3+10^input_pos;
     if (input == '4') temp_input =temp_input + 4+10^input_pos;
     if (input == '5') temp_input =temp_input + 5+10^input_pos;
     if (input == '6') temp_input =temp_input + 6+10^input_pos;
     if (input == '7') temp_input =temp_input + 7+10^input_pos;
     if (input == '8') temp_input =temp_input + 8+10^input_pos;
     if (input == '9') temp_input =temp_input + 9+10^input_pos;
     input_pos++;   
     printf("Got Char\n\r");
     printf("%C",input);
 
   } while(input !='x' |input !='X' );


while(true)
{printf("%d\n\r",temp_input);}

}




it prints out "starting booting", but nothing after that.. I think its my hardware, but I want to see if anyone sees anything wrong with my code.

Nick
Nick
Guest







PostPosted: Thu Feb 17, 2005 10:22 pm     Reply with quote

yup it was hardware.. code has errors because it never exits the first loop on 'x' or 'X'
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