DAC0 Hard Fault in MK22FX

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

DAC0 Hard Fault in MK22FX

844 Views
marcohess
Contributor II

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 DAC_HAL_Init.

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.

Any ideas?

Tags (3)
0 Kudos
3 Replies

630 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi, Marco

About DAC you can refer to the demo code"C:\Freescale\KSDK_1.0.0\demos\dac_adc_demo", pay attention the the configuration of DAC.

And you also can check out the file of "C:\Freescale\KSDK_1.0.0\platform\drivers\dac\fsl_dac_driver.h" , look at the functions effect , then select you need .

Best Regards,

Alice

------------------------------------------------------------------------------------------

If this post answers your question, please click the Correct Answer button.

-----------------------------------------------------------------------------------

If this post help your question, please click the helpful Answer button.

0 Kudos

630 Views
marcohess
Contributor II

I am  familiar with those examples anf the fsl_dac_driver. However, the key issue is that this is the MK22FX part which the KSDK does not support, so I am patching the KSDK libraries to get it to work. It used to work beautifully on the FRDM-K22F board (MK22FN device) but now on the MK22FX, it Hard Faults at the first line of initialisation that happens in DAC_DRV_Init.

I have seen these hard faults before when I was debugging the other peripherals when the clock was not enabled to that peripheral, but now I am pretty sure that the clock is enabled so I am at a loss as to why it is now hard faulting.

0 Kudos

630 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Marco,

What's the whole name of your chip ? You should careful compare the two chips registers of DAC ,for example their address.

Best Regards

Alice

0 Kudos