2017-09-12 11:24 PM
If I configure one GPIO pin to output. Is there a function in HAL to read back the current output status of it?
Solved! Go to Solution.
2024-04-23 01:36 PM
"it doesn't have any advantage over reading the ODR register."
Well, another two years... there are times when it's useful to know what was written to a pin, which might, indeed, be different than what is "visible" at the pin...this can be useful when you have something on a pin which can "return" a different state than what was written.
I used this on an IC to do confirmation of a function that was written, as part of self-test:
Write hi to external device
Wait xx μs for it to perform it's internal function
Read pin value - if it's now low, the device returns a "good" response
OTOH, you may want to know that you've set the pin high, even if it reads low, in a case where you might be driving something like a high-gain npn transistor, or a low Vgth FET with a pull-down resistor...edge cases, but...
2024-04-23 01:40 PM
embedded systems can sometimes be helped by knowing the true "schematic" of the I/O pins, to allow more intimate knowledge of the behaviour in "funny" applications, or for more effective self-test operations.
Just a thought, based on 46 years of embedded systems and IC development (about 2 billion ICs served ;) )
2024-04-23 01:48 PM
Yep, just so that a HAL may only provide the "streamlined" version, the 99.9% use cases, but it's nice to have something written that clarifies exactly what is, or is not, explicitly provided, since some of us old "bare metal" fools sometimes use abstruse methods ; -).