cancel
Showing results for 
Search instead for 
Did you mean: 

Wi-Fi Combo

Anonymous
Not applicable

Second arg of:

wiced_result_t wiced_adc_init( wiced_adc_t adc, uint32_t sample_cycle );

What values are acceptable?

0 Likes
1 Solution
SeyhanA_31
Employee

Hi,

Here is the logic to determine actual value used to set MCU peripheral:

/* Find the closest supported sampling time by the MCU */

for ( a = 0; ( a < sizeof( adc_sampling_cycle ) / sizeof(uint16_t) ) && adc_sampling_cycle < sample_cycle; a++ )

{

}

Seyhan

View solution in original post

7 Replies
ShawnA_01
Employee

I don't know your exact answer, but (in SDK 3.1.1.) Line 106 of the file platform_adc.c (in the platform_adc_init() function), you can see the code step through an array of [supported] sample cycles.

static const uint16_t adc_sampling_cycle[] =

{

    [ADC_SampleTime_3Cycles  ] = 3,

    [ADC_SampleTime_15Cycles ] = 15,

    [ADC_SampleTime_28Cycles ] = 28,

    [ADC_SampleTime_56Cycles ] = 56,

    [ADC_SampleTime_84Cycles ] = 84,

    [ADC_SampleTime_112Cycles] = 112,

    [ADC_SampleTime_144Cycles] = 144,

    [ADC_SampleTime_480Cycles] = 480,

};

Then, at line 111, it configures the ADC channel with the "found" value from the table.  Stated differently, if you pass in a garbage sample rate, the code self-protects itself to only sample at the supported rates.

So, I assume, the numbers in the table above are your choices.

I'm speculating on all of this.  What do you think?

0 Likes
VikramR_26
Employee

An ADC is defined by its bandwidth (the range of frequencies it can measure) and its signal to noise ratio (how accurately it can measure a signal relative to the noise it introduces). The actual bandwidth of an ADC is characterized primarily by its sampling rate which is the sample cycle. Consider for instance 15 cycles is 4 MHz according to some specs . Based on the MCU you are using, you can refer to the data sheet can configure the number of cycles as Shawn has mentioned above.

Thnx

vik86

Anonymous
Not applicable

So the sample_cycle is the number of internal ADC clocks to take a single sample, correct?  When the comment

<snip>

If the MCU does not support the value provided, the closest supported value is used.

</snip>

Is closest based on delta from supported higher and lower values, or is there another means to determine the closest supported value?

Thanks, Denis

0 Likes
ShawnA_01
Employee

Looking at the code, the comparison is a Less-Than operator.  Passing in a '52' would resolve down to a 28 per the table above.

0 Likes
Anonymous
Not applicable

Shawn,

you're right about the mechanism: the example from Broadcom asks for a "5", but internally a valid number which is close to the requested number is chosen. In this example, "5" is requested, "15" is programmed.

I will search the data sheet to know what those number mean in term of sample-per-second.

0 Likes
SeyhanA_31
Employee

Hi,

Here is the logic to determine actual value used to set MCU peripheral:

/* Find the closest supported sampling time by the MCU */

for ( a = 0; ( a < sizeof( adc_sampling_cycle ) / sizeof(uint16_t) ) && adc_sampling_cycle < sample_cycle; a++ )

{

}

Seyhan

View solution in original post

Anonymous
Not applicable

So if 52 were passed in, the result would be 56.

Thanks

0 Likes