Hello,
I am trying to send a simple "Hello World!" message to a terminal running on a PC through the com port of that PC. I still have a problem.
The code I have is:
I set spbrg to 103 because I used this:
I have connected pin 25 to 2 of the COM port and 5 of the COM port to gnd. The problem is that I'm getting some strange characters on the terminal and not the message. What could be the problem here? Could it be the baudrate? (The thing is that when I run it in simulation everything seems to be fine)
Thanks
I am trying to send a simple "Hello World!" message to a terminal running on a PC through the com port of that PC. I still have a problem.
The code I have is:
Rich (BB code):
#include <p18f4620.h>
//#pragma config WDT = OFF
#pragma config MCLRE = OFF
#include <usart.h>
#include <delays.h>
#pragma config PWRT = OFF, WDT = OFF, LVP = OFF
void main()
{
unsigned int i;
TRISC = 0x00;
TRISB =0x00;
OSCCONbits.IRCF0 =1;
OSCCONbits.IRCF1 =1;
OSCCONbits.IRCF2 =1;
OSCCONbits.SCS1 =1;
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW,103);
while(1)
{
PORTB=0x00;
for(i=0;i<4000;i++);
PORTB=0xff;
for(i=0;i<4000;i++);
putrsUSART( (const far rom char *)"Hello World!" );
Delay10KTCYx(200);
}
}
Rich (BB code):
With USART_BRGH_LOW:
baud rate= FOSC / (64 * (spbrg + 1))
Thanks