#include <p18f4550.h>
#include <stdio.h>
#include <delays.h>
#include <spi.h>
#include <usart.h>
/* 4550's settings */
#pragma config WDT = OFF
#pragma config FOSC = INTOSCIO_EC //Internal oscillator, port function on RA6, EC used by USB
#pragma config MCLRE = OFF
#pragma config LVP = OFF
void setup(void)
{
/* Port Set Up*/
ADCON1 = 0b00001111; //set all pins to digital mode
TRISD = 0;
TRISA = 0;
TRISB = 0b00000011; //set RB0 and RB1 as input for SPI communication
TRISC = 0b10000000; // RX is an input, TX is output
/* 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
void main()
{
setup();
while (1)
{
putrsUSART("Hello");
while(BusyUSART());
Delay1KTCYx(1000);
//refresh(red_byte_array,green_byte_array,blue_byte_array);
}
}