Hello Viktors,
Yes, MK21DA5 derivative is the most compatible derivative with MK22DX128VLK5 MCU.
Remember to modify fsl_device_registers.h in order to include MK21DA5 header files when CPU_MK22DX128VLK5 is used in the project:
#elif (defined(CPU_MK21DX128AVLK5) || defined(CPU_MK21DX256AVLK5) || defined(CPU_MK21DN512AVLK5) || \
defined(CPU_MK21DX128AVMC5) || defined(CPU_MK21DX256AVMC5) || defined(CPU_MK21DN512AVMC5)
|| defined(CPU_MK22DX128VLK5))
#define K21DA5_SERIES
/* CMSIS-style register definitions */
#include "MK21DA5/include/MK21DA5.h"
/* Extension register definitions */
#include "MK21DA5/include/MK21DA5_extension.h"
/* CPU specific feature definitions */
#include "MK21DA5/include/MK21DA5_features.h"
Also, remember to enable features in MK21DA5_features.h according to peripherals for MK22 MCU part:
#elif defined(CPU_MK22DX128VLK5)
/* @brief ACMP availability on the SoC. */
#define FSL_FEATURE_SOC_ACMP_COUNT (0)
/* @brief ADC16 availability on the SoC. */
#define FSL_FEATURE_SOC_ADC16_COUNT (1)
I hope this can help you!
Best Regards,
Isaac Avila