MCXA153 Hard Fault on GPIO_PinInit

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

MCXA153 Hard Fault on GPIO_PinInit

跳至解决方案
226 次查看
aberger
Contributor V

I'm trying to initialize a pin on the FRDM-MXCA153 as GPIO Output, but the GPIO_PinWrite throws a HardFault. 

Here is code execution, paused at the write to the PSOR register for GPIO3. 

GPIO_PinWrite().png

The Hard Fault occurs immediately upon execution of the base->PSOR write.

HardFault_Handler().png

You can also see in the call stack <signal handler called>() at 0xffffffb8. 

There is no custom code here, just a call to the library code from fsl_gpio. I am using SDK_2.16.000 for the MXCA153.

Minimum example project is also attached.

标签 (1)
0 项奖励
回复
1 解答
119 次查看
XuZhang
NXP Employee
NXP Employee

hi,aberger

If pin P3_12 is used, kCLOCK_GatePORT3 should be enabled. If pin P3_12 is used as a common GPIO pin, kCLOCK_GateGPIO3 should be enabled.
When the GPIO pin is initialized in the Config Tools tool, the code will be updated to enable kCLOCK_GateGPIO3.

XuZhang_0-1721813608540.png

XuZhang_1-1721813727485.png

I hope this can help you. If you have any other questions, contact me again. 

BR

Xu Zhang

在原帖中查看解决方案

0 项奖励
回复
4 回复数
107 次查看
aberger
Contributor V

Thanks. It seems that routing a pin as GPIO (i.e. clicking the checkbox for the pin in the GPIO list in the "Peripheral Signals" tab), but leaving the Direction as "Not Specified" is not sufficient to generate the CLOCK_EnableClock(kCLOCK_GateGPIO3) call in pin_mux.c. The Direction must be specified too.

0 项奖励
回复
191 次查看
XuZhang
NXP Employee
NXP Employee

hi,aberger

Thank you for your interest in NXP products and opportunity to serve you,I will gladly help you with this.

The clock has not been enabled in your code. After adding CLOCK_EnableClock(kCLOCK_GateGPIO3) to your demo, the error was successfully resolved.

XuZhang_0-1721358750667.png

 

I hope this can help you. If you have any other questions, contact me again. The fixed code is also attached.

BR

Xu Zhang

 

0 项奖励
回复
155 次查看
aberger
Contributor V

Hi @XuZhang ,

Thank you for the response. Can you explain the difference between kCLOCK_GatePORT3 and kCLOCK_GateGPIO3?

You can see the the clock for PORT3 is enabled in my project inside BOARD_InitBootPins() (and this is auto-generated by Config Tools in the pin_mux.c file when I selected GPIO3, pin 12 to be routed). Why did Config Tools not enable the clock for GPIO3? 

0 项奖励
回复
120 次查看
XuZhang
NXP Employee
NXP Employee

hi,aberger

If pin P3_12 is used, kCLOCK_GatePORT3 should be enabled. If pin P3_12 is used as a common GPIO pin, kCLOCK_GateGPIO3 should be enabled.
When the GPIO pin is initialized in the Config Tools tool, the code will be updated to enable kCLOCK_GateGPIO3.

XuZhang_0-1721813608540.png

XuZhang_1-1721813727485.png

I hope this can help you. If you have any other questions, contact me again. 

BR

Xu Zhang

0 项奖励
回复