/*******************************************************/
/*
/* EE400 - Interface Assignment 1 - Hello World
/* Group 27
/* November 13, 2007
/*
/********************************************************/
#include <p30f4011.h>
#include <p30fxxxx.h>
/**********************/
/* CONFIGURATION BITS
/**********************/
_FOSC(CSW_FSCM_OFF & FRC); //use internal fast RC oscillator
_FWDT(WDT_OFF); //disable WDT
_FBORPOR(PBOR_OFF); //disable brownout
_FGS(CODE_PROT_OFF); //disable code protection
int main()
{
/******************/
/* CONFIGURE UART
/******************/
U2MODE = 0b1000000000000000; //Enable UART2, 8-bit, no-parity, stop bit, everything else disabled
//U2BRG = 0x002F; //set baud rate to 9600bps at 7.37MHz (FRC oscillator)
U2BRG = 47; //set baud rate to 9600bps at 7.37MHz (FRC oscillator)
/*********************/
/* MAIN PROGRAM LOOP
/*********************/
char Message[] = " Hello World!"; //string to be sent over UART
int n;
do
{
for(n = 0; Message[n] != '!'; n++)
{
while(U2STAbits.UTXBF==1); //make sure TX buffer not full before loading in more data
U2TXREG=Message[n++]; //load next character into TX buffer and increment character counter
}
} while(1); //repeat sending "Hello World" over UART forever
return(0);
}