I am struggling to get a custom board working which was designed for an MK22FN but by mistake we had an MK22FX device put on.
Whikle I wait for the new part to arrive, and with the KSDK not having support for the MK22FX yet, I went through and 'patched' the various differences in peripheral base addresses and clock gating registers (like for ADC1 and FTM3).
I got most of the peripherals to work, but I am now stumped by the DAC0 that gives me a Hard Fault during initialisation on the first line of
HW_DAC_DATnL_WR(baseAddr, 0U, 0U); HW_DAC_DATnH_WR(baseAddr, 0U, 0U);
The base address is Ok (
0x400cc000) and the DAC0 peripheral clock has been enabled in DAC_DRV_Init.
What else can be causing this Hard Fault. How do I fix this to get the DAC to work?
The puzzling thing is that before I had some of the other peripherals to work, this DAC0 was working fine on its PDB trigger but is now producing these Hard Faults with the PC on 0x7f4e in the disassembly below:
43 HW_DAC_DATnL_WR(baseAddr, 0U, 0U); HW_DAC_DATnH_WR(baseAddr, 0U, 0U);
00007f44: ldr r3, [r7, #4]
00007f46: movs r2, #0
00007f48: strb r2, [r3, #0]
00007f4a: ldr r3, [r7, #4]
00007f4c: adds r3, #1
00007f4e: movs r2, #0
00007f50: strb r2, [r3, #0]
I have tried removing some of the newer code and peripheral initialisations and go back to an earlier step but still no luck.