Search Projects

Blogroll

Final year degree project for engineers DAC0800 based project circuit diagram and interfacing with pic mirocontroller Final year projects based on microcontrollers on programmable peripheral interface 8255
Microcontroller based different projects abstract and source code
PIC 16f877 microcontroller projects Motion control
PIC16f877 motor controller and other light projects
Tutorials of microcontroller PIC16f877, A step by step easy to use self learning rapidex

Wednesday, July 7, 2010

PIC MikroC Hardware USART Library

The universal synchronous asynchronous receiver transmitter (USART) hardware library contains a number of functions to transmit and receive serial data using the USART circuits built on the PIC microcontroller chips. Some PIC18F-series microcontrollers have only one USART (e.g., PIC18F452), while others have two USART circuits (e.g., PIC18F8520). Hardware USART has an advantage over software-implemented USART, in that higher baud rates are generally available and the microcontroller can perform other operations while data is sent to the USART. The hardware USART library provides the following functions:
Usart_Init
Usart_Data_Ready
Usart_Read
Usart_Write

Usart_Init

The Usart_Init function initializes the hardware USART with the specified baud rate.
This function should be called first, before any other USART functions. The only
parameter required by this function is the baud rate. The following example call sets the
baud rate to 9600:
Usart_Init(9600);

Usart_Data_Ready

The Usart_Data_Ready function can be called to check whether or not a data byte has
been received by the USART. The function returns a 1 if data has been received and a
0 if no data has been received. The function has no parameters. The following code
checks if a data byte has been received or not:
if(Usart_Data_Ready( ))

Usart_Read

The Usart_Read function is called to read a data byte from the USART. If data has not been
received, a 0 is returned. Note that reading data from the USART is nonblocking (i.e., thefunction always returnswhether or not theUSART has received a data byte). TheUsart_Read
function should be called after calling the function Usart_Data_Ready to make sure that data
is available at the USART. Usart_Read has no parameters. In the following example,USART
is checked and if a data byte has been received it is copied to variable MyData:
char MyData;
if(Usart_Data_Read( )) MyData = Usart_Read();

Usart_Write

The Usart_Write function sends a data byte to the USART, and thus a serial data is sent
out of the USART. The data byte to be sent must be supplied as a parameter to the
function. In the following example, character “A” is sent to the USART:
char Temp = ‘A’;
Usart_Write(Temp);
The following example illustrates how the hardware USART functions can be used in a
program.

No comments:

Post a Comment

Hi: This is PICINF.blogspot.com comments section. Here you are requested to write your question or problems in detail. Write the question in such a way that, it have all necessary information, sothat i can understand and reply.If you want to send pictures and codes then e-mail me (rghkk@hotmail.com).Thanks.