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.

Port in Open Drain

 Hi, I must receive a data from a temperature sensor and for do this I must set the port 4.7 in open drain mode.how I can put the port in open drain mode??

  • Can you post what msp chip version do you use?

    Regards,
    Piotr Romaniuk, Ph.D.
    ELESOFTROM

  • Should be quite simple.  I assume open collector with a pull up.

    basic init: PxSEL.y = 0; PxREN.y = 1;

    set output to zero: PxDIR.y = 1; PxOUT.y = 0;

    set to open drain with internal pullup: PxOUT.y = 1; PxDIR.y = 0;

    Hardy

  • Usually, open drain does mean NO internal pullup. However:

    init:
    PxSEL&=~BITx;
    PxREN|=BITx; or  PxREN&=~BITx; (with/without pullup)
    PxOUT&=~BITx;

    output low:
    PxDIR |= BITx;

    output high:
    PxDIR &= ~BITx;

    The content of PxOUT is kept even if you switch from input to output and does not affect the mechanics when dir is input.

  • Usually open drain means, that one needs a pullup somewhere.  If there is no external pullup, then the internal one might be of good use.

  • HardyGriech said:
    Usually open drain means, that one needs a pullup somewhere.

    Yes. Depending on the purpose, it should be central, controlled by one peer on tthe bus or each has its own internal pullup.

    The usual case is one external pullup, as then the peers do not need to sink more and more current the more peers are on the bus. (think of an I2C bus with 127 slaves, each of them ahs its pullup on. Whew, you'll need really strong outputs to sink that to GND.

    HardyGriech said:
    If there is no external pullup, then the internal one might be of good use.

    Yes. Yet it is dangerous to 'just do it' without considering the pitfalls.

**Attention** This is a public forum