This project shows how to use the IADC in high accuracy mode on EFM32PG23-PK2504A (BRD2504A).
GSDK v4.4.3
- Board: Silicon Labs EFM32PG23 Pro Kit (BRD2504A)
- Device: EFM32PG23B310F512IM48
Connect the board via a micro-USB cable to your PC to flash the example. Using a power supply to apply a voltage to the IADC input pin (PA05).
To test this application, you can either create a project based on an example project or start with an empty example project.
-
Make sure that this repository is added to Preferences > Simplicity Studio > External Repos.
-
From the Launcher Home, add your board to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project filtering by 'iadc'.
-
Click the Create button on the Platform IADC High Accuracy Mode - PG23 (BRD2504A) example. Example project creation dialog pops up -> click Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create an Empty C Project project for your hardware using Simplicity Studio 5.
-
Replace all source and header files in the project root folder with the provided source and header files (located in the src and inc folder).
-
Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:
- [Platform] → [Peripheral] → [IADC]
- [Platform] → [Peripheral] → [PRS]
- [Platform] → [Driver] → [LED] → [Simple LED] → default instance name: led0.
- [Services] → [Power Manager] → [Power Manager: Deepsleep]
- [Services] → [Power Manager] → [Power Manager]
- [Services] → [Timers] → [Sleep Timer]
- [CMSIS] → [DSP] → [CMSIS-DSP]
-
Build and flash the project to your device.
This project demonstrates using the IADC peripheral's oversampling and high-accuracy features to acquire 20-bit resolution conversion results while operating in EM2.
The firmware utilizes emlib IADC structures and functions to properly configure the peripheral and employ the appropriate offset corrections. IADC interrupts on conversion completion wake the MCU into EM0, where the IADC interrupt handler converts the result to a voltage before returning to EM2.
Using the HFRCOEM23 clock source configured for 1 MHz, the IADC sampling rate is 388 Sps with an oversampling rate of 256(OSRHA) * 2(DIGAVG) = 512, and the IADC reads GPIO pin PA05 as input.
The PRS peripheral will output a pulse on PB04 whenever the IADC finishes one single conversion. Additionally, LED0 blinks at a 1 Hz frequency (500 ms toggle rate) to indicate firmware is running.
-
Build and flash the project to the PG23 Pro Kit.
-
Open the Simplicity Debugger.
-
add "sample" and "singleResult" to the Expressions Window.
-
Observe the "sample" variable, it stores the latest ADC sample and is a 20-bit result.
-
Observe the "singleResult" variable, it is the conversion result in voltage and is obtained by the formula: sample*VREF/(2^20).
-
Apply a voltage to the IADC input pin (PA05).
-
Now, start the debugger and observe the change of sample and singleResult whenever the voltage changes in the IADC input pin.
-
Observe output pin (PB04) pulsing: 20-bit resolution - conversion time formula: ((5*OSR) + 7)/fCLK_ADC with high accuracy OSR set to 256 and 1 MHz fCLK_ADC, this corresponds to single conversion time of ~1.3ms. With digital averaging set to 2X, the final conversion time is ~2.6ms, or a sampling frequency of roughly 388 Hz.