ProFPGA
Banned
I am trying to write a rountine for pic18f4523 in C using ccs-picc.
i couldnt find anything like getch() for capturing a integer input via RS 232 ??
Does anyone have a hint how i can achieve it like refer to the following piece of code :
#include <18F4523.h>
#include <stdio.h>
#use delay(internal=8M)// internal oscillator 8Mhz
#fuses NOWDT
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=,bits=8)
// using internal oscillator with CKO at RA6
int menu(void);
void main()
{
while(1)
{
switch (menu()) {
case 1: {
output_bit(PIN_A0,1);
delay_ms(1000);
output_bit(PIN_A0,0);
break;
}
case 2: {
output_bit(PIN_A1,1);
delay_ms(1000);
output_bit(PIN_A1,0);
break;
}
case 3: {
output_bit(PIN_A2,1);
delay_ms(1000);
output_bit(PIN_A2,0);
break;
}
default: {
output_bit(PIN_A0,0);
output_bit(PIN_A1,0);
output_bit(PIN_A2,0);
break;
}
}
}
///////User Selection Menu//////////////////////////////
int menu(unsigned int)
{
unsigned int ch;
printf ("\n\r Press A to turn LED on RA0 .......");
printf ("\n\r Press B to turn LED on RA1 .......");
printf ("\n\r Press C to turn LED on RA2 .......");
ch = getc(); //wait for and get serial character
delay_ms(100);
return ch;
}
/////////////////////////////////////////////////////////
/// it gives me an error that numeric should appear next to menu ????
i couldnt find anything like getch() for capturing a integer input via RS 232 ??
Does anyone have a hint how i can achieve it like refer to the following piece of code :
#include <18F4523.h>
#include <stdio.h>
#use delay(internal=8M)// internal oscillator 8Mhz
#fuses NOWDT
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=,bits=8)
// using internal oscillator with CKO at RA6
int menu(void);
void main()
{
while(1)
{
switch (menu()) {
case 1: {
output_bit(PIN_A0,1);
delay_ms(1000);
output_bit(PIN_A0,0);
break;
}
case 2: {
output_bit(PIN_A1,1);
delay_ms(1000);
output_bit(PIN_A1,0);
break;
}
case 3: {
output_bit(PIN_A2,1);
delay_ms(1000);
output_bit(PIN_A2,0);
break;
}
default: {
output_bit(PIN_A0,0);
output_bit(PIN_A1,0);
output_bit(PIN_A2,0);
break;
}
}
}
///////User Selection Menu//////////////////////////////
int menu(unsigned int)
{
unsigned int ch;
printf ("\n\r Press A to turn LED on RA0 .......");
printf ("\n\r Press B to turn LED on RA1 .......");
printf ("\n\r Press C to turn LED on RA2 .......");
ch = getc(); //wait for and get serial character
delay_ms(100);
return ch;
}
/////////////////////////////////////////////////////////
/// it gives me an error that numeric should appear next to menu ????