input pullups - ARM processor, STM32f0..

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Harvolt
Posts: 5
http://meble-kuchenne.info.pl
Joined: Tue Feb 14, 2023 5:07 pm
Has thanked: 2 times
Been thanked: 2 times

input pullups - ARM processor, STM32f0..

Post 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? :?:

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: input pullups - ARM processor, STM32f0..

Post 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).

Harvolt
Posts: 5
Joined: Tue Feb 14, 2023 5:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: input pullups - ARM processor, STM32f0..

Post 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.

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: input pullups - ARM processor, STM32f0..

Post by BenR »

Hello,

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

LeighM
Valued Contributor
Posts: 401
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 70 times
Been thanked: 217 times

Re: input pullups - ARM processor, STM32f0..

Post 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.

Harvolt
Posts: 5
Joined: Tue Feb 14, 2023 5:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: input pullups - ARM processor, STM32f0..

Post by Harvolt »

hi Ben, Steve, Leigh,
thanks for getting back - got a chance now to give this a go..

Post Reply