MCXA153 Hard Fault on GPIO_PinInit

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

MCXA153 Hard Fault on GPIO_PinInit

Jump to solution
225 Views
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.

Labels (1)
0 Kudos
Reply
1 Solution
117 Views
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

View solution in original post

0 Kudos
Reply
4 Replies
106 Views
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 Kudos
Reply
189 Views
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 Kudos
Reply
153 Views
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 Kudos
Reply
118 Views
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 Kudos
Reply