K22FX & FTM KSDK crash

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

K22FX & FTM KSDK crash

1,131 Views
marcohess
Contributor II

By accident I ended up with a K22FX512 on my board instead of the intended K22FN512

 

As far as I can tell they look pin compatible but have subtle changes inside and no KSDK support for them :-(

 

While I wait for the correct part to arrive I need to get this board running with the K22FX but are bumping into a problem with the FTM.

 

I try to use FTM3 CH7 as a single PWM output but when I try to use FTM_DRV_Init, I end up in the Default_Handler and watchdog reset in fsl_ftm_hal.c on HW_FTM_CNT_WR(ftmBaseAddr, 0);

 

From the documentation of the K22FX, it appears that the base address of FTM3 has changed compared to the K22FN and I tried patching the FTM3_BASE addresses in C:\Freescale\KSDK_1.0.0\platform\CMSIS\Include\device\MK22F51212\MK22F51212.h like so:

 

#define FTM3_BASE                                (0x400B9000u) /* (0x40026000u) */

 

but without much success as it still crashes.

 

Any pointers as to how to get FTM3 working on the K22FX?

Labels (1)
0 Kudos
4 Replies

712 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Marco,

Would you please share your code for a review? Thanks for your patience!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

712 Views
marcohess
Contributor II

I find that I end up in a Hard_Fault ISR vector. After a lot of hunting and careful checking of peripheral base addresses, I found that on the K22FX various base addresses like ADC1 and FTM3 have moved and also the peripheral clock enable bits for FTM3 and ADC1 have moved to different registers (SIM_SCGC3 instead of SIM_SCGC6).

So struggling through this, the most likely cause of the crashes is that lack of support for the K22FX in the KSDK and that the peripheral clocks are not correctly enabled. I think I managed to get the ADC1 clock and FTM3 clock correctly enabled with some patches in the KSDK but it is not really smooth sailing yet.

0 Kudos

712 Views
anthony_huereca
NXP Employee
NXP Employee

Hi Marco,

As you saw yourself, there are a number of internal differences between a K22FX device and the K22FN devices supported by KSDK. The KSDK release notes have the list of the K22FN devices supported by KSDK. By using a non-supported K22 device, you'll run into a number of issues like you've seen.

  My recommendation would be to wait to use KSDK until you receive the correct K22 device, as otherwise you may be spending a lot of time fixing more things you'll run into and it could be very frustrating.

  If however in the meantime you still want get something up and going and writing some sort of code, you could use the (non-KSDK) sample code for the TWR-K21F120M which is what should be used for your K22FX device. Kinetis K21 120 MHz Tower System Module|Freescale There is a table at the bottom of the K22_120MHz page showing how the different K22 devices match up to their respective boards: K22_120 |Kinetis K22 120 MHz MCUs|Freescale

-Anthony

0 Kudos

712 Views
xinyu_chen
NXP Employee
NXP Employee

Hi Macro

Could you please send your example code which you used?

0 Kudos