Improving pinMode

What could be included in further releases, or for the forum.
aster
Posts: 110
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

Improving pinMode

Post by 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 :)

racemaniac
Posts: 621
Joined: Sat Nov 07, 2015 9:09 am

Re: Improving pinMode

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

stevestrong
Posts: 1821
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Improving pinMode

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

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...
Last edited by stevestrong on Tue Apr 11, 2017 11:22 am, edited 2 times in total.

aster
Posts: 110
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

Re: Improving pinMode

Post by 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
Posts: 1821
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Improving pinMode

Post by 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
Posts: 110
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

Re: Improving pinMode

Post by aster » Tue Apr 11, 2017 10:33 am

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

edogaldo
Posts: 285
Joined: Fri Jun 03, 2016 8:19 am

Re: Improving pinMode

Post by edogaldo » Tue Apr 11, 2017 10:39 am

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..
Last edited by edogaldo on Tue Apr 11, 2017 10:49 am, edited 1 time in total.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Improving pinMode

Post by 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.
But it has, and is here: https://github.com/rogerclarkmelbourne/ ... e/io.h#L84

stevestrong
Posts: 1821
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Improving pinMode

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

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

edogaldo
Posts: 285
Joined: Fri Jun 03, 2016 8:19 am

Re: Improving pinMode

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

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

Post Reply