#include "main.h"
#include "LCD.c"
#include <string.h>
#use rs232(baud=9600,parity=N,xmit=PIN_C1,rcv=PIN_C0,bits=8,STOP=1, stream = PC2)
#use rs232(baud=300,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=7,STOP=1, stream = PC1)
static unsigned char ReceivedMsg[25];
static unsigned int1 endoftransmission = FALSE;
void Readline();
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
lcd_init();
lcd_putc('\f');
lcd_gotoxy(1,1);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
// TODO: USER CODE!!
fprintf(PC2,"WAITING FOR THE NECCESSARY VALUES");
while(1)
{
while(!endoftransmission){
Readline();
fputs(ReceivedMsg,PC2);
}
}
}
void Readline()
{
memset(ReceivedMsg,0,sizeof(ReceivedMsg));
unsigned char MsgChar;
int k=0;
while(MsgChar != 0x0A)//getch() until LF char received
{
MsgChar = fgetc(PC1);
if(MsgChr=='!')
endoftransmission=TRUE;
ReceivedMsg[k] = MsgChar;
k++;
}
}