PIC16F886 Assembly example code for UART echo test using interrupt

This example assembly code for PIC16F886 can be used to learn the working of the UART module within the PIC MCU. The assembly code project is comprised of two *.asm files and can be compiled using MPLAB IDE.

Working:
The program will echo back the characters which were entered from a PC (Personal Computer).
.
.
.
.
.
.
.
Source files:

1. main.asm

2. uart.asm

PS: The above assembly program is having a special behavior while executing the same. Readers are encouraged to find out the program behavior and are welcome to comment on this. 🙂

4 Comments

    Anonymous

    The TXIF flag will be set once the EUSART transmit buffer is empty. I can see from the implementation that once the TXIF flag is set, the ISR (Interrupt Service Routine) will call the routine “PutTXData ” . Now the PutTXData will simply copy the contents from the ‘working’ register to the TXREG and this will re-transmit the character which is already present in the ‘working’ register.

    In simple words, the program will continue to transmit the last sent character sent from the host computer to the microcontroller.

      embedded_expert

      Congratulations on finding the correct code flow.. 🙂
      The micro-controller will continue to send back the character which was last transmitted from the PC via RS-232

    Taylor

    This code files can be combined to only one file and can be compiled right? Why to complicate the simple logic span across multiple source files. Because the ISR routine modifies EUSART specific registers and complete modular approach is not seen in the implementation.

    But of course I can see from the implementation that this code will work. Just curious about multi file implementation 😉

      embedded_expert

      Hi Taylor, Thanks for the comment. 🙂
      The code logic is split in two files in order to show how to work with multiple source files and enthusiasts can learn about the build process also.
      The Interrupt service routine is made simple so that it will be easy for a beginner to understand the code flow.

Leave a Reply

*
*

Required fields are marked *