/*******************************************************
FILE:     char-echo.c

DESCRIPTION: Demos serial communication from PIC to a
PC. On the PC, run a terminal program, 19200 baud. Characters
that you type on the PC are echoed, confirming a 2-way serial
path between PIC-chip and PC. 

REVISION HISTORY:  
*******************************************************/
//--Includes

#include <16f88.h>

//--Setup commands

#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,NOWRT,NOLVP  // internal oscillator
#id 0x1234                     // 4 digit id
#use standard_io(A)
#use standard_io(B)
//#use fast_io(A)
//#use fast_io(B)
#use delay(clock=8000000)      // declare clock speed
#use rs232(baud=19200,xmit=PIN_B5,rcv=PIN_B2) // USART


//--Pin definitions

#define LED      PIN_B0   // LED


/*******************************************************
  Main starts here
*******************************************************/

void main(void)
{
  int8 i;
  setup_oscillator(OSC_8MHZ);

//-------Set direction registers

//  set_tris_a(0xFF);   // a is all inputs (for adc)
//  set_tris_b(0xC0);   // b7,b6 in, rest out

//-------Flash led a few times

  for (i=0;i<2;i++) {
    output_high(LED);
    delay_ms(100);
    output_low(LED);
    delay_ms(300);
  }
    

//-------loop forever

  while (TRUE) {
    putc(getc());  // echo character
  }

}



