I am using a PIC18f4520 and i am trying to use the uart tool on the pickit2 to receive from PIC and print 'Hey' to screen. I am using 9600baud and need to know what delay i need to use in my code and how to use it. This is the code i am using and i am getting nothing on the screen.
#include "p18f4520.h"
#include <usart.h>
#include <delays.h>
#pragma config OSC = INTIO67 // Sets the oscillator mode to HS
#pragma config WDT = OFF // Turns the watchdog timer off
#pragma config MCLRE = OFF // Turns low voltage programming off
void main()
{
long i;
// clock frequency = 8MHz
OSCCONbits.IRCF2 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
TRISC = 0x00;
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 209);
while(1)
{
TRISD=0x00;
LATDbits.LATD1=1;
for (i=0;i<10000;i++);
//Delay1KTCYx(250);
putrsUSART( "Hey" );
LATDbits.LATD1=0;
for (i=0;i<10000;i++);
//Delay1KTCYx(250);
LATDbits.LATD1=1;
//Delay10KTCYx(2000);
}
Any help would be much appreciated.
#include "p18f4520.h"
#include <usart.h>
#include <delays.h>
#pragma config OSC = INTIO67 // Sets the oscillator mode to HS
#pragma config WDT = OFF // Turns the watchdog timer off
#pragma config MCLRE = OFF // Turns low voltage programming off
void main()
{
long i;
// clock frequency = 8MHz
OSCCONbits.IRCF2 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
TRISC = 0x00;
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 209);
while(1)
{
TRISD=0x00;
LATDbits.LATD1=1;
for (i=0;i<10000;i++);
//Delay1KTCYx(250);
putrsUSART( "Hey" );
LATDbits.LATD1=0;
for (i=0;i<10000;i++);
//Delay1KTCYx(250);
LATDbits.LATD1=1;
//Delay10KTCYx(2000);
}
Any help would be much appreciated.