PORTC_PCR3 unable to configure as GPIO

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PORTC_PCR3 unable to configure as GPIO

跳至解决方案
1,376 次查看
srikanth_vemula
Contributor II

Hi,

I'm using MK22FX512AVLH12 Micro-Controller.

I'm trying to configure PORTC-pin3 as a GPIO, in the same way, which I followed for other pins. But the register write (PORTC_PCR3) is not happening. The debug mode screenshot of the same is attached herewith.

Please let me know, if any other things to be disabled/enabled. 

Regards,

Srikanth

0 项奖励
回复
1 解答
1,271 次查看
mjbcswitzerland
Specialist V

Hi Srikanth

I think that you are making a mistake with "|=". Use "=" instead.
"|=" assumes that the register's fields of interest are initially 0, which is not always true. If PORTC_PCR3 defaults to ALT function 4 your code would turn it into ALT function 5, which is not the intention and thus a programing error.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,272 次查看
mjbcswitzerland
Specialist V

Hi Srikanth

I think that you are making a mistake with "|=". Use "=" instead.
"|=" assumes that the register's fields of interest are initially 0, which is not always true. If PORTC_PCR3 defaults to ALT function 4 your code would turn it into ALT function 5, which is not the intention and thus a programing error.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 项奖励
回复