Hello guys, here I am with a very powerful protocol for communication in embedded systems. ARM microcontroller provides you wide range of communication techniques in which the one of the most likely is the UART communication,  it is simply just the fastest means of communication for microcontrollers in short range and 2 wire complexity with bidirectional communication. We simply need to follow the following steps for the communication programming. I’ll show you how to do simple UART programming on NUVOTON NUC200 Microcontroller.

  1. For the initialization of UART communication you have to configure few things necessary for the serial communication. Firstly let us configure the Serial settings in PC. Open hyperlink or putty in windows and create for new serial connection. The terminal will ask for Baud rate, Data bits, Stop bits, Parity, and Flow control. The default configuration on any machine is baud rate->9600, Data bits->8, Stop bits->1, Parity-> None and Flow Control->XON/XOFF. Leave it the same in the machine, you just need to synchronize the same rate in you microcontroller also.
  2. This blog is for the newbies working on NUVOTON NUC200 microcontroller. Now open keil IDE. Create a new project as simpleUART.uvproj select the microcontroller on which you are working say, I am working with Nuvoton’s  NUC200SD2AN microcontroller. Select the debugger you have for my controller I must use NULINK Debugger. Select the Crystal frequency that you are using in your development board, I am having NUCtiny-NUC200 board with 12MHz crystal oscillator I’ll fix that on the setup page in XTAL box. Check the Create Hex file box in the output tab. Now the setup page is ready for programming the board.
  3. Now create a new blank document and save it as simpleUART.C. Add the newly created .C file in the project window include the startup files for the controller in the .C file like below
  4. Now we will begin the main function the return type will be taken as an integer of 32 bits. The below used registers are already defined as macros in UART.h with their 32-bit addresses so don’t afraid with their names, you can get the function of each Special Function Register of the microcontroller in the Appendix section at the end.
  5. Initialization functions for the UART. The following code have comments that will let you understand it with ease.

    So that was the initialization for the UART communication by the microcontroller fortunately it worked in very few tries so what you need is just to copy this initialization code and the header file, and call the initialization code set the parameters in the main function and Enjoy the communication, you just need the hardware with RS232 or RS485 communication compatible ICs. To communicate PC with the microcontroller

    Some of the functions have not been pasted from my project here so if it shows any error,  get whole sample codes from

    GITHUB

    and run it. 🙂

  6. APPENDIX :  The Variables used in above programs corresponds to the 32 bit Special Function Registers in the microcontroller with as their name suggests each register has its own special functions. For the reference I am sticking the macros and headers defined for them

I hope this blog will find you a deep concept for UART communication and please submit your comments and feedbacks so that I’ll help you with other things in embedded systems, whatever you are curious about and want to know how to build it, ask me in your comments or mail me on mridul@jellyfishtechnologies.com I’ll surely write a conceptual blog that’ll help you find your answers.

Happy Communicating… 🙂