Cant set a pull-up in a GPIO

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Cant set a pull-up in a GPIO

ソリューションへジャンプ
3,594件の閲覧回数
jose_au_zone
Contributor II

Hello! I'm trying to set a GPIO with a pull-up resistor, but I am always reading zero from the pin, no matter the input value

I'm configuring it like this:

 

	gpio_pin_config_t config;

	config.direction = kGPIO_DigitalInput;
	config.interruptMode = kGPIO_NoIntmode;

	GPIO_PinInit(GPIO2, 9U, &config);

	IOMUXC_SetPinMux(IOMUXC_GPIO_B0_09_GPIO2_IO09, 0U);

	IOMUXC_SetPinConfig(IOMUXC_GPIO_B0_09_GPIO2_IO09, 0x90B0U);

I've got the value 0x90B0 from the code generated by the pin config tool
If you look at page 693 of the reference manual, that should set a 100kohm pull-up
I've tried with 22kohm and 47k as well to no avail.
Is there anything I'm missing here?
This pin is connected to a switch that when pressed shorts the pin to the ground, so when the switch is not pressed it should read 1, right? But I'm always reading zero

Any help will be greatly appreciated

0 件の賞賛
返信
1 解決策
3,580件の閲覧回数
mjbcswitzerland
Specialist V

Hi

0x90b0 enables the keeper function.
0xb0b0 enables 100k pull-up.

 

Reference:
In the uTasker project the complete GPIO initialisation is done with one line:
_CONFIG_PORT_INPUT(2, PIN_GPIO_B0_09_GPIO2_IO09, (PORT_100k_PULLUP | PORT_SPEED_100MHz));

which removes the risk of such errors when using hex values rather than meaningful defines.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements

For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: https://www.utasker.com/iMX/RT1064.html

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
3,569件の閲覧回数
jose_au_zone
Contributor II

Thank you so much, that worked!
So, for the pull up to work, both the PKE and the PUE fields need to be enabled?
I get why the PUE field is necessary, but why the PKE?
According to this doc: https://www.nxp.com/docs/en/application-note/AN5078.pdf
The PKE is used to maintain the value just when the driver is disabled. What does "driver" mean exactly in this context? Isn't a GPIO set as an input with a pull-up an "enabled driver"?

Thank you so much!

0 件の賞賛
返信
3,556件の閲覧回数
mjbcswitzerland
Specialist V

Hi Jose

You need to read the description of the two bits more carefully - the descriptions are accurate, but not always that understandable.

A truth table makes is clearer:

                      Neither enabled  keeper enabled  pull-up/down enabled
IOMUXC_SW_PAD_CTL_PAD_PKE     0               1              1
IOMUXC_SW_PAD_CTL_PAD_PUE     x               0              1

Therefore PKE is always set if any of the two are needed.

Regards

Mark

0 件の賞賛
返信
3,581件の閲覧回数
mjbcswitzerland
Specialist V

Hi

0x90b0 enables the keeper function.
0xb0b0 enables 100k pull-up.

 

Reference:
In the uTasker project the complete GPIO initialisation is done with one line:
_CONFIG_PORT_INPUT(2, PIN_GPIO_B0_09_GPIO2_IO09, (PORT_100k_PULLUP | PORT_SPEED_100MHz));

which removes the risk of such errors when using hex values rather than meaningful defines.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements

For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: https://www.utasker.com/iMX/RT1064.html

0 件の賞賛
返信