This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR4133: Using the ADC on the EVM board

Part Number: MSP430FR4133
Other Parts Discussed in Thread: DRV5055

I am attempting to use the ADC on the MSP430FR4133 to display read results from the DRV5055 Linear hall effect sensor. I am running into an issue I think with initialization of the ADC, when setting up the ADC pin to read from. The pin I thought I initialized for the ADC to read from is always outputting 3 volts instead of being pulled to the voltage output of the hall effect sensor. Is there something I'm doing wrong in the setup that would cause this? I am using example code I found on Resource Explorer ADC Concepts from MSP Academy for set up.

  • Hi Carter,

    Have you modified the code at all? If so would you mind sharing it? 

    Also, just to clarify, the example code you are starting from is msp430fr413x_adc10_02.c? 

    Best Regards,
    Brandon Fisher

  • Yes I am starting from that code. I've used the code directly without modifying it and I have tried modifying it to use one of the other ADC ports, in which case they always output 0 volts.

  • Thanks Carter,

    If you remove the Launchpad and measure the output of the hall sensor with a DMM or oscilloscope what voltage are you seeing? 

    If you are able to feed a known voltage from say a bench supply into the ADC that is a good test as well. 

    Best Regards,
    Brandon Fisher

  • On the scope without the launchpad attached I see 1.65 volts, but it jumps to 3 volts if I connect pin 1.1 to try and read it, and 0 volts if I try to connect pin 1.4 to read. Both ways when I try to read I followed the example to set up the ADC pins.

  • A1 (P1.1) is connected to the backchannel UART [Ref Launchpad UG Figs 16/19]. Try removing the TX/RX jumpers from the "bridge" header (J101).

  • Thank Bruce. That handled the issue of the pins pulling high and low. I think I am still not setting up the adc correctly however, because the reading doesn't change no matter what voltage I try to read

  • Carter,

    How are you checking the ADC Reading? Are you just checking the ADC_Result value in the watch window in CCS? 

    Best Regards,
    Brandon Fisher

  • I am checking on watch window and I have it being shown on the LCD screen on the EVM. The ADC_Result value in the watch window only varies from about 80 to 170 with it reading 80 at zero volts and 170 at 3.3 volts, which doesn't show hardly any change when I try to display the voltage on the LCD.

  • What source code are you using now? (I don't see any Examples which show ADC readings on the LCD.)

    Also, what are you using as a voltage source? I'm particularly interested in the source impedance -- a benchtop supply or battery will work fine, but with e.g. a potentiometer (resistor divider) it's very easy to end up with a very high source impedance, which will give you "mushy" readings. As a quick experiment, try setting ADCSHT to something very large, and see if anything changes..

  • I just ran this code on my MSP430FR4133 launchpad and it functioned just as you are expecting. When you are using just that example code, viewing the ADC_Result value while running the debugger should give you good results unless something is wrong on the hardware side. 

    I like Bruce's suggestion here of upping your sample and hold time to see if this is impedance related.

    Also, If you are working exclusively off of this code where you print out to the LCD, would you mind dropping your code into a post? It is possible that something seemingly unrelated may be the cause of your issue. There is a code formatting tool under the "Insert" menu when posting that will preserve readability. 

    Best Regards,
    Brandon Fisher

  •     // Set all GPIO pins to output low to prevent floating input and reduce power consumption
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0|GPIO_PIN2|GPIO_PIN3|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P5, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P6, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P7, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P8, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
    
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0|GPIO_PIN2|GPIO_PIN3|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P3, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P6, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P7, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P8, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
    
        //GPIO_setAsInputPin(GPIO_PORT_P1, GPIO_PIN1);
    
        // Configure button S1 (P1.2) interrupt
        GPIO_selectInterruptEdge(GPIO_PORT_P1, GPIO_PIN2, GPIO_HIGH_TO_LOW_TRANSITION);
        GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN2);
        GPIO_clearInterrupt(GPIO_PORT_P1, GPIO_PIN2);
        GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN2);
    
        // Set P4.1 and P4.2 as Secondary Module Function Input, LFXT.
        GPIO_setAsPeripheralModuleFunctionInputPin(
               GPIO_PORT_P4,
               GPIO_PIN1 + GPIO_PIN2,
               GPIO_PRIMARY_MODULE_FUNCTION
               );
    
        // I2C pins
            P5SEL0 |= BIT2 | BIT3;
    

        // L0~L26 & L36~L39 pins selected
        LCD_E_setPinAsLCDFunctionEx(LCD_E_BASE, LCD_E_SEGMENT_LINE_0, LCD_E_SEGMENT_LINE_26);
        LCD_E_setPinAsLCDFunctionEx(LCD_E_BASE, LCD_E_SEGMENT_LINE_36, LCD_E_SEGMENT_LINE_39);
    
        LCD_E_initParam initParams = LCD_E_INIT_PARAM;
        initParams.clockDivider = LCD_E_CLOCKDIVIDER_3;
        initParams.muxRate = LCD_E_4_MUX;
        initParams.segments = LCD_E_SEGMENTS_ENABLED;
    
        // Init LCD as 4-mux mode
        LCD_E_init(LCD_E_BASE, &initParams);
    
        // LCD Operation - Mode 3, internal 3.02v, charge pump 256Hz
        LCD_E_setVLCDSource(LCD_E_BASE, LCD_E_INTERNAL_REFERENCE_VOLTAGE, LCD_E_EXTERNAL_SUPPLY_VOLTAGE);
        LCD_E_setVLCDVoltage(LCD_E_BASE, LCD_E_REFERENCE_VOLTAGE_2_96V);
    
        LCD_E_enableChargePump(LCD_E_BASE);
        LCD_E_setChargePumpFreq(LCD_E_BASE, LCD_E_CHARGEPUMP_FREQ_16);
    
        // Clear LCD memory
        LCD_E_clearAllMemory(LCD_E_BASE);
    
        // Configure COMs and SEGs
        // L0 = COM0, L1 = COM1, L2 = COM2, L3 = COM3
        LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_0, LCD_E_MEMORY_COM0);
        LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_1, LCD_E_MEMORY_COM1);
        LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_2, LCD_E_MEMORY_COM2);
        LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_3, LCD_E_MEMORY_COM3);
    
        // Select to display main LCD memory
        LCD_E_selectDisplayMemory(LCD_E_BASE, LCD_E_DISPLAYSOURCE_MEMORY);
    
        // Turn on LCD
        LCD_E_on(LCD_E_BASE);

    This first section of code is what I have in my Init_GPIO function, and the second is from my Init_LCD function. I got both of these from the out of the box demo code for the msp430fr4133. It does actually work when I run just the example code, so something in the setup of these might be the issue.

  • Hi Carter,

    So you are using Driverlib for the LCD and GPIO initialization. Is there any particular reason you wouldn't also use the Driverlib ADC example?

    https://dev.ti.com/tirex/explore/node?devices=MSP430FR4133&devtools=MSP430FR4133&node=A__AHkyNcx8Ouivc4pnjcEQMA__msp430ware__IOGqZri__LATEST

    You can use DriverLib and register based code together, but using just one or the other is better practice. It could also simplify your code. 


    Best Regards,
    Brandon Fisher

  • I had tried the driverLib code prior to fixing the issue of the pins pulling high and low. I didn't think to test it again after that issue was solved. I used that code and now I am able to get the correct results. Thank you so much!

**Attention** This is a public forum