First of all to enable the serial port or TX(Transmission) RX(Reception) line. The SPEN(Serial port enable bit) bit of register RCSTA(Receive status and control register) should be high.
Set the Transmission setting in TXSTA(Transmit Status and Control Register) register.
The Data Which you want to transmit should be placed in TXREG(Transmit register) register. This register gives data to TSR Register. TSR then transmits the data serialy. TSR Register is not available for user you can not access it.
I write code in MP-Lab using High Tech C Compiler. The code is written in c language. First import the library htc.h. Always import this library in each project if you are writting code using high tech c compiler. Then Crystal frequency in defined. which is 20 MHz. In the main function first TRISC6=0 statement makes the Port-C bit 6 as output
pin. This pin is actually Multiplexed pin. It can be used as Digital I/O as well as TX line. So first make it as output pin. Then a string Array is defined. This Array contains my website name “www.microcontroller-project.com”. This String is displayed on Hyperterminal screen when the program runs. Then the registers are initialized i explaned their initialization above.
While 1 loop is continuously printing my website name on hyperterminal. While(TRMT=0) statement checks if the TSR Register is empty. If TSR is full The control remains on while(TRMT=0) statement and when TSR becomes empty. TRMT becomes 1 and control jumps to next statement.
Before running the program. Just set the hperterminal.Goto Start->Programs->Accessories->Communications>HyperTerminal open new connection, name it what ever you want then click ok. Now a window appears select COM1 from connect using drop down menu click ok. Now set COM1 properties, bits per second as you specified in your program in mine case 9600, Data bits=8, Parity=none, Stop bits=1, Flow control=none then click ok. Now switch on the power of your circuit, you will see “www.microcontroller-project.com” on Hyperterminal screen.
Filed Under: Microcontroller Projects, PIC Microcontroller
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.