Spark Logic

Improving pinMode

aster Tue Apr 11, 2017 8:38 am

Hello,

Maybe i missed something (i am new here) but am i wrong or i can t use some of the nice features of the stm32 like the pulldown input?

I would like to add this: pinMode(pin, INPUT_PULLDOWN)

Another function i would like to add is to choose the speed of gpio for example pinMode(pin, OUTPUT, LOWSPEED)

Maybe more experienced people than me tried and it is not simple,so i thought to write here before trying it
Tell me and i will try then i post the code here :)

Replies

racemaniac Tue Apr 11, 2017 8:50 am

aster wrote:Hello,

Maybe i missed something (i am new here) but am i wrong or i can t use some of the nice features of the stm32 like the pulldown input?

I would like to add this: pinMode(pin, INPUT_PULLDOWN)

Another function i would like to add is to choose the speed of gpio for example pinMode(pin, OUTPUT, LOWSPEED)

Maybe more experienced people than me tried and it is not simple,so i thought to write here before trying it
Tell me and i will try then i post the code here :)

stevestrong Tue Apr 11, 2017 8:57 am

You cannot activate only the built-in pull-down resistor separately from the pull-up resistor.
See available modes in RM0008 chapters 9.2.1, 9.2.2:
CNFy[1:0]: Port x configuration bits (y= 0 .. 7)
These bits are written by software to configure the corresponding I/O port.
Refer to Table 20: Port bit configuration table.
In input mode (MODE[1:0]=00):
00: Analog mode
01: Floating input (reset state)
10: Input with pull-up / pull-down
11: Reserved

aster Tue Apr 11, 2017 9:08 am

INPUT_PULLDOWN should already work
http://wiki.stm32duino.com/index.php?ti … #Pin_Modes

and about the speed, what would be the advantage in being able to define that? atm it defaults to the highest speed i think, is there any reason we would want it differently?

I tried it yesterday and it didn t worked, for sure i wrote it wrong :cry:

Yep about the speed it is not so usefull except for power saving application (not my case)

stevestrong Tue Apr 11, 2017 9:55 am

OK, I have to reformulate: The F103 does not have any INPUT_PULLDOWN mode.
The wiki should be corrected as well.

aster Tue Apr 11, 2017 10:33 am

Mmm what about adding it? In this way the wiki will be correct :roll:

edogaldo Tue Apr 11, 2017 10:39 am

aster wrote:Mmm what about adding it? In this way the wiki will be correct :roll:

danieleff Tue Apr 11, 2017 10:43 am

stevestrong wrote:OK, I have to reformulate: The F103 does not have any INPUT_PULLDOWN mode.
The wiki should be corrected as well.

stevestrong Tue Apr 11, 2017 11:21 am

Maybe the software has it but the hardware definitely not:
stevestrong wrote:You cannot activate only the built-in pull-down resistor separately from the pull-up resistor.
See available modes in RM0008 chapters 9.2.1, 9.2.2:
CNFy[1:0]: Port x configuration bits (y= 0 .. 7)
These bits are written by software to configure the corresponding I/O port.
Refer to Table 20: Port bit configuration table.
In input mode (MODE[1:0]=00):
00: Analog mode
01: Floating input (reset state)
10: Input with pull-up / pull-down
11: Reserved

edogaldo Tue Apr 11, 2017 11:52 am

stevestrong wrote:Maybe the software has it but the hardware definitely not:
stevestrong wrote:You cannot activate only the built-in pull-down resistor separately from the pull-up resistor.
See available modes in RM0008 chapters 9.2.1, 9.2.2:
CNFy[1:0]: Port x configuration bits (y= 0 .. 7)
These bits are written by software to configure the corresponding I/O port.
Refer to Table 20: Port bit configuration table.
In input mode (MODE[1:0]=00):
00: Analog mode
01: Floating input (reset state)
10: Input with pull-up / pull-down
11: Reserved

stevestrong Tue Apr 11, 2017 12:01 pm

Thanks @edogaldo, it seems that your right, it’s never too late to learn something new ;)
Just that I have never seen an example where this is used.
Has anyone tried this out?
Is this working also in combination with GPIOx_BSRR register values?

edogaldo Tue Apr 11, 2017 12:05 pm

stevestrong wrote:Thanks @edogaldo, it seems that your right, it’s never too late to learn something new ;)
Just that I have never seen an example where this is used.
Has anyone tried this out?
Is this working also in combination with GPIOx_BSRR register values?

aster Tue Apr 11, 2017 7:35 pm

edogaldo wrote:aster wrote:Mmm what about adding it? In this way the wiki will be correct :roll:

Sign in to reply