/*******************************************************
FILE:     serial.c

DESCRIPTION: To demo serial communication from PIC to a
PC. On the PC, run a terminal program, 19200 baud.

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<5;i++) {
    output_high(LED);
    delay_ms(100);
    output_low(LED);
    delay_ms(300);
  }
  
  i=48;    //ascii '0'
  
//-------send stream of numbers to terminal, looping forever

//-------loop forever

  while (TRUE) {
    putc(i);
    i++;
    if (i>57) {
      putc(13);  //CR
      putc(10);  //LF
      i=48;    //reset
    }
    delay_ms(25);
  }
}


