msp430fr5xx_6xx_driverlib_users_guide-1_90_00_65

Upload: prabakaran-ellaiyappan

Post on 09-Oct-2015

333 views

Category:

Documents


5 download

DESCRIPTION

MSP430 Driver User guide.

TRANSCRIPT

  • Copyright 2014 Texas Instruments Incorporated.

    USERS GUIDE

    MSP430 Peripheral Driver Library for FR5xx andFR6xx Devices

  • CopyrightCopyright 2014 Texas Instruments Incorporated. All rights reserved. MSP430 and 430ware are registered trademarks of Texas Instruments. Othernames and brands may be claimed as the property of others.

    Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of Texas Instruments semicon-ductor products and disclaimers thereto appears at the end of this document.

    Texas InstrumentsPost Office Box 655303Dallas, TX 75265http://www.ti.com/msp430

    Revision InformationThis is version 1.90.00.65 of this document, last updated on 2014-06-25.

    2014-06-25 1

  • Table of Contents

    Table of ContentsCopyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Revision Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 Navigating to driverlib through CCS Resource Explorer . . . . . . . . . . . . . . . . . . . . . . . 5

    3 How to create a new user project that uses Driverlib . . . . . . . . . . . . . . . . . . . . . . . . . 13

    4 How to include driverlib into your existing project . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    5 12-Bit Analog-to-Digital Converter (ADC12_B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    6 Advanced Encryption Standard (AES256) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    7 Comparator (COMP_E) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    8 Cyclical Redundancy Check (CRC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    9 Cyclical Redundancy Check (CRC32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    10 Clock System (CS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8310.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8310.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8410.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

    11 Direct Memory Access (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9811.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9811.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9811.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    12 EUSCI Universal Asynchronous Receiver/Transmitter (EUSCI_A_UART) . . . . . . . . . . . . . 11312.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11312.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11312.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

    13 EUSCI Synchronous Peripheral Interface (EUSCI_A_SPI) . . . . . . . . . . . . . . . . . . . . . . 12613.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12613.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12613.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

    14 EUSCI Synchronous Peripheral Interface (EUSCI_B_SPI) . . . . . . . . . . . . . . . . . . . . . . 13914.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    2014-06-25 2

  • Table of Contents

    14.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13914.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    15 EUSCI Inter-Integrated Circuit (EUSCI_B_I2C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15215.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15215.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15415.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

    16 FRAM Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17816.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17816.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17816.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

    17 GPIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18517.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18517.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18617.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

    18 LCD_C Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20518.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20518.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20518.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

    19 Memory Protection Unit (MPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22419.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22419.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22419.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

    20 32-Bit Hardware Multiplier (MPY32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23420.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23420.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23420.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    21 Power Management Module (PMM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24821.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24821.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24821.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

    22 RAM Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25622.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25622.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25622.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

    23 Internal Reference (REF_A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25823.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25823.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25823.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

    24 Real-Time Clock (RTC_B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26824.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26824.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26824.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    25 Real-Time Clock (RTC_C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28225.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28225.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28225.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    26 SFR Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29426.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

    2014-06-25 3

  • Table of Contents

    26.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29426.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

    27 SYS Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30027.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30027.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30027.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

    28 16-Bit Timer_A (TIMER_A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31128.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31128.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31228.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    29 16-Bit Timer_B (TIMER_B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33929.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33929.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34029.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

    30 Tag Length Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36930.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36930.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36930.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

    31 WatchDog Timer (WDT_A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37531.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37531.2 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37531.3 Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    IMPORTANT NOTICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    2014-06-25 4

  • Introduction

    1 IntroductionThe Texas Instruments MSP430 Peripheral Driver Library is a set of drivers for accessing theperipherals found on the MSP430 FR5xx/FR6xx family of microcontrollers. While they are notdrivers in the pure operating system sense (that is, they do not have a common interface and donot connect into a global device driver infrastructure), they do provide a mechanism that makes iteasy to use the devices peripherals.

    The capabilities and organization of the drivers are governed by the following design goals:

    They are written entirely in C except where absolutely not possible.

    They demonstrate how to use the peripheral in its common mode of operation.

    They are easy to understand.

    They are reasonably efficient in terms of memory and processor usage.

    They are as self-contained as possible.

    Where possible, computations that can be performed at compile time are done there insteadof at run time.

    They can be built with more than one tool chain.

    Some consequences of these design goals are:

    The drivers are not necessarily as efficient as they could be (from a code size and/orexecution speed point of view). While the most efficient piece of code for operating aperipheral would be written in assembly and custom tailored to the specific requirements ofthe application, further size optimizations of the drivers would make them more difficult tounderstand.

    The drivers do not support the full capabilities of the hardware. Some of the peripheralsprovide complex capabilities which cannot be utilized by the drivers in this library, though theexisting code can be used as a reference upon which to add support for the additionalcapabilities.

    The APIs have a means of removing all error checking code. Because the error checking isusually only useful during initial program development, it can be removed to improve codesize and speed.

    For many applications, the drivers can be used as is. But in some cases, the drivers will have to beenhanced or rewritten in order to meet the functionality, memory, or processing requirements of theapplication. If so, the existing driver can be used as a reference on how to operate the peripheral.

    Each MSP430ware driverlib API takes in the base address of the corresponding peripheral as thefirst parameter. This base address is obtained from the msp430 device specific header files (orfrom the device datasheet). The example code for the various peripherals show how base addressis used. When using CCS, the eclipse shortcut "Ctrl + Space" helps. Type __MSP430 and "Ctrl +Space", and the list of base addresses from the included device specific header files is listed.

    The following tool chains are supported:

    IAR Embedded Workbench

    Texas Instruments Code Composer Studio

    Using assert statements to debug

    2014-06-25 5

  • Introduction

    Assert statements are disabled by default. To enable the assert statement edit thehw_regaccess.h file in the inc folder. Comment out the statement define NDEBUG -> //defineNDEBUG Asserts in CCS work only if the project is optimized for size.

    2014-06-25 6

  • Navigating to driverlib through CCS Resource Explorer

    2 Navigating to driverlib through CCSResource ExplorerIn CCS, click View->TI Resource Explorer

    In Resource Explorer View, click on MSP430ware

    2014-06-25 7

  • Navigating to driverlib through CCS Resource Explorer

    Clicking MSP430ware takes you to the introductory page. The version of the latest MSP430wareinstalled is available in this page. In this screenshot the version is 1.30.00.15 The varioussoftware, collateral, code examples, datasheets and user guides can be navigated by clicking thedifferent topics under MSP430ware. To proceed to driverlib, click on Libraries->Driverlib as shownin the next two screenshots.

    2014-06-25 8

  • Navigating to driverlib through CCS Resource Explorer

    Driverlib is designed per Family. If a common device family users guide exists for a group ofdevices, these devices belong to the same family. Currently driverlib is available for the followingfamily of devices. MSP430F5xx_6xx MSP430FR57xx MSP430FR5xx_6xx MSP430i2xx

    2014-06-25 9

  • Navigating to driverlib through CCS Resource Explorer

    Click on the MSP430FR5xx_6xx to navigate to the driverlib based example code for that family.

    The various peripherals are listed in alphabetical order. The names of peripherals are as in devicefamily users guide. Clicking on a peripheral name lists the driverlib example code for thatperipheral. The screenshot below shows an example when the user clicks on GPIO peripheral.

    2014-06-25 10

  • Navigating to driverlib through CCS Resource Explorer

    Now click on the specific example you are interested in. On the right side there are options toImport/Build/Download and Debug. Import the project by clicking on the "Import the exampleproject into CCS"

    2014-06-25 11

  • Navigating to driverlib through CCS Resource Explorer

    The imported project can be viewed on the left in the Project Explorer. All required driverlib sourceand header files are included inside the driverlib folder. All driverlib source and header files arelinked to the example projects. So if the user modifies any of these source or header files, theoriginal copy of the installed MSP430ware driverlib source and header files get modified.

    Now click on Build the imported project on the right to build the example project.

    2014-06-25 12

  • Navigating to driverlib through CCS Resource Explorer

    Now click on Build the imported project on the right to build the example project.

    The COM port to download to can be changed using the Debugger Configuration option on theright if required.

    2014-06-25 13

  • Navigating to driverlib through CCS Resource Explorer

    To get started on a new project we recommend getting started on an empty project we provide.This project has all the driverlib source files, header files, project paths are set by default.

    The main.c included with the empty project can be modified to include user code.

    2014-06-25 14

  • How to create a new user project that uses Driverlib

    3 How to create a new user project that usesDriverlibTo get started on a new project we recommend using the new project wizard. For driver library towork with the new project wizard CCS must have discovered the driver library RTSC product. Formore information refer to the installation steps of the release notes. The new project wizard addsthe needed driver library source files and adds the driver library include path.

    To open the new project wizard go to File -> New -> CCS Project as seen in the screenshot below.

    Once the new project wizard has been opened name your project and choose the device youwould like to create a Driver Library project for. The device must be supported by driver library.

    Then under "Project templates and examples" choose "Empty Project with DriverLib Source" asseen below.

    2014-06-25 15

  • How to create a new user project that uses Driverlib

    Finally click "Finish" and begin developing with your Driver Library enabled project.

    2014-06-25 16

  • How to include driverlib into your existing project

    4 How to include driverlib into your existingprojectTo add driver library to an existing project we recommend using CCS project templates. For driverlibrary to work with project templates CCS must have discovered the driver library RTSC product.For more information refer to the installation steps of the release notes. CCS project templatesadds the needed driver library source files and adds the driver library include path.

    To apply a project template right click on an existing project then go to Source -> Apply ProjectTemplate as seen in the screenshot below.

    In the "Apply Project Template" dialog box under "MSP430 DriverLib Additions" choose either"Add Local Copy" or "Point to Installed DriverLib" as seen in the screenshot below. Most users willwant to add a local copy which copies the DriverLib source into the project and sets the compilersettings needed.

    Pointing to an installed DriverLib is for advandced users who are including a static library in theirproject and want to add the DriverLib header files to their include path.

    2014-06-25 17

  • How to include driverlib into your existing project

    Click "Finish" and start developing with driver library in your project.

    2014-06-25 18

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    5 12-Bit Analog-to-Digital Converter(ADC12_B)Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    5.1 Introduction

    The 12-Bit Analog-to-Digital (ADC12_B) API provides a set of functions for using theMSP430Ware ADC12_B modules. Functions are provided to initialize the ADC12_B modules,setup signal sources and reference voltages for each memory buffer, and manage interrupts forthe ADC12_B modules.

    The ADC12_B module provides the ability to convert analog signals into a digital value in respectto given reference voltages. The module implements a 12-bit SAR core, sample select control,and up to 32 independent conversion-and-control buffers. The conversion-and-control bufferallows up to 32 independent analog-to-digital converter (ADC) samples to be converted and storedwithout any CPU intervention. The ADC12_B can also generate digital values from 0 to Vcc withan 8-, 10- or 12-bit resolution and it can operate in 2 different sampling modes, and 4 differentconversion modes. The sampling modes are extended sampling and pulse sampling, in extendedsampling the sample/hold signal must stay high for the duration of sampling, while in pulse mode asampling timer is setup to start on a rising edge of the sample/hold signal and sample for aspecified amount of clock cycles. The 4 conversion modes are single-channel single conversion,sequence of channels single-conversion, repeated single channel conversions, and repeatedsequence of channels conversions.

    The ADC12_B module can generate multiple interrupts. An interrupt can be asserted for eachmemory buffer when a conversion is complete, or when a conversion is about to overwrite theconverted data in any of the memory buffers before it has been read out, and/or when aconversion is about to start before the last conversion is complete.

    ADC12_B features include:

    200 ksps maximum conversion rate at maximum resolution of 12-bits

    Monotonic 12-bit converter with no missing codes

    Sample-and-hold with programmable sampling periods controlled by software or timers.

    Conversion initiation by software or timers.

    Software-selectable on-chip reference voltage generation (1.2 V, 2.0 V, or 2.5 V) with optionto make available externally

    Software-selectable internal or external reference

    Up to 32 individually configurable external input channels, single-ended or differential inputselection available

    Internal conversion channels for internal temperature sensor and 2/3 ?AVCC and four moreinternal channels available on select devices see device data sheet for availability as well asfunction

    Independent channel-selectable reference sources for both positive and negative references

    2014-06-25 19

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Selectable conversion clock source

    Single-channel, repeat-single-channel, sequence (autoscan), and repeat-sequence(repeated autoscan) conversion modes

    Interrupt vector register for fast decoding of 38 ADC interrupts

    32 conversion-result storage registers

    Window comparator for low power monitoring of input signals of conversion-result registers

    This driver is contained in adc12_b.c, with adc12_b.h containing the API definitions for use byapplications.

    The following code metrics were performed with the TI Compiler 4.2.1 compiler, IAR 5.51.6compiler and MSPGCC 4.8.0 compiler with different optimization settings. Users may seedifferent code sizes depending on their project settings so it is best to perform yourbenchmarks within your project. These sizes contain all functions of the peripheral but onlyfunctions that are used will be linked into the application and added to the total code size. Tosee individual API code metrics see the specific API below.

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 1146TI Compiler 4.2.1 Size 558TI Compiler 4.2.1 Speed 554

    IAR 5.51.6 None 832IAR 5.51.6 Size 640IAR 5.51.6 Speed 680

    MSPGCC 4.8.0 None 1806MSPGCC 4.8.0 Size 606MSPGCC 4.8.0 Speed 618

    5.2 API Functions

    Functionsvoid ADC12_B_clearInterrupt (uint16_t baseAddress, uint8_t interruptRegisterChoice,uint16_t memoryInterruptFlagMask)void ADC12_B_configureMemory (uint16_t baseAddress,ADC12_B_configureMemoryParam param)void ADC12_B_disable (uint16_t baseAddress)void ADC12_B_disableConversions (uint16_t baseAddress, bool preempt)void ADC12_B_disableInterrupt (uint16_t baseAddress, uint16_t interruptMask0, uint16_tinterruptMask1, uint16_t interruptMask2)void ADC12_B_disableSamplingTimer (uint16_t baseAddress)void ADC12_B_enable (uint16_t baseAddress)void ADC12_B_enableInterrupt (uint16_t baseAddress, uint16_t interruptMask0, uint16_tinterruptMask1, uint16_t interruptMask2)uint16_t ADC12_B_getInterruptStatus (uint16_t baseAddress, uint8_tinterruptRegisterChoice, uint16_t memoryInterruptFlagMask)

    2014-06-25 20

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    uint32_t ADC12_B_getMemoryAddressForDMA (uint16_t baseAddress, uint8_tmemoryIndex)uint16_t ADC12_B_getResults (uint16_t baseAddress, uint8_t memoryBufferIndex)bool ADC12_B_init (uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_tclockSourceSelect, uint16_t clockSourceDivider, uint16_t clockSourcePredivider, uint16_tinternalChannelMap)bool ADC12_B_initialize (uint16_t baseAddress, ADC12_B_initializeParam param)uint8_t ADC12_B_isBusy (uint16_t baseAddress)void ADC12_B_memoryConfigure (uint16_t baseAddress, uint8_tmemoryBufferControlIndex, uint8_t inputSourceSelect, uint16_t refVoltageSourceSelect,uint16_t endOfSequence, uint16_t windowComparatorSelect, uint16_tdifferentialModeSelect)void ADC12_B_setAdcPowerMode (uint16_t baseAddress, uint8_t powerMode)void ADC12_B_setDataReadBackFormat (uint16_t baseAddress, uint8_t readBackFormat)void ADC12_B_setResolution (uint16_t baseAddress, uint8_t resolutionSelect)void ADC12_B_setSampleHoldSignalInversion (uint16_t baseAddress, uint16_tinvertedSignal)void ADC12_B_setupSamplingTimer (uint16_t baseAddress, uint16_tclockCycleHoldCountLowMem, uint16_t clockCycleHoldCountHighMem, uint16_tmultipleSamplesEnabled)void ADC12_B_setWindowCompAdvanced (uint16_t baseAddress, uint16_t highThreshold,uint16_t lowThreshold)void ADC12_B_startConversion (uint16_t baseAddress, uint16_t startingMemoryBufferIndex,uint8_t conversionSequenceModeSelect)

    5.2.1 Detailed Description

    The ADC12_B API is broken into three groups of functions: those that deal with initialization andconversions, those that handle interrupts, and those that handle auxiliary features of theADC12_B.

    The ADC12_B initialization and conversion functions are

    ADC12_B_init

    ADC12_B_memoryConfigure

    ADC12_B_setWindowCompAdvanced

    ADC12_B_setupSamplingTimer

    ADC12_B_disableSamplingTimer

    ADC12_B_startConversion

    ADC12_B_disableConversions

    ADC12_B_getResults

    ADC12_B_isBusy

    The ADC12_B interrupts are handled by

    ADC12_B_enableInterrupt

    ADC12_B_disableInterrupt

    2014-06-25 21

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_clearInterrupt

    ADC12_B_getInterruptStatus

    Auxiliary features of the ADC12_B are handled by

    ADC12_B_setResolution

    ADC12_B_setSampleHoldSignalInversion

    ADC12_B_setDataReadBackFormat

    ADC12_B_enableReferenceBurst

    ADC12_B_disableReferenceBurst

    ADC12_B_setAdcPowerMode

    ADC12_B_getMemoryAddressForDMA

    ADC12_B_enable

    ADC12_B_disable

    5.2.2 Function Documentation

    5.2.2.1 void ADC12_B_clearInterrupt (uint16_t baseAddress, uint8_tinterruptRegisterChoice, uint16_t memoryInterruptFlagMask)

    Clears ADC12B selected interrupt flags.

    Modified registers are ADC12IFG .

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 40TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 22IAR 5.51.6 Size 16IAR 5.51.6 Speed 16

    MSPGCC 4.8.0 None 64MSPGCC 4.8.0 Size 18MSPGCC 4.8.0 Speed 18

    Parameters:baseAddress is the base address of the ADC12B module.interruptRegisterChoice is either 0, 1, or 2, to choose the correct interrupt register to updatememoryInterruptFlagMask is the bit mask of the memory buffer and overflow interrupt flags

    to be cleared. Valid values are:ADC12_B_IFG0 - interruptRegisterChoice = 0ADC12_B_IFG1ADC12_B_IFG2ADC12_B_IFG3

    2014-06-25 22

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_IFG4ADC12_B_IFG5ADC12_B_IFG6ADC12_B_IFG7ADC12_B_IFG8ADC12_B_IFG9ADC12_B_IFG10ADC12_B_IFG11ADC12_B_IFG12ADC12_B_IFG13ADC12_B_IFG14ADC12_B_IFG15ADC12_B_IFG16 - interruptRegisterChoice = 1ADC12_B_IFG17ADC12_B_IFG18ADC12_B_IFG19ADC12_B_IFG20ADC12_B_IFG21ADC12_B_IFG22ADC12_B_IFG23ADC12_B_IFG24ADC12_B_IFG25ADC12_B_IFG26ADC12_B_IFG27ADC12_B_IFG28ADC12_B_IFG29ADC12_B_IFG30ADC12_B_IFG31ADC12_B_INIFG - interruptRegisterChoice = 2ADC12_B_LOIFGADC12_B_HIIFGADC12_B_OVIFGADC12_B_TOVIFGADC12_B_RDYIFG - The selected ADC12B interrupt flags are cleared, so that it nolonger asserts. The memory buffer interrupt flags are only cleared when the memorybuffer is accessed. Note that the overflow interrupts do not have an interrupt flag toclear; they must be accessed directly from the interrupt vector.

    Returns:None

    5.2.2.2 void ADC12_B_configureMemory (uint16_t baseAddress,ADC12_B_configureMemoryParam param)Configures the controls of the selected memory buffer.

    2014-06-25 23

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Maps an input signal conversion into the selected memory buffer, as well as the positive andnegative reference voltages for each conversion being stored into this memory buffer. If theinternal reference is used for the positive reference voltage, the internal REF module must be usedto control the voltage level. Note that if a conversion has been started with the startConversion()function, then a call to disableConversions() is required before this function may be called.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 102TI Compiler 4.2.1 Size 50TI Compiler 4.2.1 Speed 50

    IAR 5.51.6 None 76IAR 5.51.6 Size 50IAR 5.51.6 Speed 50

    MSPGCC 4.8.0 None 178MSPGCC 4.8.0 Size 52MSPGCC 4.8.0 Speed 52

    Parameters:baseAddress is the base address of the ADC12B module.param is the pointer to struct for ADC12B memory configuration.

    Returns:None

    5.2.2.3 void ADC12_B_disable (uint16_t baseAddress)

    Disables the ADC12B block.

    This will disable operation of the ADC12B block.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 24TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 16IAR 5.51.6 Size 12IAR 5.51.6 Speed 12

    MSPGCC 4.8.0 None 44MSPGCC 4.8.0 Size 12MSPGCC 4.8.0 Speed 12

    Parameters:baseAddress is the base address of the ADC12B module.

    Modified bits are ADC12ON of ADC12CTL0 register.

    2014-06-25 24

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Returns:None

    5.2.2.4 void ADC12_B_disableConversions (uint16_t baseAddress, bool preempt)

    Disables the ADC from converting any more signals.

    Disables the ADC from converting any more signals. If there is a conversion in progress, thisfunction can stop it immediately if the preempt parameter is set asADC12_B_PREEMPTCONVERSION, by changing the conversion mode to single-channel,single-conversion and disabling conversions. If the conversion mode is set as single-channel,single-conversion and this function is called without preemption, then the ADC core conversionstatus is polled until the conversion is complete before disabling conversions to preventunpredictable data. If the ADC12_B_startConversion() has been called, then this function has tobe called to re-initialize the ADC, reconfigure a memory buffer control, enable/disable the samplingpulse mode, or change the internal reference voltage.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 62TI Compiler 4.2.1 Size 28TI Compiler 4.2.1 Speed 28

    IAR 5.51.6 None 42IAR 5.51.6 Size 38IAR 5.51.6 Speed 32

    MSPGCC 4.8.0 None 96MSPGCC 4.8.0 Size 32MSPGCC 4.8.0 Speed 34

    Parameters:baseAddress is the base address of the ADC12B module.preempt specifies if the current conversion should be preemptively stopped before the end of

    the conversion. Valid values are:ADC12_B_COMPLETECONVERSION - Allows the ADC12B to end the currentconversion before disabling conversions.ADC12_B_PREEMPTCONVERSION - Stops the ADC12B immediately, withunpredictable results of the current conversion.

    Modified bits of ADC12CTL1 register and bits of ADC12CTL0 register.

    Returns:None

    5.2.2.5 void ADC12_B_disableInterrupt (uint16_t baseAddress, uint16_t interruptMask0,uint16_t interruptMask1, uint16_t interruptMask2)

    Disables selected ADC12B interrupt sources.

    2014-06-25 25

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Disables the indicated ADC12B interrupt sources. Only the sources that are enabled can bereflected to the processor interrupt; disabled sources have no effect on the processor.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 58TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 36IAR 5.51.6 Size 34IAR 5.51.6 Speed 34

    MSPGCC 4.8.0 None 110MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the ADC12B module.interruptMask0 is the bit mask of the memory buffer and overflow interrupt sources to be

    disabled. If the desired interrupt is not available in the selection for interruptMask0, thensimply pass in a 0 for this value. Valid values are:

    ADC12_B_IE0ADC12_B_IE1ADC12_B_IE2ADC12_B_IE3ADC12_B_IE4ADC12_B_IE5ADC12_B_IE6ADC12_B_IE7ADC12_B_IE8ADC12_B_IE9ADC12_B_IE10ADC12_B_IE11ADC12_B_IE12ADC12_B_IE13ADC12_B_IE14ADC12_B_IE15

    interruptMask1 is the bit mask of the memory buffer and overflow interrupt sources to bedisabled. If the desired interrupt is not available in the selection for interruptMask1, thensimply pass in a 0 for this value. Valid values are:

    ADC12_B_IE16ADC12_B_IE17ADC12_B_IE18ADC12_B_IE19ADC12_B_IE20ADC12_B_IE21ADC12_B_IE22

    2014-06-25 26

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_IE23ADC12_B_IE24ADC12_B_IE25ADC12_B_IE26ADC12_B_IE27ADC12_B_IE28ADC12_B_IE29ADC12_B_IE30ADC12_B_IE31

    interruptMask2 is the bit mask of the memory buffer and overflow interrupt sources to bedisabled. If the desired interrupt is not available in the selection for interruptMask2, thensimply pass in a 0 for this value. Valid values are:

    ADC12_B_INIE - Interrupt enable for a conversion in the result register is eithergreater than the ADC12LO or lower than the ADC12HI threshold. GIE bit must be setto enable the interrupt.ADC12_B_LOIE - Interrupt enable for the falling short of the lower limit interrupt of thewindow comparator for the result register. GIE bit must be set to enable the interrupt.ADC12_B_HIIE - Interrupt enable for the exceeding the upper limit of the windowcomparator for the result register. GIE bit must be set to enable the interrupt.ADC12_B_OVIE - Interrupt enable for a conversion that is about to save to a memorybuffer that has not been read out yet. GIE bit must be set to enable the interrupt.ADC12_B_TOVIE - enable for a conversion that is about to start before the previousconversion has been completed. GIE bit must be set to enable the interrupt.ADC12_B_RDYIE - enable for the local buffered reference ready signal. GIE bit mustbe set to enable the interrupt.

    Modified bits of ADC12IERx register.

    Returns:None

    5.2.2.6 void ADC12_B_disableSamplingTimer (uint16_t baseAddress)

    Disables Sampling Timer Pulse Mode.

    Disables the Sampling Timer Pulse Mode. Note that if a conversion has been started with thestartConversion() function, then a call to disableConversions() is required before this function maybe called.

    Code Metrics:

    2014-06-25 27

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 20TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 12IAR 5.51.6 Size 10IAR 5.51.6 Speed 10

    MSPGCC 4.8.0 None 28MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the ADC12B module.

    Returns:None

    5.2.2.7 void ADC12_B_enable (uint16_t baseAddress)

    Enables the ADC12B block.

    This will enable operation of the ADC12B block.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 24TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 16IAR 5.51.6 Size 12IAR 5.51.6 Speed 12

    MSPGCC 4.8.0 None 44MSPGCC 4.8.0 Size 12MSPGCC 4.8.0 Speed 12

    Parameters:baseAddress is the base address of the ADC12B module.

    Modified bits are ADC12ON of ADC12CTL0 register.

    Returns:None

    5.2.2.8 void ADC12_B_enableInterrupt (uint16_t baseAddress, uint16_t interruptMask0,uint16_t interruptMask1, uint16_t interruptMask2)

    Enables selected ADC12B interrupt sources.

    2014-06-25 28

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Enables the indicated ADC12B interrupt sources. Only the sources that are enabled can bereflected to the processor interrupt; disabled sources have no effect on the processor. Does notclear interrupt flags.

    Parameters:baseAddress is the base address of the ADC12B module.interruptMask0 is the bit mask of the memory buffer and overflow interrupt sources to

    be enabled. If the desired interrupt is not available in the selection forinterruptMask0, then simply pass in a 0 for this value. Valid values are:

    ADC12_B_IE0ADC12_B_IE1ADC12_B_IE2ADC12_B_IE3ADC12_B_IE4ADC12_B_IE5ADC12_B_IE6ADC12_B_IE7ADC12_B_IE8ADC12_B_IE9ADC12_B_IE10ADC12_B_IE11ADC12_B_IE12ADC12_B_IE13ADC12_B_IE14ADC12_B_IE15

    interruptMask1 is the bit mask of the memory buffer and overflow interrupt sources tobe enabled. If the desired interrupt is not available in the selection forinterruptMask1, then simply pass in a 0 for this value. Valid values are:

    ADC12_B_IE16ADC12_B_IE17ADC12_B_IE18ADC12_B_IE19ADC12_B_IE20ADC12_B_IE21ADC12_B_IE22ADC12_B_IE23ADC12_B_IE24ADC12_B_IE25ADC12_B_IE26ADC12_B_IE27ADC12_B_IE28ADC12_B_IE29ADC12_B_IE30ADC12_B_IE31

    interruptMask2 is the bit mask of the memory buffer and overflow interrupt sources tobe enabled. If the desired interrupt is not available in the selection forinterruptMask2, then simply pass in a 0 for this value. Valid values are:

    2014-06-25 29

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_INIE - Interrupt enable for a conversion in the result register is eithergreater than the ADC12LO or lower than the ADC12HI threshold. GIE bit mustbe set to enable the interrupt.ADC12_B_LOIE - Interrupt enable for the falling short of the lower limit interruptof the window comparator for the result register. GIE bit must be set to enablethe interrupt.ADC12_B_HIIE - Interrupt enable for the exceeding the upper limit of thewindow comparator for the result register. GIE bit must be set to enable theinterrupt.ADC12_B_OVIE - Interrupt enable for a conversion that is about to save to amemory buffer that has not been read out yet. GIE bit must be set to enable theinterrupt.ADC12_B_TOVIE - enable for a conversion that is about to start before theprevious conversion has been completed. GIE bit must be set to enable theinterrupt.ADC12_B_RDYIE - enable for the local buffered reference ready signal. GIE bitmust be set to enable the interrupt.

    Modified bits of ADC12IERx register.

    Returns:None

    5.2.2.9 uint16_t ADC12_B_getInterruptStatus (uint16_t baseAddress, uint8_tinterruptRegisterChoice, uint16_t memoryInterruptFlagMask)

    Returns the status of the selected memory interrupt flags.

    Returns the status of the selected memory interrupt flags. Note that the overflow interrupts do nothave an interrupt flag to clear; they must be accessed directly from the interrupt vector.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 58TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 36IAR 5.51.6 Size 34IAR 5.51.6 Speed 34

    MSPGCC 4.8.0 None 98MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the ADC12B module.interruptRegisterChoice is either 0, 1, or 2, to choose the correct interrupt register to updatememoryInterruptFlagMask is the bit mask of the memory buffer and overflow interrupt flags

    to be cleared. Valid values are:

    2014-06-25 30

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_IFG0 - interruptRegisterChoice = 0ADC12_B_IFG1ADC12_B_IFG2ADC12_B_IFG3ADC12_B_IFG4ADC12_B_IFG5ADC12_B_IFG6ADC12_B_IFG7ADC12_B_IFG8ADC12_B_IFG9ADC12_B_IFG10ADC12_B_IFG11ADC12_B_IFG12ADC12_B_IFG13ADC12_B_IFG14ADC12_B_IFG15ADC12_B_IFG16 - interruptRegisterChoice = 1ADC12_B_IFG17ADC12_B_IFG18ADC12_B_IFG19ADC12_B_IFG20ADC12_B_IFG21ADC12_B_IFG22ADC12_B_IFG23ADC12_B_IFG24ADC12_B_IFG25ADC12_B_IFG26ADC12_B_IFG27ADC12_B_IFG28ADC12_B_IFG29ADC12_B_IFG30ADC12_B_IFG31ADC12_B_INIFG - interruptRegisterChoice = 2ADC12_B_LOIFGADC12_B_HIIFGADC12_B_OVIFGADC12_B_TOVIFGADC12_B_RDYIFG - The selected ADC12B interrupt flags are cleared, so that it nolonger asserts. The memory buffer interrupt flags are only cleared when the memorybuffer is accessed. Note that the overflow interrupts do not have an interrupt flag toclear; they must be accessed directly from the interrupt vector.

    Returns:The current interrupt flag status for the corresponding mask.

    2014-06-25 31

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    5.2.2.10 uint32_t ADC12_B_getMemoryAddressForDMA (uint16_t baseAddress, uint8_tmemoryIndex)

    Returns the address of the specified memory buffer for the DMA module.

    Returns the address of the specified memory buffer. This can be used in conjunction with theDMA to store the converted data directly to memory.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 26TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 12IAR 5.51.6 Size 12IAR 5.51.6 Speed 12

    MSPGCC 4.8.0 None 34MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the ADC12B module.memoryIndex is the memory buffer to return the address of. Valid values are:

    ADC12_B_MEMORY_0ADC12_B_MEMORY_1ADC12_B_MEMORY_2ADC12_B_MEMORY_3ADC12_B_MEMORY_4ADC12_B_MEMORY_5ADC12_B_MEMORY_6ADC12_B_MEMORY_7ADC12_B_MEMORY_8ADC12_B_MEMORY_9ADC12_B_MEMORY_10ADC12_B_MEMORY_11ADC12_B_MEMORY_12ADC12_B_MEMORY_13ADC12_B_MEMORY_14ADC12_B_MEMORY_15ADC12_B_MEMORY_16ADC12_B_MEMORY_17ADC12_B_MEMORY_18ADC12_B_MEMORY_19ADC12_B_MEMORY_20ADC12_B_MEMORY_21ADC12_B_MEMORY_22ADC12_B_MEMORY_23

    2014-06-25 32

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_MEMORY_24ADC12_B_MEMORY_25ADC12_B_MEMORY_26ADC12_B_MEMORY_27ADC12_B_MEMORY_28ADC12_B_MEMORY_29ADC12_B_MEMORY_30ADC12_B_MEMORY_31

    Returns:address of the specified memory buffer

    5.2.2.11 uint16_t ADC12_B_getResults (uint16_t baseAddress, uint8_tmemoryBufferIndex)

    Returns the raw contents of the specified memory buffer.

    Returns the raw contents of the specified memory buffer. The format of the content depends onthe read-back format of the data: if the data is in signed 2s complement format then the contentsin the memory buffer will be left-justified with the least-significant bits as 0s, whereas if the data isin unsigned format then the contents in the memory buffer will be right- justified with themost-significant bits as 0s.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 26TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 10

    IAR 5.51.6 None 12IAR 5.51.6 Size 12IAR 5.51.6 Speed 12

    MSPGCC 4.8.0 None 28MSPGCC 4.8.0 Size 12MSPGCC 4.8.0 Speed 12

    Parameters:baseAddress is the base address of the ADC12B module.memoryBufferIndex is the specified memory buffer to read. Valid values are:

    ADC12_B_MEMORY_0ADC12_B_MEMORY_1ADC12_B_MEMORY_2ADC12_B_MEMORY_3ADC12_B_MEMORY_4ADC12_B_MEMORY_5ADC12_B_MEMORY_6ADC12_B_MEMORY_7ADC12_B_MEMORY_8

    2014-06-25 33

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_MEMORY_9ADC12_B_MEMORY_10ADC12_B_MEMORY_11ADC12_B_MEMORY_12ADC12_B_MEMORY_13ADC12_B_MEMORY_14ADC12_B_MEMORY_15ADC12_B_MEMORY_16ADC12_B_MEMORY_17ADC12_B_MEMORY_18ADC12_B_MEMORY_19ADC12_B_MEMORY_20ADC12_B_MEMORY_21ADC12_B_MEMORY_22ADC12_B_MEMORY_23ADC12_B_MEMORY_24ADC12_B_MEMORY_25ADC12_B_MEMORY_26ADC12_B_MEMORY_27ADC12_B_MEMORY_28ADC12_B_MEMORY_29ADC12_B_MEMORY_30ADC12_B_MEMORY_31

    Returns:A signed integer of the contents of the specified memory buffer.

    5.2.2.12 bool ADC12_B_init (uint16_t baseAddress, uint16_t sampleHoldSignalSource-Select, uint8_t clockSourceSelect, uint16_t clockSourceDivider, uint16_tclockSourcePredivider, uint16_t internalChannelMap)

    DEPRECATED - Initializes the ADC12B Module.

    This function initializes the ADC module to allow for analog-to-digital conversions. Specifically thisfunction sets up the sample-and-hold signal and clock sources for the ADC core to use forconversions. Upon successful completion of the initialization all of the ADC control registers will bereset, excluding the memory controls and reference module bits, the given parameters will be set,and the ADC core will be turned on (Note, that the ADC core only draws power during conversionsand remains off when not converting).Note that sample/hold signal sources are device dependent.Note that if re-initializing the ADC after starting a conversion with the startConversion() function,the disableConversion() must be called BEFORE this function can be called.

    Code Metrics:

    2014-06-25 34

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 82TI Compiler 4.2.1 Size 72TI Compiler 4.2.1 Speed 72

    IAR 5.51.6 None 72IAR 5.51.6 Size 60IAR 5.51.6 Speed 68

    MSPGCC 4.8.0 None 92MSPGCC 4.8.0 Size 70MSPGCC 4.8.0 Speed 110

    Parameters:baseAddress is the base address of the ADC12B module.sampleHoldSignalSourceSelect is the signal that will trigger a sample-and-hold for an input

    signal to be converted. Valid values are:ADC12_B_SAMPLEHOLDSOURCE_SC [Default]ADC12_B_SAMPLEHOLDSOURCE_1ADC12_B_SAMPLEHOLDSOURCE_2ADC12_B_SAMPLEHOLDSOURCE_3ADC12_B_SAMPLEHOLDSOURCE_4ADC12_B_SAMPLEHOLDSOURCE_5ADC12_B_SAMPLEHOLDSOURCE_6ADC12_B_SAMPLEHOLDSOURCE_7 - This parameter is device specific andsources should be found in the devices datasheet.Modified bits are ADC12SHSx of ADC12CTL1 register.

    clockSourceSelect selects the clock that will be used by the ADC12B core, and thesampling timer if a sampling pulse mode is enabled. Valid values are:

    ADC12_B_CLOCKSOURCE_ADC12OSC [Default] - MODOSC 5 MHz oscillatorfrom the UCSADC12_B_CLOCKSOURCE_ACLK - The Auxiliary ClockADC12_B_CLOCKSOURCE_MCLK - The Master ClockADC12_B_CLOCKSOURCE_SMCLK - The Sub-Master ClockModified bits are ADC12SSELx of ADC12CTL1 register.

    clockSourceDivider selects the amount that the clock will be divided. Valid values are:ADC12_B_CLOCKDIVIDER_1 [Default]ADC12_B_CLOCKDIVIDER_2ADC12_B_CLOCKDIVIDER_3ADC12_B_CLOCKDIVIDER_4ADC12_B_CLOCKDIVIDER_5ADC12_B_CLOCKDIVIDER_6ADC12_B_CLOCKDIVIDER_7ADC12_B_CLOCKDIVIDER_8Modified bits are ADC12DIVx of ADC12CTL1 register.

    clockSourcePredivider selects the amount that the clock will be predivided. Valid valuesare:

    ADC12_B_CLOCKPREDIVIDER__1 [Default]ADC12_B_CLOCKPREDIVIDER__4

    2014-06-25 35

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_CLOCKPREDIVIDER__32ADC12_B_CLOCKPREDIVIDER__64Modified bits are ADC12PDIV of ADC12CTL1 register.

    internalChannelMap selects what internal channel to map for ADC input channels Validvalues are:

    ADC12_B_MAPINTCH3ADC12_B_MAPINTCH2ADC12_B_MAPINTCH1ADC12_B_MAPINTCH0ADC12_B_TEMPSENSEMAPADC12_B_BATTMAPADC12_B_NOINTCHModified bits of ADC12CTL3 register.

    Returns:STATUS_SUCCESS or STATUS_FAILURE of the initialization process.

    5.2.2.13 bool ADC12_B_initialize (uint16_t baseAddress, ADC12_B_initializeParam param)

    Initializes the ADC12B Module.

    This function initializes the ADC module to allow for analog-to-digital conversions. Specifically thisfunction sets up the sample-and-hold signal and clock sources for the ADC core to use forconversions. Upon successful completion of the initialization all of the ADC control registers will bereset, excluding the memory controls and reference module bits, the given parameters will be set,and the ADC core will be turned on (Note, that the ADC core only draws power during conversionsand remains off when not converting).Note that sample/hold signal sources are device dependent.Note that if re-initializing the ADC after starting a conversion with the startConversion() function,the disableConversion() must be called BEFORE this function can be called.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 168TI Compiler 4.2.1 Size 104TI Compiler 4.2.1 Speed 104

    IAR 5.51.6 None 188IAR 5.51.6 Size 122IAR 5.51.6 Speed 152

    MSPGCC 4.8.0 None 274MSPGCC 4.8.0 Size 110MSPGCC 4.8.0 Speed 110

    Parameters:baseAddress is the base address of the ADC12B module.param is the pointer to struct for initialization.

    Returns:STATUS_SUCCESS or STATUS_FAILURE of the initialization process.

    2014-06-25 36

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    5.2.2.14 uint8_t ADC12_B_isBusy (uint16_t baseAddress)

    Returns the busy status of the ADC12B core.

    Returns the status of the ADC core if there is a conversion currently taking place.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 10TI Compiler 4.2.1 Speed 10

    IAR 5.51.6 None 8IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the ADC12B module.

    Returns:ADC12_B_BUSY or ADC12_B_NOTBUSY dependent if there is a conversion currently takingplace. Return one of the following:

    ADC12_B_NOTBUSYADC12_B_BUSYindicating if a conversion is taking place

    5.2.2.15 void ADC12_B_memoryConfigure (uint16_t baseAddress, uint8_tmemoryBufferControlIndex, uint8_t inputSourceSelect, uint16_trefVoltageSourceSelect, uint16_t endOfSequence, uint16_twindowComparatorSelect, uint16_t differentialModeSelect)

    DEPRECATED - Configures the controls of the selected memory buffer.

    Maps an input signal conversion into the selected memory buffer, as well as the positive andnegative reference voltages for each conversion being stored into this memory buffer. If theinternal reference is used for the positive reference voltage, the internal REF module must be usedto control the voltage level. Note that if a conversion has been started with the startConversion()function, then a call to disableConversions() is required before this function may be called.

    Code Metrics:

    2014-06-25 37

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 92TI Compiler 4.2.1 Size 50TI Compiler 4.2.1 Speed 50

    IAR 5.51.6 None 80IAR 5.51.6 Size 68IAR 5.51.6 Speed 76

    MSPGCC 4.8.0 None 94MSPGCC 4.8.0 Size 80MSPGCC 4.8.0 Speed 50

    Parameters:baseAddress is the base address of the ADC12B module.memoryBufferControlIndex is the selected memory buffer to set the configuration for. Valid

    values are:ADC12_B_MEMORY_0ADC12_B_MEMORY_1ADC12_B_MEMORY_2ADC12_B_MEMORY_3ADC12_B_MEMORY_4ADC12_B_MEMORY_5ADC12_B_MEMORY_6ADC12_B_MEMORY_7ADC12_B_MEMORY_8ADC12_B_MEMORY_9ADC12_B_MEMORY_10ADC12_B_MEMORY_11ADC12_B_MEMORY_12ADC12_B_MEMORY_13ADC12_B_MEMORY_14ADC12_B_MEMORY_15ADC12_B_MEMORY_16ADC12_B_MEMORY_17ADC12_B_MEMORY_18ADC12_B_MEMORY_19ADC12_B_MEMORY_20ADC12_B_MEMORY_21ADC12_B_MEMORY_22ADC12_B_MEMORY_23ADC12_B_MEMORY_24ADC12_B_MEMORY_25ADC12_B_MEMORY_26ADC12_B_MEMORY_27ADC12_B_MEMORY_28ADC12_B_MEMORY_29ADC12_B_MEMORY_30

    2014-06-25 38

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_MEMORY_31inputSourceSelect is the input that will store the converted data into the specified memory

    buffer. Valid values are:ADC12_B_INPUT_A0 [Default]ADC12_B_INPUT_A1ADC12_B_INPUT_A2ADC12_B_INPUT_A3ADC12_B_INPUT_A4ADC12_B_INPUT_A5ADC12_B_INPUT_A6ADC12_B_INPUT_A7ADC12_B_INPUT_A8ADC12_B_INPUT_A9ADC12_B_INPUT_A10ADC12_B_INPUT_A11ADC12_B_INPUT_A12ADC12_B_INPUT_A13ADC12_B_INPUT_A14ADC12_B_INPUT_A15ADC12_B_INPUT_A16ADC12_B_INPUT_A17ADC12_B_INPUT_A18ADC12_B_INPUT_A19ADC12_B_INPUT_A20ADC12_B_INPUT_A21ADC12_B_INPUT_A22ADC12_B_INPUT_A23ADC12_B_INPUT_A24ADC12_B_INPUT_A25ADC12_B_INPUT_A26ADC12_B_INPUT_A27ADC12_B_INPUT_A28ADC12_B_INPUT_A29ADC12_B_INPUT_TCMAPADC12_B_INPUT_BATMAPModified bits are ADC12INCHx of ADC12MCTLx register.

    refVoltageSourceSelect is the reference voltage source to set as the upper/lower limits forthe conversion stored in the specified memory. Valid values are:

    ADC12_B_VREFPOS_AVCC_VREFNEG_VSS [Default]ADC12_B_VREFPOS_INTBUF_VREFNEG_VSSADC12_B_VREFPOS_EXTNEG_VREFNEG_VSSADC12_B_VREFPOS_EXTBUF_VREFNEG_VSSADC12_B_VREFPOS_EXTPOS_VREFNEG_VSSADC12_B_VREFPOS_AVCC_VREFNEG_EXTBUFADC12_B_VREFPOS_AVCC_VREFNEG_EXTPOSADC12_B_VREFPOS_INTBUF_VREFNEG_EXTPOS

    2014-06-25 39

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_VREFPOS_AVCC_VREFNEG_INTBUFADC12_B_VREFPOS_EXTPOS_VREFNEG_INTBUFADC12_B_VREFPOS_AVCC_VREFNEG_EXTNEGADC12_B_VREFPOS_INTBUF_VREFNEG_EXTNEGADC12_B_VREFPOS_EXTPOS_VREFNEG_EXTNEGADC12_B_VREFPOS_EXTBUF_VREFNEG_EXTNEGModified bits are ADC12VRSEL of ADC12MCTLx register.

    endOfSequence indicates that the specified memory buffer will be the end of the sequence ifa sequenced conversion mode is selected Valid values are:

    ADC12_B_NOTENDOFSEQUENCE [Default] - The specified memory buffer will NOTbe the end of the sequence OR a sequenced conversion mode is not selected.ADC12_B_ENDOFSEQUENCE - The specified memory buffer will be the end of thesequence.Modified bits are ADC12EOS of ADC12MCTLx register.

    windowComparatorSelect sets the window comparator mode Valid values are:ADC12_B_WINDOW_COMPARATOR_DISABLE [Default]ADC12_B_WINDOW_COMPARATOR_ENABLE

    differentialModeSelect sets the differential mode Valid values are:ADC12_B_DIFFERENTIAL_MODE_DISABLE [Default]ADC12_B_DIFFERENTIAL_MODE_ENABLE

    Returns:None

    5.2.2.16 void ADC12_B_setAdcPowerMode (uint16_t baseAddress, uint8_t powerMode)

    Use to set the ADCs power conservation mode if the sampling rate is at 50-ksps or less.

    Sets ADCs power mode. If the user has a sampling rate greater than 50-ksps, then he/she canonly enable ADC12_B_REGULARPOWERMODE. If the sampling rate is 50-ksps or less, the usercan enable ADC12_B_LOWPOWERMODE granting additional power savings.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 32TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 18IAR 5.51.6 Size 6IAR 5.51.6 Speed 6

    MSPGCC 4.8.0 None 66MSPGCC 4.8.0 Size 12MSPGCC 4.8.0 Speed 12

    Parameters:baseAddress is the base address of the ADC12B module.powerMode is the specified maximum sampling rate. Valid values are:

    2014-06-25 40

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_REGULARPOWERMODE [Default] - If sampling rate is greater than50-ksps, there is no power saving feature available.ADC12_B_LOWPOWERMODE - If sampling rate is less than or equal to 50-ksps,select this value to save powerModified bits are ADC12SR of ADC12CTL2 register.

    Returns:None

    5.2.2.17 void ADC12_B_setDataReadBackFormat (uint16_t baseAddress, uint8_treadBackFormat)

    Use to set the read-back format of the converted data.

    Sets the format of the converted data: how it will be stored into the memory buffer, and how itshould be read back. The format can be set as right-justified (default), which indicates that thenumber will be unsigned, or left-justified, which indicates that the number will be signed in 2scomplement format. This change affects all memory buffers for subsequent conversions.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 32TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 18IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 66MSPGCC 4.8.0 Size 12MSPGCC 4.8.0 Speed 12

    Parameters:baseAddress is the base address of the ADC12B module.readBackFormat is the specified format to store the conversions in the memory buffer. Valid

    values are:ADC12_B_UNSIGNED_BINARY [Default]ADC12_B_SIGNED_2SCOMPLEMENTModified bits are ADC12DF of ADC12CTL2 register.

    Returns:None

    5.2.2.18 void ADC12_B_setResolution (uint16_t baseAddress, uint8_t resolutionSelect)

    Use to change the resolution of the converted data.

    This function can be used to change the resolution of the converted data from the default of12-bits.

    2014-06-25 41

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 34TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 20IAR 5.51.6 Size 10IAR 5.51.6 Speed 10

    MSPGCC 4.8.0 None 66MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the ADC12B module.resolutionSelect determines the resolution of the converted data. Valid values are:

    ADC12_B_RESOLUTION_8BITADC12_B_RESOLUTION_10BITADC12_B_RESOLUTION_12BIT [Default]Modified bits are ADC12RESx of ADC12CTL2 register.

    Returns:None

    5.2.2.19 void ADC12_B_setSampleHoldSignalInversion (uint16_t baseAddress, uint16_tinvertedSignal)

    Use to invert or un-invert the sample/hold signal.

    This function can be used to invert or un-invert the sample/hold signal. Note that if a conversionhas been started with the startConversion() function, then a call to disableConversions() isrequired before this function may be called.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 34TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 20IAR 5.51.6 Size 14IAR 5.51.6 Speed 14

    MSPGCC 4.8.0 None 56MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the ADC12B module.

    2014-06-25 42

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    invertedSignal set if the sample/hold signal should be inverted Valid values are:ADC12_B_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an input signalfor conversion will be started on a rising edge of the sample/hold signal.ADC12_B_INVERTEDSIGNAL - a sample-and-hold of an input signal for conversionwill be started on a falling edge of the sample/hold signal.Modified bits are ADC12ISSH of ADC12CTL1 register.

    Returns:None

    5.2.2.20 void ADC12_B_setupSamplingTimer (uint16_t baseAddress, uint16_tclockCycleHoldCountLowMem, uint16_t clockCycleHoldCountHighMem, uint16_tmultipleSamplesEnabled)

    Sets up and enables the Sampling Timer Pulse Mode.

    This function sets up the sampling timer pulse mode which allows the sample/hold signal to triggera sampling timer to sample-and-hold an input signal for a specified number of clock cycles withouthaving to hold the sample/hold signal for the entire period of sampling. Note that if a conversionhas been started with the startConversion() function, then a call to disableConversions() isrequired before this function may be called.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 60TI Compiler 4.2.1 Size 24TI Compiler 4.2.1 Speed 24

    IAR 5.51.6 None 36IAR 5.51.6 Size 32IAR 5.51.6 Speed 32

    MSPGCC 4.8.0 None 96MSPGCC 4.8.0 Size 26MSPGCC 4.8.0 Speed 26

    Parameters:baseAddress is the base address of the ADC12B module.clockCycleHoldCountLowMem sets the amount of clock cycles to sample- and-hold for the

    higher memory buffers 0-7. Valid values are:ADC12_B_CYCLEHOLD_4_CYCLES [Default]ADC12_B_CYCLEHOLD_8_CYCLESADC12_B_CYCLEHOLD_16_CYCLESADC12_B_CYCLEHOLD_32_CYCLESADC12_B_CYCLEHOLD_64_CYCLESADC12_B_CYCLEHOLD_96_CYCLESADC12_B_CYCLEHOLD_128_CYCLESADC12_B_CYCLEHOLD_192_CYCLESADC12_B_CYCLEHOLD_256_CYCLES

    2014-06-25 43

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    ADC12_B_CYCLEHOLD_384_CYCLESADC12_B_CYCLEHOLD_512_CYCLESADC12_B_CYCLEHOLD_768_CYCLESADC12_B_CYCLEHOLD_1024_CYCLESModified bits are ADC12SHT0x of ADC12CTL0 register.

    clockCycleHoldCountHighMem sets the amount of clock cycles to sample-and-hold for thehigher memory buffers 8-15. Valid values are:

    ADC12_B_CYCLEHOLD_4_CYCLES [Default]ADC12_B_CYCLEHOLD_8_CYCLESADC12_B_CYCLEHOLD_16_CYCLESADC12_B_CYCLEHOLD_32_CYCLESADC12_B_CYCLEHOLD_64_CYCLESADC12_B_CYCLEHOLD_96_CYCLESADC12_B_CYCLEHOLD_128_CYCLESADC12_B_CYCLEHOLD_192_CYCLESADC12_B_CYCLEHOLD_256_CYCLESADC12_B_CYCLEHOLD_384_CYCLESADC12_B_CYCLEHOLD_512_CYCLESADC12_B_CYCLEHOLD_768_CYCLESADC12_B_CYCLEHOLD_1024_CYCLESModified bits are ADC12SHT1x of ADC12CTL0 register.

    multipleSamplesEnabled allows multiple conversions to start without a trigger signal fromthe sample/hold signal Valid values are:

    ADC12_B_MULTIPLESAMPLESDISABLE [Default] - a timer trigger will be neededto start every ADC conversion.ADC12_B_MULTIPLESAMPLESENABLE - during a sequenced and/or repeatedconversion mode, after the first conversion, no sample/hold signal is necessary tostart subsequent sample/hold and convert processes.Modified bits are ADC12MSC of ADC12CTL0 register.

    Returns:None

    5.2.2.21 void ADC12_B_setWindowCompAdvanced (uint16_t baseAddress, uint16_thighThreshold, uint16_t lowThreshold)

    Sets the high and low threshold for the window comparator feature.

    Sets the high and low threshold for the window comparator feature. Use the ADC12HIIE,ADC12INIE, ADC12LOIE interrupts to utilize this feature.

    Code Metrics:

    2014-06-25 44

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 36TI Compiler 4.2.1 Size 10TI Compiler 4.2.1 Speed 10

    IAR 5.51.6 None 20IAR 5.51.6 Size 18IAR 5.51.6 Speed 18

    MSPGCC 4.8.0 None 46MSPGCC 4.8.0 Size 10MSPGCC 4.8.0 Speed 10

    Parameters:baseAddress is the base address of the ADC12B module.highThreshold is the upper bound that could trip an interrupt for the window comparator.lowThreshold is the lower bound that could trip on interrupt for the window comparator.

    Returns:None

    5.2.2.22 void ADC12_B_startConversion (uint16_t baseAddress, uint16_tstartingMemoryBufferIndex, uint8_t conversionSequenceModeSelect)

    Enables/Starts an Analog-to-Digital Conversion.

    Enables/starts the conversion process of the ADC. If the sample/hold signal source chosen duringinitialization was ADC12OSC, then the conversion is started immediately, otherwise the chosensample/hold signal source starts the conversion by a rising edge of the signal. Keep in mind whenselecting conversion modes, that for sequenced and/or repeated modes, to keep thesample/hold-and-convert process continuing without a trigger from the sample/hold signal source,the multiple samples must be enabled using the ADC12_B_setupSamplingTimer() function. Notethat after this function is called, the ADC12_B_stopConversions() has to be called to re-initializethe ADC, reconfigure a memory buffer control, enable/disable the sampling timer, or to change theinternal reference voltage.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 82TI Compiler 4.2.1 Size 44TI Compiler 4.2.1 Speed 44

    IAR 5.51.6 None 56IAR 5.51.6 Size 48IAR 5.51.6 Speed 48

    MSPGCC 4.8.0 None 162MSPGCC 4.8.0 Size 46MSPGCC 4.8.0 Speed 46

    Parameters:baseAddress is the base address of the ADC12B module.

    2014-06-25 45

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    startingMemoryBufferIndex is the memory buffer that will hold the first or only conversion.Valid values are:

    ADC12_B_START_AT_ADC12MEM0 [Default]ADC12_B_START_AT_ADC12MEM1ADC12_B_START_AT_ADC12MEM2ADC12_B_START_AT_ADC12MEM3ADC12_B_START_AT_ADC12MEM4ADC12_B_START_AT_ADC12MEM5ADC12_B_START_AT_ADC12MEM6ADC12_B_START_AT_ADC12MEM7ADC12_B_START_AT_ADC12MEM8ADC12_B_START_AT_ADC12MEM9ADC12_B_START_AT_ADC12MEM10ADC12_B_START_AT_ADC12MEM11ADC12_B_START_AT_ADC12MEM12ADC12_B_START_AT_ADC12MEM13ADC12_B_START_AT_ADC12MEM14ADC12_B_START_AT_ADC12MEM15ADC12_B_START_AT_ADC12MEM16ADC12_B_START_AT_ADC12MEM17ADC12_B_START_AT_ADC12MEM18ADC12_B_START_AT_ADC12MEM19ADC12_B_START_AT_ADC12MEM20ADC12_B_START_AT_ADC12MEM21ADC12_B_START_AT_ADC12MEM22ADC12_B_START_AT_ADC12MEM23ADC12_B_START_AT_ADC12MEM24ADC12_B_START_AT_ADC12MEM25ADC12_B_START_AT_ADC12MEM26ADC12_B_START_AT_ADC12MEM27ADC12_B_START_AT_ADC12MEM28ADC12_B_START_AT_ADC12MEM29ADC12_B_START_AT_ADC12MEM30ADC12_B_START_AT_ADC12MEM31Modified bits are ADC12CSTARTADDx of ADC12CTL1 register.

    conversionSequenceModeSelect determines the ADC operating mode. Valid values are:ADC12_B_SINGLECHANNEL [Default] - one-time conversion of a single channelinto a single memory buffer.ADC12_B_SEQOFCHANNELS - one time conversion of multiple channels into thespecified starting memory buffer and each subsequent memory buffer up until theconversion is stored in a memory buffer dedicated as the end-of-sequence by thememorys control register.ADC12_B_REPEATED_SINGLECHANNEL - repeated conversions of one channelinto a single memory buffer.ADC12_B_REPEATED_SEQOFCHANNELS - repeated conversions of multiplechannels into the specified starting memory buffer and each subsequent memorybuffer up until the conversion is stored in a memory buffer dedicated as theend-of-sequence by the memorys control register.Modified bits are ADC12CONSEQx of ADC12CTL1 register.

    2014-06-25 46

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Modified bits of ADC12CTL1 register and bits of ADC12CTL0 register.

    Returns:None

    5.3 Programming Example

    The following example shows how to initialize and use the ADC12_B API to start a single channelwith single conversion using an external positive reference for the ADC12_B.

    //Initialize the ADC12 Module/*Base address of ADC12 ModuleUse internal ADC12 bit as sample/hold signal to start conversionUSE MODOSC 5MHZ Digital Oscillator as clock sourceUse default clock divider/pre-divider of 1Map to internal channel 0

    */ADC12_B_init(ADC12_B_BASE,

    ADC12_B_SAMPLEHOLDSOURCE_SC,ADC12_B_CLOCKSOURCE_ADC12OSC,ADC12_B_CLOCKDIVIDER_1,ADC12_B_CLOCKPREDIVIDER__1,ADC12_B_MAPINTCH0);

    //Enable the ADC12_B moduleADC12_B_enable(ADC12_B_BASE);

    /*Base address of ADC12 ModuleFor memory buffers 0-7 sample/hold for 16 clock cyclesFor memory buffers 8-15 sample/hold for 4 clock cycles (default)Disable Multiple Sampling

    */ADC12_B_setupSamplingTimer(ADC12_B_BASE,

    ADC12_B_CYCLEHOLD_16_CYCLES,ADC12_B_CYCLEHOLD_4_CYCLES,ADC12_B_MULTIPLESAMPLESDISABLE);

    //Configure Memory Buffer/*Base address of the ADC12 ModuleConfigure memory buffer 0Map input A0 to memory buffer 0Vref+ = AVccVref- = EXT PositiveMemory buffer 0 is not the end of a sequence

    */ADC12_B_memoryConfigure(ADC12_B_BASE,

    ADC12_B_MEMORY_0,ADC12_B_INPUT_A0,ADC12_B_VREFPOS_EXTPOS_VREFNEG_VSS,ADC12_B_NOTENDOFSEQUENCE,ADC12_B_WINDOW_COMPARATOR_DISABLE,ADC12_B_DIFFERENTIAL_MODE_DISABLE);

    while (1){

    //Enable/Start first sampling and conversion cycle/*

    Base address of ADC12 Module

    2014-06-25 47

  • 12-Bit Analog-to-Digital Converter (ADC12_B)

    Start the conversion into memory buffer 0Use the single-channel, single-conversion mode

    */ADC12_B_startConversion(ADC12_B_BASE,

    ADC12_B_MEMORY_0,ADC12_B_SINGLECHANNEL);

    //Poll for interrupt on memory buffer 0while (!ADC12_B_getInterruptStatus(ADC12_B_BASE,

    0,ADC12_B_IFG0));

    __no_operation(); // SET BREAKPOINT HERE}

    2014-06-25 48

  • Advanced Encryption Standard (AES256)

    6 Advanced Encryption Standard (AES256)Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    6.1 IntroductionThe AES256 accelerator module performs encryption and decryption of 128-bit data with 128-bit keys according to theadvanced encryption standard (AES256) (FIPS PUB 197) in hardware. The AES256 accelerator features are:

    Encryption and decryption according to AES256 FIPS PUB 197 with 128-bit key

    On-the-fly key expansion for encryption and decryption

    Off-line key generation for decryption

    Byte and word access to key, input, and output data

    AES256 ready interrupt flag The AES256256 accelerator module performs encryption and decryption of 128-bit datawith 128-/192-/256-bit keys according to the advanced encryption standard (AES256) (FIPS PUB 197) in hardware.The AES256 accelerator features are: AES256 encryption ? 128 bit - 168 cycles ? 192 bit - 204 cycles ? 256 bit -234 cycles AES256 decryption ? 128 bit - 168 cycles ? 192 bit - 206 cycles ? 256 bit - 234 cycles

    On-the-fly key expansion for encryption and decryption

    Offline key generation for decryption

    Shadow register storing the initial key for all key lengths

    Byte and word access to key, input data, and output data

    AES256 ready interrupt flag

    This driver is contained in aes256.c, with aes256.h containing the API definitions for use by applications.

    The following code metrics were performed with the TI Compiler 4.2.1 compiler, IAR 5.51.6 compiler and MSPGCC4.8.0 compiler with different optimization settings. Users may see different code sizes depending on their projectsettings so it is best to perform your benchmarks within your project. These sizes contain all functions of the peripheralbut only functions that are used will be linked into the application and added to the total code size. To see individualAPI code metrics see the specific API below.

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 1358TI Compiler 4.2.1 Size 654TI Compiler 4.2.1 Speed 1452

    IAR 5.51.6 None 994IAR 5.51.6 Size 474IAR 5.51.6 Speed 652

    MSPGCC 4.8.0 None 1716MSPGCC 4.8.0 Size 728MSPGCC 4.8.0 Speed 1430

    6.2 API Functions

    Functionsvoid AES256_clearErrorFlag (uint16_t baseAddress)void AES256_clearInterruptFlag (uint16_t baseAddress)void AES256_decryptData (uint16_t baseAddress, const uint8_t data, uint8_t decryptedData)

    2014-06-25 49

  • Advanced Encryption Standard (AES256)

    void AES256_disableInterrupt (uint16_t baseAddress)void AES256_enableInterrupt (uint16_t baseAddress)void AES256_encryptData (uint16_t baseAddress, const uint8_t data, uint8_t encryptedData)uint8_t AES256_getDataOut (uint16_t baseAddress, uint8_t outputData)uint32_t AES256_getErrorFlagStatus (uint16_t baseAddress)uint32_t AES256_getInterruptFlagStatus (uint16_t baseAddress)uint16_t AES256_isBusy (uint16_t baseAddress)void AES256_reset (uint16_t baseAddress)uint8_t AES256_setCipherKey (uint16_t baseAddress, const uint8_t cipherKey, uint16_t keyLength)uint8_t AES256_setDecipherKey (uint16_t baseAddress, const uint8_t cipherKey, uint16_t keyLength)void AES256_startDecryptData (uint16_t baseAddress, const uint8_t data)void AES256_startEncryptData (uint16_t baseAddress, const uint8_t data)uint8_t AES256_startSetDecipherKey (uint16_t baseAddress, const uint8_t cipherKey, uint16_t keyLength)

    6.2.1 Detailed DescriptionThe AES256 module APIs are

    AES256_setCipherKey(),

    AES256256_setCipherKey(),

    AES256_encryptData(),

    AES256_decryptDataUsingEncryptionKey(),

    AES256_generateFirstRoundKey(),

    AES256_decryptData(),

    AES256_reset(),

    AES256_startEncryptData(),

    AES256_startDecryptDataUsingEncryptionKey(),

    AES256_startDecryptData(),

    AES256_startGenerateFirstRoundKey(),

    AES256_getDataOut()

    The AES256 interrupt handler functions

    AES256_enableInterrupt(),

    AES256_disableInterrupt(),

    AES256_clearInterruptFlag(),

    6.2.2 Function Documentation

    6.2.2.1 void AES256_clearErrorFlag (uint16_t baseAddress)

    Clears the AES256 error flag.

    Clears the AES256 error flag that results from a key or data being written while the AES256 module is busy.

    Code Metrics:

    2014-06-25 50

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 10IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Modified bits are AESERRFG of AESACTL0 register.

    Returns:None

    6.2.2.2 void AES256_clearInterruptFlag (uint16_t baseAddress)

    Clears the AES256 ready interrupt flag.

    This function clears the AES256 ready interrupt flag. This flag is automatically cleared when AES256ADOUT is read, orwhen AES256AKEY or AES256ADIN is written. This function should be used when the flag needs to be reset and it hasnot been automatically cleared by one of the previous actions.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 10IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Modified bits are AESRDYIFG of AESACTL0 register.

    Returns:None

    6.2.2.3 void AES256_decryptData (uint16_t baseAddress, const uint8_t data, uint8_t decryptedData)

    Decrypts a block of data using the AES256 module.

    This function requires a pregenerated decryption key. A key can be loaded and pregenerated by using functionAES256_setDecipherKey() or AES256_startSetDecipherKey(). The decryption takes 167 MCLK.

    Code Metrics:

    2014-06-25 51

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 188TI Compiler 4.2.1 Size 78TI Compiler 4.2.1 Speed 304

    IAR 5.51.6 None 138IAR 5.51.6 Size 34IAR 5.51.6 Speed 54

    MSPGCC 4.8.0 None 234MSPGCC 4.8.0 Size 92MSPGCC 4.8.0 Speed 288

    Parameters:baseAddress is the base address of the AES256 module.data is a pointer to an uint8_t array with a length of 16 bytes that contains encrypted data to be decrypted.decryptedData is a pointer to an uint8_t array with a length of 16 bytes in that the decrypted data will be written.

    Returns:None

    6.2.2.4 void AES256_disableInterrupt (uint16_t baseAddress)

    Disables AES256 ready interrupt.

    Disables AES256 ready interrupt. This interrupt is reset by a PUC, but not reset by AES256_reset.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 10IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Modified bits are AESRDYIE of AESACTL0 register.

    Returns:None

    6.2.2.5 void AES256_enableInterrupt (uint16_t baseAddress)

    Enables AES256 ready interrupt.

    Enables AES256 ready interrupt. This interrupt is reset by a PUC, but not reset by AES256_reset.

    Code Metrics:

    2014-06-25 52

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 10IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Modified bits are AESRDYIE of AESACTL0 register.

    Returns:None

    6.2.2.6 void AES256_encryptData (uint16_t baseAddress, const uint8_t data, uint8_t encryptedData)

    Encrypts a block of data using the AES256 module.

    The cipher key that is used for encryption should be loaded in advance by using function AES256_setCipherKey()

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 188TI Compiler 4.2.1 Size 78TI Compiler 4.2.1 Speed 302

    IAR 5.51.6 None 138IAR 5.51.6 Size 22IAR 5.51.6 Speed 56

    MSPGCC 4.8.0 None 234MSPGCC 4.8.0 Size 92MSPGCC 4.8.0 Speed 288

    Parameters:baseAddress is the base address of the AES256 module.data is a pointer to an uint8_t array with a length of 16 bytes that contains data to be encrypted.encryptedData is a pointer to an uint8_t array with a length of 16 bytes in that the encrypted data will be written.

    Returns:None

    6.2.2.7 uint8_t AES256_getDataOut (uint16_t baseAddress, uint8_t outputData)Reads back the output data from AES256 module.

    This function is meant to use after an encryption or decryption process that was started and finished by initiating aninterrupt by use of AES256_startEncryptData or AES256_startDecryptData functions.

    Code Metrics:

    2014-06-25 53

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 98TI Compiler 4.2.1 Size 42TI Compiler 4.2.1 Speed 146

    IAR 5.51.6 None 82IAR 5.51.6 Size 56IAR 5.51.6 Speed 58

    MSPGCC 4.8.0 None 124MSPGCC 4.8.0 Size 52MSPGCC 4.8.0 Speed 130

    Parameters:baseAddress is the base address of the AES256 module.outputData is a pointer to an uint8_t array with a length of 16 bytes in that the data will be written.

    Returns:STATUS_SUCCESS if data is valid, otherwise STATUS_FAIL

    6.2.2.8 uint32_t AES256_getErrorFlagStatus (uint16_t baseAddress)

    Gets the AES256 error flag status.

    Checks the AES256 error flag that results from a key or data being written while the AES256 module is busy. If the flag isset, it needs to be cleared using AES256_clearErrorFlag.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 20TI Compiler 4.2.1 Size 12TI Compiler 4.2.1 Speed 12

    IAR 5.51.6 None 10IAR 5.51.6 Size 10IAR 5.51.6 Speed 10

    MSPGCC 4.8.0 None 36MSPGCC 4.8.0 Size 10MSPGCC 4.8.0 Speed 10

    Parameters:baseAddress is the base address of the AES256 module.

    Returns:One of the following:

    AES256_ERROR_OCCURREDAES256_NO_ERRORindicating the error flag status

    6.2.2.9 uint32_t AES256_getInterruptFlagStatus (uint16_t baseAddress)

    Gets the AES256 ready interrupt flag status.

    This function checks the AES256 ready interrupt flag. This flag is automatically cleared when AES256ADOUT is read, orwhen AES256AKEY or AES256ADIN is written. This function can be used to confirm that this has been done.

    Code Metrics:

    2014-06-25 54

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 22TI Compiler 4.2.1 Size 14TI Compiler 4.2.1 Speed 14

    IAR 5.51.6 None 24IAR 5.51.6 Size 18IAR 5.51.6 Speed 20

    MSPGCC 4.8.0 None 30MSPGCC 4.8.0 Size 14MSPGCC 4.8.0 Speed 14

    Parameters:baseAddress is the base address of the AES256 module.

    Returns:One of the following:

    AES256_READY_INTERRUPTAES256_NOTREADY_INTERRUPTindicating the status of the AES256 ready status

    6.2.2.10 uint16_t AES256_isBusy (uint16_t baseAddress)

    Gets the AES256 module busy status.

    Gets the AES256 module busy status. If a key or data are written while the AES256 module is busy, an error flag will bethrown.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 10TI Compiler 4.2.1 Speed 10

    IAR 5.51.6 None 8IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 18MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Returns:One of the following:

    AES256_BUSYAES256_NOT_BUSYindicating if the AES256 module is busy

    6.2.2.11 void AES256_reset (uint16_t baseAddress)

    Resets AES256 Module immediately.

    This function performs a software reset on the AES256 Module, note that this does not affect the AES256 ready interrupt.

    Code Metrics:

    2014-06-25 55

  • Advanced Encryption Standard (AES256)

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 18TI Compiler 4.2.1 Size 8TI Compiler 4.2.1 Speed 8

    IAR 5.51.6 None 10IAR 5.51.6 Size 8IAR 5.51.6 Speed 8

    MSPGCC 4.8.0 None 24MSPGCC 4.8.0 Size 8MSPGCC 4.8.0 Speed 8

    Parameters:baseAddress is the base address of the AES256 module.

    Modified bits are AESSWRST of AESACTL0 register.

    Returns:None

    6.2.2.12 uint8_t AES256_setCipherKey (uint16_t baseAddress, const uint8_t cipherKey,uint16_t keyLength)

    Loads a 128, 192 or 256 bit cipher key to AES256 module.

    This function loads a 128, 192 or 256 bit cipher key to AES256 module. Requires both a key as well as the length of thekey provided. Acceptable key lengths are AES256_KEYLENGTH_128BIT, AES256_KEYLENGTH_192BIT, orAES256_KEYLENGTH_256BIT

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 174TI Compiler 4.2.1 Size 98TI Compiler 4.2.1 Speed 98

    IAR 5.51.6 None 130IAR 5.51.6 Size 82IAR 5.51.6 Speed 102

    MSPGCC 4.8.0 None 220MSPGCC 4.8.0 Size 110MSPGCC 4.8.0 Speed 112

    Parameters:baseAddress is the base address of the AES256 module.cipherKey is a pointer to an uint8_t array with a length of 16 bytes that contains a 128 bit cipher key.keyLength is the length of the key. Valid values are:

    AES256_KEYLENGTH_128BITAES256_KEYLENGTH_192BITAES256_KEYLENGTH_256BIT

    Returns:STATUS_SUCCESS or STATUS_FAIL of key loading

    6.2.2.13 uint8_t AES256_setDecipherKey (uint16_t baseAddress, const uint8_t cipherKey, uint16_t keyLength)

    Sets the decipher key.

    2014-06-25 56

  • Advanced Encryption Standard (AES256)

    The API AES256_startSetDecipherKey or AES256_setDecipherKey must be invoked before invokingAES256_startDecryptData.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 186TI Compiler 4.2.1 Size 100TI Compiler 4.2.1 Speed 100

    IAR 5.51.6 None 138IAR 5.51.6 Size 74IAR 5.51.6 Speed 104

    MSPGCC 4.8.0 None 238MSPGCC 4.8.0 Size 112MSPGCC 4.8.0 Speed 114

    Parameters:baseAddress is the base address of the AES256 module.cipherKey is a pointer to an uint8_t array with a length of 16 bytes that contains a 128 bit cipher key.keyLength is the length of the key. Valid values are:

    AES256_KEYLENGTH_128BITAES256_KEYLENGTH_192BITAES256_KEYLENGTH_256BIT

    Returns:STATUS_SUCCESS or STATUS_FAIL of key loading

    6.2.2.14 void AES256_startDecryptData (uint16_t baseAddress, const uint8_t data)Decrypts a block of data using the AES256 module.

    This is the non-blocking equivalent of AES256_decryptData(). This function requires a pregenerated decryption key. A keycan be loaded and pregenerated by using function AES256_setDecipherKey() or AES256_startSetDecipherKey(). Thedecryption takes 167 MCLK. It is recommended to use interrupt to check for procedure completion then use theAES256_getDataOut() API to retrieve the decrypted data.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 100TI Compiler 4.2.1 Size 44TI Compiler 4.2.1 Speed 168

    IAR 5.51.6 None 74IAR 5.51.6 Size 30IAR 5.51.6 Speed 54

    MSPGCC 4.8.0 None 120MSPGCC 4.8.0 Size 50MSPGCC 4.8.0 Speed 162

    Parameters:baseAddress is the base address of the AES256 module.data is a pointer to an uint8_t array with a length of 16 bytes that contains encrypted data to be decrypted.

    Returns:None

    2014-06-25 57

  • Advanced Encryption Standard (AES256)

    6.2.2.15 void AES256_startEncryptData (uint16_t baseAddress, const uint8_t data)Starts an encryption process on the AES256 module.

    The cipher key that is used for decryption should be loaded in advance by using function AES256_setCipherKey(). This isa non-blocking equivalent of AES256_encryptData(). It is recommended to use the interrupt functionality to check forprocedure completion then use the AES256_getDataOut() API to retrieve the encrypted data.

    Code Metrics:

    Compiler Optimization Code Size

    TI Compiler 4.2.1 None 100TI Compiler 4.2.1 Size 44TI Compiler 4.2.1 Speed 164

    IAR 5.51.6 None 74IAR 5.51.6 Size 28IAR 5.51.6 Speed 56

    MSPGCC 4.8.0 None 120MSPGCC 4.8.0 Size 50MSPGCC 4.8.0 Speed 162

    Parameters:baseAddress is the base address of the AES256 module.data is a pointer to an uint8_t array with a length of 16 bytes that contains data to be encrypted.

    Returns:None

    6.2.2.16 uint8_t AES256_startSetDecipherKey (uint16_t baseAddress, const uint8_t cipherKey, uint16_t keyLength)

    Sets the decipher key.

    The API AES256_startS