Hi Ian. Yes I am using C18. I know that I can use the header file and access the usart.h functions. I am doing this lab and it has two examples. This is the first and the second uses the functions from the library of the MPLABC18 header.
However, when I tried both examples. I get the same results.
As for the virtual window. I thought of that as well . I have changed it. take a look at the screenshot.
I know I need to calculate the baud rate using the formula and I get 64 for 20MHz oscillator and 19200 baud.
Please help. I understand the theory, the code (functions, steps of setting up USART, etc) but cannot debug this. I cannot even upload the Proteus file because I know it's against forum rules!
The following is the source code for the example using functions of the usart.h. The only difference is that I need to output a statement:
/* Serial Communication Transmit Example using MPLAB C18 libraries */ /* Using Port C as a UART Port */
#pragma config OSC = HS /*set osc mode to HS
#pragma config WDT = OFF /* set watchdog timer off */
#pragma config LVP = OFF /* Low Voltage Programming Off */
#pragma config DEBUG = OFF /* Compile without extra Debug compile Code */
/* Include the following header files */
#include <p18cxxx.h> // device PIC18 family
#include <delays.h> // include the delays library
#include <usart.h> // include the USART header files
void main ()
{
/* Make Port C O/P */
TRISC = 0x00; /* Open the USART for communication and set the following operational parameters: Set USART Parameters: Baud rate 19.200, TX & RX interrupts disabled, asynchronous operation, 8 data bits, Continuous reception, High Baud rate, calculated value for 19200 is 64 decimal */
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 64);
while(1)
{
putrsUSART( " PIC 18F4520 TRANSMIT EXAMPLE ! \r\n " ); // Send the string
Delay10KTCYx(200); // Delay between data transmissions
}
}