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.

MSP432P401R CODING LOGIC FOR GPIO



Hello,

I am writing an embedded C code for MSP432P401R. If i want to check the "set" condition for  the GPIO pin i write this logic "if (P1IN & BIT1)"..

What should be the logic for checking the "reset" condition on GPIO pin?

Please help me out..

Thanks 

  • Hi Nafeesa,

    "Set" and "Reset" may not be the right words for that, but you already placed them in quotation marks yourself. By writing

    if( P1IN & BIT1 )
    {
      // Do something when input pin is high
    }

    you can perform an action when the voltage level on the input pin causes it to be high.

    For the opposite case you simply write

    if( !(P1IN & BIT1) )
    {
      // Do something when input pin is low
    }

    This checks if the pin is not high.

    Dennis

**Attention** This is a public forum