AnsweredAssumed Answered

KV5x HSADC CTRL2 DIVA doesn't do anything?

Question asked by Gregory Wong on Sep 11, 2016
Latest reply on Aug 21, 2018 by Chris Brown

Hi everyone,

I'm trying to control the sampling rate of the 12-bit ADC by using the SDK2 driver.

I used the clock driver to set the system clock to 237.5MHz based on a 25MHz TCXO.

 

Right now I'm modifying the struct as follows:

 

hsadcConverterConfigStruct.clockDivisor = 3U;

 

And writing the registers using:

HSADC_SetConverterConfig(DEMO_HSADC_INSTANCE, kHSADC_ConverterA | kHSADC_ConverterB, &hsadcConverterConfigStruct);

 

I'm also toggling an LED to measure the acquisition speed.

 

It seems that no matter what value I use (in range, 3-64), the acquisition speed doesn't change.

 

Here is the whole block of code:

hsadc_config_t hsadcConfigStruct;
hsadc_converter_config_t hsadcConverterConfigStruct;
hsadc_sample_config_t hsadcSampleConfigStruct;


HSADC_GetDefaultConfig(&hsadcConfigStruct);
hsadcConfigStruct.dualConverterScanMode = kHSADC_DualConverterWorkAsTriggeredParallel;
hsadcConfigStruct.DMATriggerSoruce = kHSADC_DMATriggerSourceAsSampleReady;
HSADC_Init(DEMO_HSADC_INSTANCE, &hsadcConfigStruct);
HSADC0->CTRL1 |= HSADC_CTRL1_DMAENA(1);
/* Configure each converter. */
HSADC_GetDefaultConverterConfig(&hsadcConverterConfigStruct);

hsadcConverterConfigStruct.clockDivisor = 3U;
/* Enable the calibration in power up period. */
//hsadcConverterConfigStruct.powerUpCalibrationModeMask =
// (kHSADC_CalibrationModeSingleEnded | kHSADC_CalibrationModeDifferential);
HSADC_SetConverterConfig(DEMO_HSADC_INSTANCE, kHSADC_ConverterA | kHSADC_ConverterB, &hsadcConverterConfigStruct);
/* Enable the power for each converter. */
HSADC_EnableConverterPower(DEMO_HSADC_INSTANCE, kHSADC_ConverterA | kHSADC_ConverterB, true);
while (
(kHSADC_ConverterAPowerDownFlag | kHSADC_ConverterBPowerDownFlag) ==
((kHSADC_ConverterAPowerDownFlag | kHSADC_ConverterBPowerDownFlag) & HSADC_GetStatusFlags(DEMO_HSADC_INSTANCE)))
{
}
/* Wait the calibration process complete. None End of Scan flag will be set after power up calibration process. */
//while ((kHSADC_ConverterAEndOfCalibrationFlag | kHSADC_ConverterBEndOfCalibrationFlag) !=
// ((kHSADC_ConverterAEndOfCalibrationFlag | kHSADC_ConverterBEndOfCalibrationFlag) &
// HSADC_GetStatusFlags(DEMO_HSADC_INSTANCE)))
//{
//}
//HSADC_ClearStatusFlags(DEMO_HSADC_INSTANCE,
// (kHSADC_ConverterAEndOfCalibrationFlag | kHSADC_ConverterBEndOfCalibrationFlag));
/* Make each converter exit stop mode. */
HSADC_EnableConverter(DEMO_HSADC_INSTANCE, kHSADC_ConverterA | kHSADC_ConverterB, true);

/* Configure the samples. */
HSADC_GetDefaultSampleConfig(&hsadcSampleConfigStruct);
/* For converter A. */
hsadcSampleConfigStruct.channelNumber = DEMO_HSADC_CONVA_CHN_NUM1;
hsadcSampleConfigStruct.channel67MuxNumber = DEMO_HSADC_CONVA_CHN67_MUX_NUM1;
hsadcSampleConfigStruct.enableDifferentialPair = DEMO_HSADC_CONVA_CHN_NUM1_ENABLE_DIFF;
HSADC_SetSampleConfig(DEMO_HSADC_INSTANCE, 0U, &hsadcSampleConfigStruct);
hsadcSampleConfigStruct.channelNumber = DEMO_HSADC_CONVA_CHN_NUM2;
hsadcSampleConfigStruct.channel67MuxNumber = DEMO_HSADC_CONVA_CHN67_MUX_NUM2;
hsadcSampleConfigStruct.enableDifferentialPair = DEMO_HSADC_CONVA_CHN_NUM2_ENABLE_DIFF;
HSADC_SetSampleConfig(DEMO_HSADC_INSTANCE, 1U, &hsadcSampleConfigStruct);
/* For converter B.
* In HSADC_SetSampleConfig(), the channel number 0~7 represents input 0~7 of converter A and channel number 8~15
* represents input 0~7 of converter B.
*/
hsadcSampleConfigStruct.channelNumber = (DEMO_HSADC_CONVB_CHN_NUM1 + 8U);
hsadcSampleConfigStruct.channel67MuxNumber = DEMO_HSADC_CONVB_CHN67_MUX_NUM1;
hsadcSampleConfigStruct.enableDifferentialPair = DEMO_HSADC_CONVB_CHN_NUM1_ENABLE_DIFF;
HSADC_SetSampleConfig(DEMO_HSADC_INSTANCE, 8U, &hsadcSampleConfigStruct);
hsadcSampleConfigStruct.channelNumber = (DEMO_HSADC_CONVB_CHN_NUM2 + 8U);
hsadcSampleConfigStruct.channel67MuxNumber = DEMO_HSADC_CONVB_CHN67_MUX_NUM2;
hsadcSampleConfigStruct.enableDifferentialPair = DEMO_HSADC_CONVB_CHN_NUM2_ENABLE_DIFF;
HSADC_SetSampleConfig(DEMO_HSADC_INSTANCE, 9U, &hsadcSampleConfigStruct);
/* Enable the sample slot.
* The conversion sequence for converter A includes sample slot 0 and 1, while the sequence for converter B
* includes sample slot 8 and 9. Sample slot 0~7 can reference only to converter A and sample slot 8~15 can
* reference only to converter B in parallel mode.
*/
sampleMask = HSADC_SAMPLE_MASK(0U) /* For converter A. */
| HSADC_SAMPLE_MASK(1U) /* For converter A. */
| HSADC_SAMPLE_MASK(8U) /* For converter B. */
| HSADC_SAMPLE_MASK(9U); /* For converter B. */


HSADC_EnableSample(DEMO_HSADC_INSTANCE, sampleMask, true);
HSADC_EnableSample(DEMO_HSADC_INSTANCE, (uint16_t)(~sampleMask), false); /* Disable other sample slots. */

 

Not sure what I'm doing wrong here.

Outcomes