#include <p1320.h>
#pragma CLOCK_FREQ 8000000
void Rs_Init()
{
//RS Init.
trisb = 0b00010010;
portb = 0x00;
spbrg = 0x0C;
txsta.BRGH = 0;
baudctl.BRG16 = 0;
txsta.SYNC = 0;
rcsta.SPEN = 1;
rcsta.CREN = 1;
txsta.TXEN = 1;
}
void Rs_Send (char tx_char)
{
while(!pir1.TXIF);
txreg = tx_char;
}
void puts(char *source)
{
while (*source != 0) // wait until tx register is empty
Rs_Send(*source++);
Rs_Send(0x0d);
Rs_Send(0x0a);
}
void RxRecv(char *MyTmp)
{
while(!pir1.RCIF); //Not correctly checking Flag even with
//a breakpoint i cant skip this
*MyTmp = rcreg;
Rs_Send(rcreg);
}
void main()
{
//PIC Init.
osccon.IRCF2 = 1; // 8Mhz Clock
osccon.IRCF1 = 1;
osccon.IRCF0 = 1;
Rs_Init();
puts("Hello, world\r\n");
while(1)
{
char Tmp2 = 0x00;
RxRecv(&Tmp2);
}
}