PORTC_PCR3 unable to configure as GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PORTC_PCR3 unable to configure as GPIO

Jump to solution
707 Views
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 Kudos
1 Solution
602 Views
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

View solution in original post

0 Kudos
1 Reply
603 Views
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 Kudos