Hi,
Can anyone plz explain me with this function
adc16_status_t ADC16_DRV_ConfigConvChn(uint32_t instance, uint32_t chnGroup, const adc16-configPtr);
what parameter instance and chngroup means?
How to initialize and assign multiple channels ( differential input) for ADC conversion in continuous conversion mode?
If I want to use 3 channels as ADC inputs is it possible to initialize 2 channels as differential input and 1 as single ended input? If it's possible how it should be done?
Is it possible to set 16 bit differential end resolution? I could see 9, 12 or 13 , 12 and 13 in KSDK 1.3 API reference manual.
In reference manual it is mentioned as
Output modes:
differential 16-bit, 13-bit, 11-bit, and 9-bit modes
single-ended 16-bit, 12-bit, 10-bit, and 8-bit modes on page 591.
Regards,
Snehal.
Hello Snehal,
1. " what parameter instance and chngroup means? " ->
"instance" is ADC ID or ADC module , for exmaple ADC0 \ ADC1 .
"chngroup" is the ADC configuration group, for example ADC0_A(0) ADC0_b(1) ...
2. If you want to initialize multiple channels , you can use the function you mentioned much times.
3. About the other two question , please tell me the part number of your chip.
And about the use of ADC functions , i recommend you refer to the adc demo and the "API Reference Manual",
you can find them at here : Freescale\KSDK_1.3.0\doc
Hope it helps
Alice
Part number we are using is : MK02FN128VFM10
Hello ,
About this chip , when use the differential mode , it can output 16 bit data.
- And about your requirement, on one hand, if your project is only KSDK (without PE) , i recommend
you refer to the demo code under KSDK (for example the demo on TWRK60100m board) to know how
to use the API, configure the 16 bit here :
then build the KSDK lib , then use this function :
ADC16_DRV_StructInitUserConfigDefault(&adcUserConfig);
- On the other hand (i recommend you use this method) . create one SDK+PE project,
then you only need configure the "fsl_adc16" component , then the code can generated ,
for example configure it as this :
the related code :
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Snehal,
- About the create one KSDK project on KSDK ,you can refer to here : Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt
After read this , you will know how to include the lib
- About the ADC16_HAL_drv and ADC16_Peripheral_drv , the HAL layer function realize the basic function , and the Perpheral layer call the HAL layer's funtions.
So generally , we use the ADC16_Peripheral_drv , while we can also use the HAl layer functions .
- As a newer to the KSDK , i recommend you use the KSDK+PE project as i said before .
- And sorry i don't know what's mean about this "Can we save as the example projects" ?
If you still have question you can contact me !
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
Thanks for reply….. I didn’t find reply option on community so replying through mail….
Sorry but I am getting confused now…. ☹
I have tried to write basic initialization code for ADC (continuous conversion only) as below:
void adc_init()
{
adc16_converter_config_t userConvConfig;
adc16_chn_config_t userChnConfig;
//uint16_t sampleValue;
//uint32_t i;
#if FSL_FEATURE_ADC16_HAS_CALIBRATION
adc16_calibration_param_t userCalConfig;
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
// Execute the auto-calibration.
userConvConfig.lowPowerEnable = false;
userConvConfig.clkDividerMode = kAdc16ClkDividerOf8; //check clock settings then decide
userConvConfig.longSampleTimeEnable = false;
userConvConfig.clkSrc = kAdc16ClkSrcOfBusClk;
userConvConfig.asyncClkEnable = false;
userConvConfig.highSpeedEnable = false;
userConvConfig.longSampleCycleMode = kAdc16LongSampleCycleOf24;
userConvConfig.hwTriggerEnable = false;
userConvConfig.refVoltSrc = kAdc16RefVoltSrcOfVref;
userConvConfig.continuousConvEnable = true;
#if (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16)
userConvConfig.resolution = kAdc16ResolutionBitOf16;
#endif
ADC16_DRV_Init(ADC16_INSTANCE, &userConvConfig);
}
Doubts:
I want to include library files (HAL/peripheral)in project. How should I include it.
I am confused about ADC16_HAL_drv and ADC16_Peripheral_drv sections in 1.3 API reference manual. adc16_chn_config_t structure is different in both sections. .diffconvenable parameter is there in HAL driver and not in peripheral driver.
Which library needs to be used : HAL or peripheral. Please guide how to do project settings. I can see my settings are included directly while project creation only.
I have written above function taking reference of examples in 1.3 demo_examples folder ADC_low_power.
Request to reply I am lagging in my work due to confusion.
Thanks.