Hello... I need to toggle some of the FRDM-K64F GPIO pins. One of those pins is in the PTA port, the PTA2 pin, but I can't set it to logic '1', it's always at 0V and I need to set it to it's logic '1' state of 3.3V. I have tried a baremetal code, I can set other pins except this one. The pins is shared with the JTAG_TDO and I think that's the reason. Can I get this pin to work as GPIO??
Thanks
Here's my initialization code:
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK; //Enable clock
PORTA_PCR2 |= PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Chose alt1 as gpio pin and enable drive strenght
GPIOA_PDDR |= (1<<2); //Set the pin as output
GPIOA_PSOR |= (1<<2); //To set the pin at logic '1' but doesn't work :smileysad:
解決済! 解決策の投稿を見る。
Hi
Change the line
PORTA_PCR2 |= PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Chose alt1 as gpio pin and enable drive strenght
to
PORTA_PCR2 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Chose alt1 as gpio pin and enable drive strenght
and it will work.
In the uTasker project you would simply do
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, (PORTA_BIT2), (PORTA_BIT2), (PORT_DSE_HIGH)); // configure and drive '1' on PTA2
and nothing can go wrong.
Regards
Mark
Hi Alejandro,
Mark is right.
The PORTA_PCR2[MUX]=0x07 as default. So you need PORTA_PCR2 = PORT_PCR_MUX(1) instead of PORTA_PCR2 |= PORT_PCR_MUX(1).
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks Robin, you're right!!
Regards
Hi
Change the line
PORTA_PCR2 |= PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Chose alt1 as gpio pin and enable drive strenght
to
PORTA_PCR2 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Chose alt1 as gpio pin and enable drive strenght
and it will work.
In the uTasker project you would simply do
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, (PORTA_BIT2), (PORTA_BIT2), (PORT_DSE_HIGH)); // configure and drive '1' on PTA2
and nothing can go wrong.
Regards
Mark
Thanks Mark, it works!!
I don't know the uTasker tool, can you please give me more information about it or where I can find it? Thanks
Regards
Hi Alejandro
Link at end of previous post.
Regards
Mark