8 years, 8 months ago.

how to make a pin such as PTE4 always high?

how to make a pin such as PTE4 always high?

Question relating to:

2 Answers

8 years, 8 months ago.

You can control any digital pins to go high and/or low. But this will only happen when the program starts after reset. It is not possible to set a pin high on Mbed before the program runs.

snip

DigitalOut  mypin(PTE4);

int main()
{

mypin=1;

// pin PTE4 will remain 'high' until you change it, e.g. mypin=0;

while(true)

}

8 years, 8 months ago.

After a reset all pins behave as DigitalInputs and have a pull-up to high level. When you declare a pin as DigitalOut it will go to low level until you change the state. This may result in an undesired short pulse with logic low level. There is a new feature in the mbed lib to define the state of a newly declared pin.

DigitalOut mypin (PTE4, 1);

..

The pin will then stay high until you change it. This should avoid a spurious pulse after a reset.

That's handy Wim, I power low power LCD displays with Digital out pins, this new feature will improve stability at start up. I assume a '0' will set a low state?

posted by Paul Staron 26 Aug 2015

Using an IO pin to power anything more complicated than an LED is just asking for trouble.

Put a p-channel MOSFET in the power line to the LCD, and use the mbed to pull the gate pin to control the power. Depending on the voltages you may also need an n-channel MOSFET (the mbed controls the n-channel which then controls the p-channel part). That way you can use a couple of pull up/down resistors to set the default behavior and will get a far more reliable power connection to the LCD.

posted by Andy A 26 Aug 2015

Good idea Andy, been lucky so far but only a matter of time before troubles, just being lazy not adding the extra bits :)

posted by Paul Staron 26 Aug 2015