Uart Hard fault while initialization

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

Uart Hard fault while initialization

Jump to solution
1,271 Views
Ahmed_Mohsen_Shoheb
Contributor I

Hello, I having a "hard fault" when trying to initialize LPUART1 in Cortex-M4 S32K144 EVB. 

the situation is:

1- I enable the peripheral clock ( this is by setting CGC bit in PCC_LPUART1 register).

I'm giving the peripheral directly from SOSC clock, which is 16MHz.

 

2- inside my startup code, CSTartup, I have:

A- defined "CSTS32K_coUSE_LPUART1_RxTx_ERR_IRQHandler" which is the interrupt that is gonna fire when Uart interrupt happens. Moreover, priority is defined using macro "CSTS32K_u8LPUART1_RxTx_ERR_PRIORITY" (has the value of 7).

B- inside the "CSTS32K_vidLPUART1_RxTx_ERR_IRQHandler" handler "LPUA

RT1_Handler();" is added to execute LPUART1 code when Uart interrupt fires.

 

Issue: Once I try to access CTRL register of LPUART1, "CSTS32K_vidHardFault_Handler" is fired.

 

Notes: I have looked into similar issue posted on the community, it's solution was to add "-mcpu=cortex-m4
-mthumb" into my linker options. However, I found out that these options are already added, so I guess that's not the problem.

0 Kudos
1 Solution
1,231 Views
Ahmed_Mohsen_Shoheb
Contributor I

Fortunately I have solved the issue I was facing.

I discovered that I was indexing a wrong address of the LPUART1, that was causing the hard-fault. So I guess I won't need further assistance, at least for now :D.

Thanks again.

View solution in original post

0 Kudos
1 Reply
1,232 Views
Ahmed_Mohsen_Shoheb
Contributor I

Fortunately I have solved the issue I was facing.

I discovered that I was indexing a wrong address of the LPUART1, that was causing the hard-fault. So I guess I won't need further assistance, at least for now :D.

Thanks again.

0 Kudos