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.

MSPM0L1228: Is it possible to use the GPIO API to read and write the RX and TX pins of the UART?

Part Number: MSPM0L1228

Tool/software:

Hi,

I need to detect when the RX pin goes low within 100ms or set the TX pin high for about 50ms.

Can I use the GPIO API (DL_GPIO_readPins, DL_GPIO_setPins) to read or write the RX, TX pins of the UART?

If not possible, is there any way to apply the above two requirements?

Best Regards!

  • The GPIO function is a separate Peripheral Function (PF=1), so in general you can't read the pin state if it's connected to a different peripheral.

    It is possible to temporarily switch the pin to GPIO function with something like "DL_GPIO_initPeripheralInputFunction(<pincm>, 1);" Where "1" refers to PF=1 (GPIO) and <pincm> appears in ti_msp_dl_config.h as <something>_PINMUX. I have seen glitches (as seen by the peripheral) when doing this, but I haven't tried it with the UART.

    I expect a 100ms low on Rx would be detected as a Break (maybe multiple Breaks), so you can try monitoring for BRKERR. 

    I'm not quite sure what you're looking for in the Tx, since you're the one controlling that.

  • Hi Sho,

    As Bruce mentions, you will need to reassign the pin function to GPIO before using those function calls, but generally yes you can switch the pin function from UART to GPIO, then read or set the pin using the functions you mention. Then to time those functions correctly you'll probably want to utilize a timer peripheral as well. Once the GPIO functionality has completed you can switch back to the UART pin function.

    Agreed that 100ms would likely be detected as a break so I'd encourage you to try enabling the break error interrupt for the Rx condition detection, and then for Tx you'll need to switch pin functions.

  • Hi 

    Thanks for your reply soon. I'll consider using BRKERR before switching pin.

    Best regards!