How to learn dsPIC UART program based on PIC USART experience

microchippicuart

I've learned USART of PIC16F883, and I want to learn UART of dsPIC33FJ64MC802.(Actually I need to learn dsPIC, but I learned PIC16F883 first since I thought it's easier to learn.)

Here's my circuit diagram of PIC16F883 in Proteus simulator(I can send messages to virtual COM port):

enter image description here

And here's the code:

void main() {
     char ch;
     UART1_Init(19200);
     Delay_ms(100);

     while(1)
     {
             if(UART1_Tx_Idle())
                 UART1_Write_Text("OK2\r\n");
             Delay_ms(500);
     }
}

I have found some resources teaching dsPIC UART, but I can hardly read the sample code. And I don't know how to what's the circuit of the sample code and how to learn. Can anyone provide some help? How can I learn dsPIC UART based on the what I've learned from PIC?

1.UART Example for DSPIC33 (DSPIC33FJ128GP802)

2.Setting up RS232 transmission on a dsPIC

3.dsPIC33F UART transmission problem

4.Thread: [dspic33] UART – Transmits ok, but receives garbage

EDIT:

An easy way to run dsPIC UART is using mikroC for dsPIC, it's very user friendly. It provides sample code and the code is easy to understand.

Best Answer

You have unfortunately not learned much from your previous UART experience if that is all the code you have. Here it seems like you have used a couple of libraries (i.e header files) which has implemented all the "tricky" stuff for you.

I would suggest that you take a look in your code and open up the UART1_Init() function. This is most likely included as uart.c and uart.h, where the .c-file is the actual implementation.

Here you will find how UART actually works, and when you have learned this you can move on to other controllers. As a matter of fact, look in to all of your uart-functions and study them, finding out what every line means. This is the most common way to learn code: To study code, understanding it and write your own.