Hi Jim,
I have checked you code and I have noticed the following warning:
passing argument 1 of 'DAC_DRV_StructInitUserConfigNormal' discards 'const' qualifier from pointer target type [enabled by default] main.c /Test DAC on K64/Sources line 56 C/C++ Problem
The Processor Expert generates the daConv1_InitConfig0 as a const variable (structure) that cannot be modified:
const dac_converter_config_t daConv1_InitConfig0 = {
.dacRefVoltSrc = kDacRefVoltSrcOfVref1,
.lowPowerEnable = false,
};
But the DAC_DRV_StructInitUserConfigNormal function initialize the daConv1_InitConfig0 structure. Therefore the exception is invoked.
In the case you use structures that are generated by Processor Expert you can use them directly. These structures are already initialized according to selected configuration in the fsl_dac component in your project.
If you use the default configuration the DAC device is already initialized in the PE_low_level_init().
PE_low_level_init() -> PEX_components_init() -> Components_Init() contains:
void Components_Init(void)
{
/*! daConv1 Auto initialization start */
DAC_DRV_Init(daConv1_IDX, &daConv1_InitConfig0);
DAC_DRV_ConfigBuffer(daConv1_IDX, &daConv1_BufferInitConfig0);
/*! daConv1 Auto initialization end */
}
It is mean that you can directly call the DAC_DRV_Output(daConv1_IDX, DACoutputValue) in your application (e.g. in the main() function after PE_low_level_init() function call).
Best Regards,
Marek Neuzil