KSDK support for 16bit ADC resolution on FRDM_K22F?

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

KSDK support for 16bit ADC resolution on FRDM_K22F?

1,224 Views
marcohess
Contributor II

I am just starting with the FRDM_K22F board and need the ADC in 16bit resolution which I though was supported by this CPU.

 

However looking through the SDK API documentation, there only appear to be resolution settings for up to 13 bits in the enum adc_resultion_mode_t.

 

Am I looking in the wrong place or is 16bit not supported in the SDK?

Labels (1)
0 Kudos
3 Replies

948 Views
marcohess
Contributor II

The documentation does not show it but it turns out that in the fsl_adc_hal.h there are a couple of extra lines in the adc_resolution_mode_t enum:

#if (FSL_FEATURE_ADC_MAX_RESOLUTION>=16)

    , kAdcResolutionBitOf16 = 3U,

        /*!< 16-bit for both single end sample and differential sample. */

    kAdcResolutionBitOfSingleEndAs16 = kAdcResolutionBitOf16, /*!< 16-bit for single end sample. */

    kAdcResolutionBitOfDiffModeAs16 = kAdcResolutionBitOf16 /*!< 16-bit for differential sample. */

#endif /* FSL_FEATURE_ADC_MAX_RESOLUTION */

0 Kudos

948 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Marco,

When customer want to modify resolutionMode value, it need to modify at [ksdk_platform_lib] project <fsl_adc_driver.c> below function:

/*FUNCTION*********************************************************************

*

* Function Name : ADC_DRV_StructInitUserConfigForIntMode

* Description  : Fill the initial user configuration for interrupt mode.

* Then call initialization function with the filled parameter would configure

* the ADC module work as the interrupt mode.

*

*END*************************************************************************/

adc_status_t ADC_DRV_StructInitUserConfigForIntMode(adc_user_config_t *userConfigPtr)

{

    if ( !userConfigPtr )

    {

        return kStatus_ADC_InvalidArgument;

    }

    userConfigPtr->intEnable = true;

    userConfigPtr->lowPowerEnable = true;

    userConfigPtr->clkDividerMode = kAdcClkDividerInputOf8;

    userConfigPtr->resolutionMode = kAdcResolutionBitOf12or13;

    userConfigPtr->clkSrcMode = kAdcClkSrcOfAsynClk;

    userConfigPtr->asyncClkEnable = true;

    userConfigPtr->highSpeedEnable = false;

    userConfigPtr->hwTriggerEnable = false;

#if FSL_FEATURE_ADC_HAS_DMA

    userConfigPtr->dmaEnable = false;

#endif /* FSL_FEATURE_ADC_HAS_DMA */

    userConfigPtr->refVoltSrcMode = kAdcRefVoltSrcOfVref;

    userConfigPtr->continuousConvEnable = true;

    return kStatus_ADC_Success;

}

After that, customer need compile the lib and related demo projects, the ADC resolution will be changed.


Wish it helps.
best regards
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

948 Views
andrew_su
NXP Employee
NXP Employee

Hi,

Changing the KSDK's source file or rebuild the library is not necessary. ADC_DRV_StructInitUserConfig...() is provided for quick configuration. These would be an available group of setting, but may not fit the user's actually application. So the configuation structure of "adc_user_config_t " can be filled according to application manually by users. For example, if you want to just change the converter's resolution, just use the code like the following:

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

adc_user_config_t MyAdcConfigStructure;

ADC_DRV_StructInitUserConfigForIntMode(&MyAdcConfigStructure);

MyAdcConfigStructure.resolutionMode= kAdcResolutionBitOfSingleEndAs16;

ADC_DRV_Init(0U, &MyAdcConfigStructure);

...

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

Eventually, users can fill the "MyAdcConfigStructure" totally by their own without the API of ADC_DRV_StructInitUserConfig...().

All these work can be done just in Application Layer and do not have to change the KSDK.


May the illustration help you.

Best regards!

Andrew SU

8/25, 2014

0 Kudos