Page 1 of 1

input pullups - ARM processor, STM32f0..

Posted: Sat Feb 18, 2023 9:03 am
by Harvolt
hi all,
is there a convenient way, either graphically or C code to implement a pull up on a digtial input for STM32f0 processors? :?:

Re: input pullups - ARM processor, STM32f0..

Posted: Sun Feb 19, 2023 10:12 am
by Steve-Matrix
I am not familiar with that range of devices, but looking at the datasheet there is a register that controls the internal weak pull-ups and pull-downs for the I/O ports (GPIOx_PUPDR).

Re: input pullups - ARM processor, STM32f0..

Posted: Mon Feb 20, 2023 10:07 am
by Harvolt
so will the flowcode IDE support a discrete C code write to this register via a Code Command icon? will the compiler understand or recognise that register name?

Could you provide an example of how this would be done? - i purchased the FLOWCODE ARM version for training only,i was hoping this would be straighforward, before i consider purchasing a professional license.

Re: input pullups - ARM processor, STM32f0..

Posted: Mon Feb 20, 2023 12:47 pm
by BenR
Hello,

This reply on our old forum might be useful for you.
https://www.matrixtsl.com/mmforums/view ... 272#p92272

Re: input pullups - ARM processor, STM32f0..

Posted: Tue Feb 21, 2023 1:33 pm
by LeighM
To simplify the C code, add these definitions into the Project Options -> Supplementary Code -> Definitions

Code: Select all

#define PULL_UP(port, pin) GPIO##port->PUPDR |= (1 << (pin *2))
#define PULL_DOWN(port, pin) GPIO##port->PUPDR |= (2 << (pin *2))
Then, as an example, to turn on pullup to port B pin 8, add this into a C icon

Code: Select all

PULL_UP(B, 8);
nb. You will still need to use C code to read the pin, as mentioned in the post linked by Ben.
Hope that helps.

Re: input pullups - ARM processor, STM32f0..

Posted: Tue Feb 21, 2023 3:21 pm
by Harvolt
hi Ben, Steve, Leigh,
thanks for getting back - got a chance now to give this a go..