USART Static Driver Library

Creating USART Static Drivers

The Static driver library is used to control individual Universal Synchronous/Asynchronous Receiver/Transmitter (USART) peripherals (USART1 or USART2 or …). MHC is used to configure which USART peripheral is controlled by a specific USART driver instance. These custom drivers are created by MHC when you generate the files (click the "Generate" button). Here are some examples of Static drivers:

rx_byte = DRV_USART0_ReadByte ();   // Read a byte from USART driver instance 0 

DRV_USART0_WriteByte ('a');         // Write character 'a' to USART driver instance 0 

DRV_USART1_WriteByte ('b');         // Write character 'b' to USART driver instance 1

If the Static drivers shown above were configured by MHC as shown in the picture below, then the character 'a' will be transmitted on USART4 and 'b' will be transmitted on USART2.

usart_config_example.png

Harmony Static Drivers are simpler to use than Dynamic Drivers because they don't rely on an object-oriented (data structure-oriented) programming model. Data structures (objects) defining the drivers are not needed for the Static Drivers because the static driver functions are generated (customized) by MHC, based on the selections you've made in MHC.

USART Static Driver Functions
DRV_USART0_Initialize()
Initialize USART driver instance 0 (not the non-existant USART0 peripheral)
DRV_USART0_ReceiverBufferIsEmpty()
Returns true if USART instance 0 receiver buffer is empty
DRV_USART0_ReadByte()
Receive a byte from USART instance 0
DRV_USART0_WriteByte('c')
Transmit the character 'c' to USART instance 0

The Static Driver functions shown above are for USART Driver instance 0. The "0" in USART0" indicates which driver instance is being controlled. In other words, if you need two Static Drivers, MHC will generate a group of "USART0" functions and a group of "USART1" functions (to control driver instance 0 and instance 1 respectively).

The Static Driver API is much smaller than the Dynamic Driver API, and only implements a byte-by-byte transfer model. These are all the functions implemented for a single USART Static driver instance:


Using USART Static Drivers

Once you have used MHC to generate the USART Static Drivers, you can use them as shown in the example below.

Using the USART Static Driver

using_static.png

You do not need to understand how MHC creates static drivers to use them. If you want these details, click the following button. For a higher level understanding of how to use USART Static Drivers, click on the "Harmony USART Tutorial" button below.

 
USART Static Driver Details
Learn more >

 Learn More

 
Harmony USART Tutorial
Learn more >
 
Example Code and Projects
Learn more >
 
Entire USART Driver Interface
Learn more >
 
USART Hardware Description
Learn more >

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.