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.

basic GPIO

Other Parts Discussed in Thread: MSP430AFE253

I'm using an MSP430AFE253 and the only thing I want to do is set P1.0 and P1.1 to 1 (high logic level) at the start of my code. At some point in the code, I want to be able to set them low for x clock cycles and then set them high again.

Do I do:

P1SEL = BIT0 + BIT1;

P1DIR = 0x0x1;

P1OUT = BIT1;

to set the pins high? Because then how do I set only P1.0 high and not P1.1...

  • Lawrence,

     

    Please take a look at our code examples for that device:

    http://www.ti.com/litv/zip/slac487

     

    To set the GPIO high do something like:

     

    P1DIR = BIT0 + BIT1;

    P1OUT = BIT0 + BIT1;

     

    To just have P1.0 high do :

    P1OUT = BIT0;

  • P1SEL will select special functions of that pin, so using that you can switch from the GPIO function to say a timer output or an analog input for the ADC.

    If you want to switch a single port without affecting the others use:

    P1OUT |= BITx;

    To reset it:

    P1OUT &= ~(BITx);

    Each of the BITx is only affecting the x-th bit in a byte/word and no other.

    Just as information, the BITx are simply defines to values where only a single bit is set like 0x01, 0x02, 0x04, 0x08, 0x10 and so on.

  • You should set:

    P1SEL = ~(BIT0 + BIT1);

    in order to assign bits 0 and 1 of PORT1 to GPIO function, and it's the default after POR (so no need to change it, if you didn't change it before).

    Regards.

    Peppe

**Attention** This is a public forum