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.
The Hard Fault occurs immediately upon execution of the base->PSOR write.
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.
已解决! 转到解答。
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.
I hope this can help you. If you have any other questions, contact me again.
BR
Xu Zhang
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.
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.
I hope this can help you. If you have any other questions, contact me again. The fixed code is also attached.
BR
Xu Zhang
Hi @Joey_z ,
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?
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.
I hope this can help you. If you have any other questions, contact me again.
BR
Xu Zhang