K22f stuck in hard fault handler in BOARD_BootClockRUN

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

K22f stuck in hard fault handler in BOARD_BootClockRUN

1,105 Views
bulislaw
Contributor I

I've tracked my issues with K22f to board being stuck in hard fault handler:

eg the bubble demo bubble.c:

buble.c:140 BOARD_BootClockRUN

clock_config.c:131 CLOCK_SetSimConfig(&g_defaultClockConfigRun.simConfig);

fsl_clock.c:520 CLOCK_SetEr32kClock(config->er32kSrc);

fsl_clock.c:663 SIM->SOPT1 = ((SIM->SOPT1 & ~SIM_SOPT1_OSC32KSEL_MASK) | SIM_SOPT1_OSC32KSEL(src));

What could be going wrong?

0 Kudos
3 Replies

711 Views
bulislaw
Contributor I

Hi,

apologies for not giving more background. I have the K22f board and it used to work just fine. One day it just stopped (I was playing with PWM and servo control, it seemed to work fine, but next day I've tried to use it it wouln't work). I thought it's flashing issue, because the debug seem not to work, but after some massaging and more checking I manage to track it down to the hard fault. I don't see how it would stop populating the clock source. I make sure to try some of the demo apps and they also don't work (hang in exactly the same way). Could it be I fried the clock source or disconnected it in some way (I was touching bits around flextimer but it shouldn't affect anything permanently)? How could it happen?

0 Kudos

711 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Bartek,

I suppose you use FRDM-K22F, it has both 32.768KHz crystal(connected to EXTAL32/XTAL32) and 8MHz crystal(connected to EXTAL0/XTAL0 pins), it seems that the Hard Fault interrupt does not result from crystal.

It is difficult to track the source which leads to the hard fault interrupt.

I suggest you use PIT to generate interrupt, in the ISR of PIT, toggle a LED, does the hard fault issue happen or not?

How about using the default FEI mode instead of PEE mode by commenting the BOARD_BootClockRUN() function.

BR

XiangJun Rong

0 Kudos

711 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Bartek,

The following is the code of void BOARD_BootClockRUN(void), the CLOCK_BootToPeeMode() function configures the K22f in PLL mode which uses external crystal or clock source for the EXTAL/XTAL pins, I suppose that you use your own target board, which do not populate crystal or clock source on the EXTAL/XTAL pins. I suppose you use the code based on FRDM_K22F, on the board, a 8MHz crystal are connect to the EXTAL/XTAL pins.

If it is not your case, I am sorry.

BR

XiangJun Rong

void BOARD_BootClockRUN(void)

{

    CLOCK_SetSimSafeDivs();

    CLOCK_InitOsc0(&g_defaultClockConfigRun.oscConfig);

    CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ);

    CLOCK_BootToPeeMode(g_defaultClockConfigRun.mcgConfig.oscsel, kMCG_PllClkSelPll0,

                        &g_defaultClockConfigRun.mcgConfig.pll0Config);

    CLOCK_SetInternalRefClkConfig(g_defaultClockConfigRun.mcgConfig.irclkEnableMode,

                                  g_defaultClockConfigRun.mcgConfig.ircs, g_defaultClockConfigRun.mcgConfig.fcrdiv);

    CLOCK_SetSimConfig(&g_defaultClockConfigRun.simConfig);

    SystemCoreClock = g_defaultClockConfigRun.coreClock;

}

0 Kudos