USART Dynamic Driver Library

Creating USART Dynamic Drivers

MHC does not create functions for Dynamic Drivers like it does for Static Drivers. It instead uses the Universal Synchronous/Asynchronous Receiver/Transmitter (USART) Driver configuration macros to create data structures (also known as objects) for each USART Driver instance. These objects are passed into the Dynamic Driver functions to specify how the drivers are configured. This means a USART Dynamic Driver function can control any USART instance, depending on which instance you pass into the function.

MHC also uses USART peripheral libraries to configure the specific peripherals you selected to use for each driver instance.

USART Data Transfer Model DMA?
Byte by Byte No
File I/O Read/Write No
File I/O Read/Write with Buffer Queue No
Buffer Queue No
Buffer Queue with DMA Yes

Unlike the USART Static drivers, the Dynamic drivers provide three different data transfer models:

  • Byte by Byte
    • Transfer data through USART driver one byte at a time.
  • File I/O Read/Write
    • Can process a block of data using read and write functions. Depending on the mode (blocking or non-blocking) in which the client opened the driver, the driver will either block until all of the data is transferred (only if using an RTOS) or will immediately return with the number of bytes transferred.
  • Buffer Queue
    • Allows clients to queue data transfers for processing. The driver returns a buffer handle for a queued request. Clients can track the completion of a buffer through events and API.

You configure the USART Dynamic Drivers using the selections provided by MHC. These drivers are created when you press the MHC "Generate" button. MHC's first step in this process is to create USART Driver configuration macros based on your selections.


Next, MHC uses these macros to create the USART Driver initialization structures.

The last job MHC performs for you is to initialize the USART Dynamic Driver object structures.


Using USART Dynamic Drivers

Once the driver is initialized, it must be "opened" by a client before it can be used.

You must do the following:

  1. Create a handle (pointer) for a client to use with a USART Driver instance.
  2. Open a client for a specific USART Driver instance and assign the handle to it.

Opening a Client for a USART Dynamic Driver


Two parameters are passed into this USART open function:

  • Specific USART instance to open
  • How you want to use the USART (I/O Intent)

The I/O Intent parameter is used for all Dynamic Drivers, and defines how the client interacts with the driver instance. It defines the intended usage or desired behavior of the device driver.

Once this handle has been assigned to a specific USART Driver instance, it must be passed into the library functions to control that instance.

Using the USART Dynamic Driver


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

USART Dynamic 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.