Nick Guest
|
Serial port input code... could be my hardware hook up |
Posted: Thu Feb 17, 2005 10:00 pm |
|
|
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 |
|