element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Safe and Sound
  • Challenges & Projects
  • Design Challenges
  • Safe and Sound
  • More
  • Cancel
Safe and Sound
Blog Safe and Sound Wearables- Hearing Guard System #12: Adding ADC Channels in TI-RTOS
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jomoenginer
  • Date Created: 22 May 2017 7:11 AM Date Created
  • Views 620 views
  • Likes 3 likes
  • Comments 1 comment
  • msp432p401r
  • safe & sound
  • adc channel
  • safe&sound
  • ti-rtos
Related
Recommended

Safe and Sound Wearables- Hearing Guard System #12: Adding ADC Channels in TI-RTOS

jomoenginer
jomoenginer
22 May 2017

Adding ADC Channels to TI-RTOS with the MSP432 Launchpad

 

Hardware:

SimpleLinkTm MSP432P401R LaunchPad

430BOOST-SHARP96

 

Software:

TI-RTOS for MSPx - v2.20.00.06

 

With my Hearing Guard System since I am collecting data from an audio source I require an ADC input on the MSP432 However due to using multiple Booster Packs such as the  430BOOST-SHARP96430BOOST-SHARP96 LCD DLP-790ABP and the  BOOSTXL-CC2650MABOOSTXL-CC2650MA as well as possibly others I need to more ADC channels than the 2(ADC0 and ADC1 that are defined in TI-RTOS This took a bit of researching and mainly trial and error but I was able to finally crack the code with how to enable the ADC channels for the MSP432 in TI-RTOS

 

For this exercises, I am going to use the "adcsinglechannel_MSP_EXP432P401R_TI" example found in the TI-RTOS for MSPx v2.20.00.06 package.  This can be added to Code Composer Studio via Resource Explorer.

 

image

 

The first thing that is needed is add the the extra ADC channels to the Enum of ADC Channels in the MSP_EXP432P401R.h file:

Example for up to 9 channels:

 

/*!
 *  @def    MSP_EXP432P401R_ADCName
 *  @brief  Enum of ADC channels on the MSP_EXP432P401R dev board
 */
typedef enum MSP_EXP432P401R_ADCName {
    MSP_EXP432P401R_ADC0 = 0,
    MSP_EXP432P401R_ADC1,
  MSP_EXP432P401R_ADC2,
  MSP_EXP432P401R_ADC3,
  MSP_EXP432P401R_ADC4,
  MSP_EXP432P401R_ADC5,
  MSP_EXP432P401R_ADC6,
  MSP_EXP432P401R_ADC7,
  MSP_EXP432P401R_ADC8,
    MSP_EXP432P401R_ADCCOUNT
}MSP_EXP432P401R_ADCName;

 

 

Then, in the MSP_EXP432P401R.c file, add the ADC channels to the ADC configuration Structure.

NOTE; Each channel requires a configuration.

 

/* ADC objects */
ADCMSP432_Object adcMSP432Objects[MSP_EXP432P401R_ADCCOUNT];


/* ADC configuration structure */
const ADCMSP432_HWAttrs adcMSP432HWAttrs[MSP_EXP432P401R_ADCCOUNT] = {
    {
        .channel = ADC_INPUT_A0,
        .gpioPort = GPIO_PORT_P5,
        .gpioPin = GPIO_PIN5,
        .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
        .refVoltage = REF_A_VREF2_5V,
        .resolution = ADC_14BIT
    },
    {
        .channel = ADC_INPUT_A1,
        .gpioPort = GPIO_PORT_P5,
        .gpioPin = GPIO_PIN4,
        .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
        .refVoltage = REF_A_VREF1_45V,
        .resolution = ADC_8BIT
    },
    {
        .channel = ADC_INPUT_A2,
        .gpioPort = GPIO_PORT_P5,
        .gpioPin = GPIO_PIN3,
        .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
        .refVoltage = REF_A_VREF2_5V,
        .resolution = ADC_14BIT
    },
  {
     .channel = ADC_INPUT_A3,
     .gpioPort = GPIO_PORT_P5,
     .gpioPin = GPIO_PIN2,
     .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
     .refVoltage = REF_A_VREF2_5V,
     .resolution = ADC_14BIT
  },
  {
     .channel = ADC_INPUT_A4,
     .gpioPort = GPIO_PORT_P5,
     .gpioPin = GPIO_PIN1,
     .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
     .refVoltage = REF_A_VREF2_5V,
     .resolution = ADC_14BIT
  },
  {
     .channel = ADC_INPUT_A5,
     .gpioPort = GPIO_PORT_P5,
     .gpioPin = GPIO_PIN0,
     .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
     .refVoltage = REF_A_VREF2_5V,
     .resolution = ADC_14BIT
  },
  {
     .channel = ADC_INPUT_A6,
     .gpioPort = GPIO_PORT_P4,
     .gpioPin = GPIO_PIN7,
     .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
     .refVoltage = REF_A_VREF2_5V,
     .resolution = ADC_14BIT
  },
  {
     .channel = ADC_INPUT_A7,
     .gpioPort = GPIO_PORT_P4,
     .gpioPin = GPIO_PIN6,
     .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
     .refVoltage = REF_A_VREF2_5V,
     .resolution = ADC_14BIT
  },
    {
        .channel = ADC_INPUT_A8,
        .gpioPort = GPIO_PORT_P4,
        .gpioPin = GPIO_PIN5,
        .gpioMode = GPIO_TERTIARY_MODULE_FUNCTION,
        .refVoltage = REF_A_VREF2_5V,
        .resolution = ADC_14BIT
    }
};

 

 

Below this, there are defines for each channel to the ADC_config array.

 

const ADC_Config ADC_config[] = {
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[0],
        .hwAttrs = &adcMSP432HWAttrs[0]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[1],
        .hwAttrs = &adcMSP432HWAttrs[1]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[2],
        .hwAttrs = &adcMSP432HWAttrs[2]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[3],
        .hwAttrs = &adcMSP432HWAttrs[3]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[4],
        .hwAttrs = &adcMSP432HWAttrs[4]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[5],
        .hwAttrs = &adcMSP432HWAttrs[5]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[6],
        .hwAttrs = &adcMSP432HWAttrs[6]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[7],
        .hwAttrs = &adcMSP432HWAttrs[7]
    },
    {
        .fxnTablePtr = &ADCMSP432_fxnTable,
        .object = &adcMSP432Objects[8],
        .hwAttrs = &adcMSP432HWAttrs[8]
    },
    {NULL, NULL, NULL}
};

 

