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.

MSPM0L1105: How to control GPIO and read its value

Part Number: MSPM0L1105
Other Parts Discussed in Thread: SYSCONFIG

Dear Ti team,

How to control GPIO by API? 

What I think is  

DL_GPIO_setPins(GPIO_PWR_PORT, GPIO_PWR_P2_PWR_OFF_PIN)  is set to 1

DL_GPIO_clearPins(GPIO_PWR_PORT, GPIO_PWR_P2_PWR_OFF_PIN)  is set to 0

I use DL_GPIO_readPins(GPIO_PWR_PORT, GPIO_PWR_P2_PWR_OFF_PIN) to check values after sending above command.

But I can't see its values changed no matter how I use set or clear commands.

Please tell me how to control GPIO and read its value correctly.

Thanks!

  • Hi Jonas,

    Your API looks good. But I will recommend you to refer to the example code directly.

    Could you measure the IO level directly?

    I guess you did not enable the input feature.

  • Hi Yuhao,

    From example gpio_software_poll, Set and Clear only apply on Direction Output GPIO (LED), and Read only apply on Direction Input GPIO (SWITCH).

    What I want is if there is a way to get my Direction Output GPIO status? 

    It looks like readPins API can only work on Direction Input GPIO.

    IO level looks do change when I use setPins and clearPins API, I just want to monitor its current status after running.

    How to do it ?

    Thanks!

  • You can try to enable the INENA to enable the input while you are using output function. 

     

  • Hi Yuhao,

    Sorry, I don't know what you mean. How to enable the INENA you said? in syscfg file?

    Thanks

  • Here is one question first:

    If you output high and the pin is connected to GND directly, then this will cause a short circuit and may directly damage the MCU.

    If you use a resistor to pull down instead, then the pin should still be high because the voltage drop across the resistor.

    So there is no need to read a output pin, right? It should be the level you set, or the MCU has been shorted.

  • Hi,

    The enablement of INENA could not be configured by sysconfig directly. You could configure a pin as output firstly and then add the program language below in main() function:

    IOMUX->SECCFG.PINCM[GPIO_LEDS_PIN_TEST_IOMUX] |= IOMUX_PINCM_INENA_ENABLE;

    where "GPIO_LEDS_PIN_TEST_IOMUX" is the iomux pin name you configured as output in sysconfig, and it may be found in "ti_msp_dl_config.h" file. 

    After that, the IO state could be read by "DL_GPIO_readPins()" function.