I'm getting really frustrated by the lack of documentation with processor expert:
I want to get the values of two pins from an ADC on a FRDM-K26Z. They're ADC0_SE8 and ADC0_SE9 if that matters.
I'm using the component fsl_adc16, which lets me set up multiple channel configurations, both single ended. One ADC configuration:
adConv1_InitConfig0 = {
.lowPowerEnable = false,
.clkDividerMode = kAdc16ClkDividerOf1,
.longSampleTimeEnable = false,
.resolution = kAdc16ResolutionBitOfSingleEndAs12,
.clkSrc = kAdc16ClkSrcOfBusClk,
.asyncClkEnable = false,
.highSpeedEnable = true,
.longSampleCycleMode = kAdc16LongSampleCycleOf24,
.hwTriggerEnable = false,
.refVoltSrc = kAdc16RefVoltSrcOfVref,
.continuousConvEnable = true,
.dmaEnable = false,
};
This works for the first channel configuration, software triggered (or really, "continuous") via ADC16_DRV_GetConvValueRAW(0,0).
When trying to get the second channel configuration, via ADC16_DRV_GetConvValueRAW(0,1), I get nothing but zeros. Even when attempting to manually initialize/trigger the 2nd channel with ADC16_DRV_ConfigConvChn(adConv1_IDX, 1, &adConv1_ChnConfig1); I get nothing but zeros. When I try adding DC16_DRV_WaitConvDone(adConv1_IDX,1);, the device effectively halts at that line (the conversion is never done).
Diving deeper into the fsl_adc16 component, I notice that I can't initialize multiple channels unless I turn on hardware triggering (Maybe add why that is a requirement to the docs?). So I tried that. I enabled hardware triggering in adConv1_InitConfig0, pointed Trigger A to PIT_Trigger_0 (I also tried combinations of Trigger B and PIT_Trigger_1), and set up an fsl_pit component. There's no pin configuration in the fsl_pit component so I'm just assuming it'll be on one of the PIT_Trigger pins...
The behavior is even worse now, with *neither* channel getting any values.
I'm losing my mind here because I feel like this ought to be a ridiculously simple thing to do.
Hello steven,
- From the Reference manual of your chip :
so if you initialize two pins at the same time, the I think only the second one work.
- About the second channel initialization, please change
ADC16_DRV_ConfigConvChn(adConv1_IDX, 1, &adConv1_ChnConfig1);
to
ADC16_DRV_ConfigConvChn(adConv1_IDX, 0, &adConv1_ChnConfig1);
then read result also use
ADC16_DRV_GetConvValueRAW(0,0)
- In the hardware trigger, if you use the PIT as trigger source, it needn't any pins for PIT.
After you configure the PIT correctly, it will the PIT trigger will automatically trigger ADC .
- About the hardware trigger , there is demo under KSDKv1.3 :
KSDK_1.3.0\examples\frdmkl26z\demo_apps\adc_hw_trigger
-About the PE, there is detail describe about the each component : right lick fsl_adc16 component -> choose "Help on component "
Hope it helps
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------