Still in the MSP_EXP432P401R.c, I found I had to add an GPIOMSP432 entry for the ADC channel I wanted to use; in this case ADC8 (A8).

 

GPIO_PinConfig gpioPinConfigs[] = {
    /* Input pins */
    /* MSP_EXP432P401R_S1 */
    GPIOMSP432_P1_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
    /* MSP_EXP432P401R_S2 */
    GPIOMSP432_P1_4 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,


    /* Output pins */
    /* MSP_EXP432P401R_LED1 */
    GPIOMSP432_P1_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_RED */
    GPIOMSP432_P2_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,


    /*
     * MSP_EXP432P401R_LED_GREEN & MSP_EXP432P401R_LED_BLUE are used for
     * PWM examples.  Uncomment the following lines if you would like to control
     * the LEDs with the GPIO driver.
     */
    /* MSP_EXP432P401R_LED_GREEN */
    //GPIOMSP432_P2_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_BLUE */
    //GPIOMSP432_P2_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW
    GPIOMSP432_P4_5 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING
};

 

 

Now, this these defined, the values that will be used in the code can be added to the Board.h file.

#define Board_ADC0                  MSP_EXP432P401R_ADC0
#define Board_ADC1                  MSP_EXP432P401R_ADC1
#define Board_ADC2                  MSP_EXP432P401R_ADC2
#define Board_ADC3                  MSP_EXP432P401R_ADC3
#define Board_ADC4                  MSP_EXP432P401R_ADC4
#define Board_ADC5                  MSP_EXP432P401R_ADC5
#define Board_ADC6                  MSP_EXP432P401R_ADC6
#define Board_ADC7                  MSP_EXP432P401R_ADC7
#define Board_ADC8                  MSP_EXP432P401R_ADC8

 

 

 

Now, in the adcsinglechannel.c file, the new ADC values can be used to send or received data from.  In this instance, I am using ADC 8 (A*) from the MSP432 Header to input the data from my microphone circuit, so I changed task1 to read from A8 vs A1. This is just raw data and is not formatted as will be case in the final product.

 

/*
 *  ======== taskFxn1 ========
 *  Open a ADC handle and get a array of sampling results after
 *  calling several conversions.
 */
Void taskFxn1(UArg arg0, UArg arg1)
{
    uint16_t     i;
    ADC_Handle   adc;
    ADC_Params   params;
    int_fast16_t res;


    ADC_Params_init(&params);
    adc = ADC_open(Board_ADC8, &params);


    if (adc == NULL) {
        System_abort("Error initializing ADC channel 8\n");
    }
    else {
        System_printf("ADC channel 8 initialized\n");
    }


    for (i = 0; i < ADC_SAMPLE_COUNT; i++) {
        res = ADC_convert(adc, &adcValue1[i]);


        if (res == ADC_STATUS_SUCCESS) {
            System_printf("ADC channel 8 convert result (%d): 0x%x\n", i,
                adcValue1[i]);
        }
        else {
            System_printf("ADC channel 8 convert failed (%d)\n", i);
        }


        System_flush();
    }


    ADC_close(adc);
}

 

 

When this is run, the output will look something like the following:

[CORTEX_M4_0] Starting the ADC Single Channel example
System provider is set to SysMin.  Halt the target to view any SysMin contents in ROV.
ADC channel 0 initialized
ADC channel 0 convert result: 0x219
ADC channel 8 initialized
ADC channel 8 convert result (0): 0x2431
ADC channel 8 convert result (1): 0x242f
ADC channel 8 convert result (2): 0x241b
ADC channel 8 convert result (3): 0x2423
ADC channel 8 convert result (4): 0x245e
ADC channel 8 convert result (5): 0x2432
ADC channel 8 convert result (6): 0x242c
ADC channel 8 convert result (7): 0x240b
ADC channel 8 convert result (8): 0x241e
ADC channel 8 convert result (9): 0x2441

 

 

Video showing the use of ADC8 (A8) on the MSP432 with TI-RTOS for my Hearing Guard System:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply
  • DAB
    DAB over 8 years ago

    Nice update and demo.

     

    Yes, sometimes the simple things are the hardest to do until you find the right sequence of code.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube