PIC24, DsPIC33F and DsPIC30F UART implementation Code + Proteus Simulation



This post will help us to transmit data (bytes) using serial port (UART). A lot of debugging is done using serial ports. It is most convenient way of debugging for Engineers around the world.

I am using MPLAB x IDE and C30 Compiler and Proteus Simulation on v8.0 (can be downloaded from downloads section at the bottom of this post). This code will work on PIC24, DsPIC33 and DsPIC30 (16bit microcontroller) by changing only the microcontroller and header file.

Proteus Simulation:

            In this figure, I used virtual terminal that will show what data is transmitted by UART1.

Proteus Simulation virtual terminal.


Code:

In the following figure II. First I configure Uart1 module in OpenUART1() which is set according to basic functions explained in comments. I used high speed BRG which has formula. I a while loop I print a string with linefeed and carriage return at the end so it looks good.

Formula for Baudrate calculation.


Figure II main function.


In the following figure, we have BusyUART1() which continuously monitors the flag which means that UART is bust in transmitting previous  data that is written to TSR register for transmission. This function will return 0 when transmit is ready for next data.







In following figure, WriteCharToUART1( DATA) this will write data for transmission and wait till the data is send properly.



Reading Suggestions:


Downloads:

You can download Code and Proteus Simulation
Click here

For all topics Click here.

©IbrahimLabs.blogspot.com

Popular posts from this blog

Defining code regions in MPLAB X IDE

Digital AC voltmeter Schematic + Code + Proteus Simulation

Automatic Streetlight control using LDR and PIC (Code + Proteus Simulation)