#include <p18f4620.h>
#include <stdio.h>
#include <delays.h>
#include <usart.h>
#pragma config OSC = HS, LVP=OFF ,MCLRE =ON
void setup(void)
{
/* Port Set Up*/
ADCON1 = 0b00001111; //set all pins to digital mode
TRISD = 0;
TRISA = 0;
TRISB = 0b00000000;
TRISC = 0b10000000; // RX is an input, TX is output
PORTBbits.RB0=1; // turn on the 4 LEDS
PORTBbits.RB1=1;
PORTBbits.RB2=1;
PORTBbits.RB3=1;
/* Interrupt Setup */
INTCON = 0x00; /* Clear Registers */
PIR1 = 0x00;
PIE1 = 0x00;
TMR1L = 0x00;
TMR1H = 0x00;
T1CON = 0x00;
RCON = 0x00;
/* RS232 Enable */
RCSTA = 0b10000000;
TXSTA = 0b00100000;
BAUDCON = 0b00000000;
//SPBRG = 51; //FOSC = 8.000 MHz,SYNC = 0, BRGH = 0, BRG16 = 0
OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 51);
/* Clock Setup*/
OSCCON = 0b01110110; //select 8 MHz clock
}
#pragma code
void main(void)
{
setup();
while (1)
{
putrsUSART("Hello");
// while(BusyUSART());
Delay1KTCYx(1000);
}
}