PIC USART Problems

crazyengineer

Joined Dec 29, 2010
156
Hello everyone. I'm trying to write hello world to a serial program. However, when I ran the following code

Rich (BB code):
#include <p18F2420.h>
#include <delays.h>
#include <usart.h>
#pragma config OSC = INTIO67
#pragma config WDT = OFF
#pragma config LVP = OFF

void main()
{
TRISC=0x00;
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE &USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 51);
while(1)
{
while(BusyUSART());
putrsUSART("Hello");
}

}

Keep in mid I'm using the internal osc of the PIC18F2420.
I see nothing displayed in the serial program, but the cursor moves

MrChips

Joined Oct 2, 2009
19,273
Have you made certain that the two baud rates are the same?
Try using an external xtal instead of the internal oscillator.

crazyengineer

Joined Dec 29, 2010
156
Works perfectly now. Just the confusion of the internal clock was messing me up. I switched to an external 20MHZ clock the whole thing works marvelously!

Last edited:

t06afre

Joined May 11, 2009
5,936
If you use Hi-Tech C you must define the clock frequency in your code.

lawncegary

Joined Sep 27, 2012
6
I switched to an external 20MHZ clock the whole thing works marvelously!