MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Peripheral features and how this peripheral works

The 12-bit Cyclic Analog-to-Digital converter(CADC) is a dual converter 12-bit ADC in which each ADC converter has its own voltage reference and control block. The two converters are converterA and converterB.

Features

How this peripheral works

  1. Connects signals to CADC's input channels pin on the board.
  2. Sets the scan mode of the cadc.
  3. Assigns the channels to sample slots.
  4. Upon a software start or external sync trigger, ADC starts to convert from sample slot 0. The conversion result of each sample slot is placed into the corresponding result register.
  5. The scan shall complete upon a disabled sample slot or otherwise upon the last sample slot.

How this driver is designed to make this peripheral works.

The cadc driver provides a structure cadc_config_t which contains major options of cadc features. The CADC_Init() function takes the argument in type of cadc_config_t, and this function can be used to configure major features of the CADC module except the high limit value, low limit value, offset value and zero crossing mode of each sample slots. After Invoking the CADC_Init() function with the related converters being powered up, upon software starting or being armed by the Sync signal, the scan will start based on the options configured. Based on the behaviour of the cadc module, the cadc driver also is divided into multiple function groups.

How to use this driver

Typical Use Case

  1. Dual converters scan sample slots sequentially. In this type of use case, dual converters use the control setting of converterA. The scan mode must be selected as sequential mode, so dual converters can be executed sequentially. In this type of use case, do remember to power up the converter which contains the channels to be sampled. If the application wants to use interrupts, please remember to enable related interrupts except that kCADC_ConversionCompleteInterrupt1Enable is useless. After started, the scan will execute from sample slot0 and will stop at the first disabled sample slot. The prototype of this type of use case is shown below.
    cadc_config_t sCadcConfigStruct;
    CADC_GetDefaultConfig(&sCadcConfigStruct);
    sCadcConfigStruct.sConverterA.bPowerUp = true;
    sCadcConfigStruct.sConverterA.u16ClockDivisor = 4U; (So ConverterA clock = (peripheral clock / 5).)
    sCadcConfigStruct.sConverterB.bPowerUp = true;
    sCadcConfigStruct.sConverterB.u16ClockDivisor = 4U; (So ConverterB clock = (peripheral clock / 5).)
    CADC_Init(ADC, &sCadcConfigStruct);
  2. Dual converters scan sample slots parallel independently. In this type of use case each converter has its own control setting. The scan mode must be selected as parallel independent mode, so dual converters can work independently. The converter must be powered up if it is used to convert sample slots. If the application wants to use interrupt, please remember to enable interrupts. If converterA is started, the scan of converterA will start from sample slot0 and will stop at the first disabled sample slot. If converterB is started, the scan of converterB will start from sample slot8 and will stop at the first disabled sample slot. The prototype of this type of use case is shown below.
    cadc_config_t sCadcConfigStruct;
    CADC_GetDefaultConfig(&sCadcConfigStruct);
    kCADC_convASample2Disabled;
    kCADC_convBSample10Disabled;
    sCadcConfigStruct.sConverterA.bPowerUp = true;
    sCadcConfigStruct.sConverterA.u16ClockDivisor = 4U; (So ConverterA clock = (peripheral clock / 5).)
    sCadcConfigStruct.sConverterB.bPowerUp = true;
    sCadcConfigStruct.sConverterB.u16ClockDivisor = 4U; (So ConverterB clock = (peripheral clock / 5).)
    CADC_Init(ADC, &sCadcConfigStruct);
  3. Dual converters scan sample slots parallel simultaneously. In this type of use case, dual converters use the control setting of converterA. The scan mode must be selected as parallel simultaneous mode, so dual converters can work simultaneously. In this type of use case do power up both the converters. If the application wants to use interrupt, please remember to enable related interrupts but please note that kCADC_ConverterBEndOfScanFlag is useless in this type of use case. If started, the scan of converterA and converterB will start from converters' first sample slot at the same time, and the scan will stop when any converter encounters the first disabled sample slot. The prototype of this type of use case is shown below.
    cadc_config_t cadcConfigStruct;
    CADC_GetDefaultConfig(&cadcConfigStruct);
    sCadcConfigStruct.sConverterA.bPowerUp = true;
    sCadcConfigStruct.sConverterA.u16ClockDivisor = 4U; (So ConverterA clock = (peripheral clock / 5).)
    sCadcConfigStruct.sConverterB.bPowerUp = true;
    sCadcConfigStruct.sConverterB.u16ClockDivisor = 4U; (So ConverterB clock = (peripheral clock / 5).)
    CADC_Init(ADC, &sCadcConfigStruct);