FRDMK64 board
KSDK 1.3
Hi, I just tried to use the DAC,I initialised the DAC using PE, basic setup without buffer.
I added these lines of my code;
DAC_DRV_StructInitUserConfigNormal(&daConv1_InitConfig0);
DAC_DRV_Init(daConv1_IDX, &daConv1_InitConfig0);
DAC_DRV_Output(daConv1_IDX, DACoutputValue);
I can single step into the first line but when the return is executed it jumps here (red text), in startup_MK64F12.S
DefaultISR:
b DefaultISR
.size DefaultISR, . - DefaultISR
I would appreciate any help with this.
Thanks
Jim
Solved! Go to Solution.
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
Hi Marek, thanks for that, still love PE and mourn its passing!
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
Hello Jim,
You can refer to the demo under the KSDK1.3 :
KSDK_1.3.0\examples\frdmk64f\driver_examples\dac
If still have error , you can send your project to me , i will check it on my side .
BR
Alice
Hi Jim,
Have you checked to see if the DAC module has the clock enabled in the SIM_SCGC2 register before making those DAC calls?
Regards,
David