Skip to content

Commit de2b526

Browse files
committed
Added default delay and sample times for the ADC during initialization.
1 parent 6d11627 commit de2b526

File tree

1 file changed

+16
-0
lines changed
  • targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api

1 file changed

+16
-0
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/analogin_api.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ void analogin_init(analogin_t *obj, PinName pin)
9494
MBED_ASSERT(channel != 0xFFFFFFFF);
9595
obj->UserBuffer.nChannels = channel;
9696

97+
/* Set ACLK to CCLK/16 */
98+
adi_pwr_SetClockDivider(ADI_CLOCK_ACLK,16);
99+
100+
/* Set default values for conversion and delay cycles. This sets up a sampling rate of
101+
16kHz. The sampling frequency is worked out from the following:
102+
103+
if delay time > 0:
104+
Fs = ACLK / [((14 + sampling time) * oversample factor) + (delay time + 2)]
105+
if delay time = 0:
106+
Fs = ACLK / ((14 + sampling time) * oversample factor)
107+
108+
The sampling (or acquisition) and delay times are in number of ACLK clock cycles.
109+
*/
110+
obj->DelayCycles = 0;
111+
obj->SampleCycles = 88;
112+
97113
/* Open the ADC device */
98114
adi_adc_Open(ADC_DEV_NUM, DeviceMemory, sizeof(DeviceMemory), &hDevice);
99115
obj->hDevice = hDevice;

0 commit comments

Comments
 (0)