Page 1 of 2

Improving pinMode

Posted: Tue Apr 11, 2017 8:38 am
by aster
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 :)

Re: Improving pinMode

Posted: Tue Apr 11, 2017 8:50 am
by racemaniac
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 :)
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?

Re: Improving pinMode

Posted: Tue Apr 11, 2017 8:57 am
by stevestrong
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:

Code: Select all

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
Regarding the IO speed, there is no reason to set the pins to lower speed, default is max 50MHz.
In general, one want to squeeze out the maximum from the device...

Re: Improving pinMode

Posted: Tue Apr 11, 2017 9:08 am
by aster
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)

Re: Improving pinMode

Posted: Tue Apr 11, 2017 9:55 am
by stevestrong
OK, I have to reformulate: The F103 does not have any INPUT_PULLDOWN mode.
The wiki should be corrected as well.

Re: Improving pinMode

Posted: Tue Apr 11, 2017 10:33 am
by aster
Mmm what about adding it? In this way the wiki will be correct :roll:

Re: Improving pinMode

Posted: Tue Apr 11, 2017 10:39 am
by edogaldo
aster wrote:Mmm what about adding it? In this way the wiki will be correct :roll:
You should propose it to STM as it them that produce the chip.. ;)
Sorry, double checking the RM, it's possible, I need to better study GPIOs..

Re: Improving pinMode

Posted: Tue Apr 11, 2017 10:43 am
by danieleff
stevestrong wrote:OK, I have to reformulate: The F103 does not have any INPUT_PULLDOWN mode.
The wiki should be corrected as well.
But it has, and is here: https://github.com/rogerclarkmelbourne/ ... e/io.h#L84

Re: Improving pinMode

Posted: Tue Apr 11, 2017 11:21 am
by stevestrong
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:

Code: Select all

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

Re: Improving pinMode

Posted: Tue Apr 11, 2017 11:52 am
by edogaldo
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:

Code: Select all

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
RM0008, table 20 @ page 160: it has and seems correctly configured in the core.. ;)