UT EE 345M - Using a 9-bit Software UARTwith Stellaris Microcontrollers

Unformatted text preview:

Using a 9-bit Software UART with Stellaris® MicrocontrollersTable of ContentsIntroduction9-Bit UART InitializationGPIOUARTUART InterruptProgrammable Address9-Bit UART FunctionTransmitReceiveReceive Buffer Configuration9-Bit UART LimitationsApplication InformationAPI Functional DescriptionConclusionReferencesApplication ReportAN01280–August 2010Using a 9-bit Software UART with Stellaris® MicrocontrollersABSTRACTExtend the functionality of the standard hardware UART available on Stellaris®microcontrollers by using the9-bit UART add-on. This practical software solution provides a way to distinguish between an address or datacharacter.Contents1 Introduction ................................................................................................................................. 12 9-Bit UART Initialization ................................................................................................................. 13 9-Bit UART Function ...................................................................................................................... 24 9-Bit UART Limitations ................................................................................................................... 55 Application Information .................................................................................................................. 56 API Functional Description .............................................................................................................. 57 Conclusion .................................................................................................................................. 58 References .................................................................................................................................. 51 IntroductionThe Universal Asynchronous Receiver Transmitter (UART) is a widely used serial communications peripheralused in many applications for connection to legacy devices and is present on all Stellaris®microcontrollers.Some systems require the additional functionality of a 9-bit UART, with automatic address detection. The 9-bitsoftware UART uses a ninth bit to differentiate between a data or address character. The auto addressdetection allows the user to program a specific address that is used to determine if the received data issupposed to be processed or discarded. The 9-bit UART was written using the standard UART DriverLib API.The 9-bit UART uses the same function structure as the standard UART, but adds the NB_ prefix specificallyfor 9-bit UART calls. This application note describes the 9-bit UART software add-on in detail.2 9-Bit UART InitializationThere are five initialization steps for the 9-bit UART:1. Enable UART and GPIO peripherals.2. Configure the GPIO pins for UART function.3. Set up the UART hardware.4. Enable the UART Rx interrupt.5. Customize the user programmable address.2.1 GPIOThe GPIO setup is not included in the 9-bit UART API functions and must be done explicitly by the user. Thefollowing steps are necessary to enable the UART and GPIO peripherals:1. Enable the appropriate GPIO port for the UART0 or UART1 Tx and Rx pins.2. Configure the UART0 or UART1 GPIO pins for UART operation.a. Configure the GPIO pins for standard push-pull operation.b. Set the pins to be peripheral controlled.3. If your part has pin muxing, set the pin mux for your device.Using a 9-bit Software UART with Stellaris® Microcontrollers 1AN01280–August 2010Copyright © 2010 Texas Instruments Inc.Note: See the corresponding microcontroller data sheet for your device to find the correct UART GPIO portand pins.2.2 UARTThe 9-bit UART API supports the use of only one UART port. You can use either UART0 or UART1, but notboth ports.Note: For 9-bit UART operation, you must only use the DriverLib function calls that have the designatedNB_ prefix.There are two functions used to configure and initialize the 9-bit UART:• NB_UARTConfigSetExpClk()Sets up baud-rate, number of data-bits, and number of stop-bits.• NB_UARTEnable()Enables the UART hardware and the UART receive interrupt.2.3 UART InterruptFor proper operation of the 9-bit UART, enable the UART Rx interrupt using the NB_UARTEnable() functionwhich enables the UART hardware interrupts on the nested vector interrupt controller (NVIC), and also enablesthe receive interrupt on the UART hardware. You must enable the processor interrupts and explicitly add the“NB_UARTIntHandler” interrupt handler to the interrupt vector table.The UART interrupt can be configured to call a user function. If the NB_USER_INT_HANDLER macro is defined,then the NB_UserIntHandler() function will be called in the UART interrupt handler.Note: The NB_UserIntHandler() is called in an interrupt context. Do not do time-consuming operationsin this function.2.4 Programmable AddressUse the following functions to set the 9-bit UART's single programmable address:• NB_UARTAddressSet()Sets the address for the UART hardware.• NB_UARTAddressGet()Returns the current address of the UART hardware.This address is used by the UART to decide when to acknowledge or discard data. You must properly set thedevice address prior to using the 9-bit UART. Unlike some hardware implementations of the 9-bit UART, thecharacter used as the address is allowed to be received as a data. For details on receiving a character, seethe “Receive” section for more information.3 9-Bit UART FunctionThe 9-bit UART includes two sets of transmit functions; one set of functions is used to transmit data and theother set is to transmit an address. The received data is handled by the receive ISR and a software buffer.For 9-bit UART operation, you must only use the DriverLib function calls that have the designated NB_ prefix.Note: See the API Functional Description in the accompanying source code package for this applicationnote for more information on these functions.3.1 TransmitThe 9-bit UART API includes the following functions for sending addresses and data:• NB_UARTBusy()AN01280–August 20102 Using a 9-bit Software UART with Stellaris® MicrocontrollersCopyright © 2010 Texas Instruments Inc.9-Bit UART Functionwww.ti.comChecks if the UART is busy sending or receiving another character.• NB_UARTAddrPut()Puts an address character in the transmit register if there is space available. If there is no space available,it blocks the write of the address character until space is available.• NB_UARTAddrPutNonBlocking()Puts an address


View Full Document

UT EE 345M - Using a 9-bit Software UARTwith Stellaris Microcontrollers

Download Using a 9-bit Software UARTwith Stellaris Microcontrollers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using a 9-bit Software UARTwith Stellaris Microcontrollers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using a 9-bit Software UARTwith Stellaris Microcontrollers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?