K22 forced hard fault while configuring uart0

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

K22 forced hard fault while configuring uart0

1,653 Views
mikhailburakov
Contributor III

Hello dear community!

Our HW guys decided to switch from K20 to K22. I started to adopt my code to this new MCU, but stuck right at the beginning. I get forced hard fault on writing to UART0_AP7816A_T0 during UART0 initialization. The code was generated by PE and it pretty straightforward:

...

  /* UART0_WF7816: GTFD=1 */

  UART0_WF7816 = UART_WF7816_GTFD(0x01);

  /* UART0_ET7816: TXTHRESHOLD=0,RXTHRESHOLD=0 */

  UART0_ET7816 = (UART_ET7816_TXTHRESHOLD(0x00) | UART_ET7816_RXTHRESHOLD(0x00));

  /* UART0_AP7816A_T0: ADTI_H=0 */

  UART0_AP7816A_T0 = UART_AP7816A_T0_ADTI_H(0x00);

...

SCB_CFSR 0x00008200

SCB_HFSR 0x40000000

SCB_BFAR 0x4006a03a

This happens right in the PE_low_level_init() and only generated code is executed before this fault. Can someone shed a light on this behaviour? Maybe I am missing some simple thing? Or maybe it is a hardware problem?

Labels (1)
0 Kudos
8 Replies

1,114 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Mikhail,

Is it a K22 50MHz part? Please kindly let me know the mask set info on it, it is something like "0m33z".

Thanks for your patience!!

Have a nice day!!

Kan

0 Kudos

1,114 Views
mikhailburakov
Contributor III

Hi!

The chip is 120MHz, it's marked as "MK22FX512 VLK12 2N03G XCTAA1337A"

0 Kudos

1,114 Views
bgag
Contributor I

Mikhail,

I had the same problem.

CWMCU 10.4

MK22FX512VLL12 2N03G

As you know, during PE's UART0_Init() function, there is an unhandled interrupt which stops the MPU. Commenting out the reg inits with UART0_*7816 will prevent the interrupt, but you have to do this every time you "Generate Code" in PE. I agree, this is a PE or MK22 bug.

To fix this just disable all interrupts prior to calling PE_low_level_init(), and enable the interrupts in your code when you are good and ready. PE should disable all INTs before init.

1.  In PE Component Inspector, set "generate code" for the EnableInt and DisableInt methods in the CPU component.

2. Add Cpu_DisableInt(); in the main() function (ProcessorExpert.c) as shown below:

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

  /* Write your local variable definition here */

Cpu_DisableInt();                                             //               <-add this line

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization. ***/

...

3. In your code, after YOUR init stuff, enable the interrupts if needed.

...

Cpu_EnableInt();

...

 

Hope this helps,

-Brian

1,114 Views
mikhailburakov
Contributor III

Thank you for your answer. Actually the differences appeared to be so significant, that we decided to sick with k20. Only took 100MHz chip instead of previously used 72MHz.

0 Kudos

1,114 Views
retosonderegger
Contributor II

Did you enable the clock for this uart module?

0 Kudos

1,114 Views
mikhailburakov
Contributor III

Yep, clock gate enabled in PE. Moreover, I rechecked it right from the debugger.

0 Kudos

1,114 Views
mjbcswitzerland
Specialist V

Hi

The ISO-7816 functionality is new in the K22 (in comparison to K20).

Check that the ISO-7816 functionality is first enabled by setting the control bit ISO_7816E in UART0_C7816 otherwise the registers can not be written to (maybe trying to write when they are not enabled causes a hard fault).

Regards

Mark

1,114 Views
mikhailburakov
Contributor III

Hello!

I've just checked init code generated for K20 by PE. There is initialization sequence for 7816 stuff, but it is a bit different. Also it does not cause any troubles. At the moment I've just removed this part of code. However it is not a solution - only a workaround, because this code is autogenerated by PE.

0 Kudos