5.1.1 Macro Definitions
Below are the macro definitions in the source code in main.c
file listed.
- HARMONIC_NOISE
#define HARMONIC_NOISE 1
1
: Generate PWM signal as a periodic noise.0
: Do not generate PWM signal. - PWM_FRQ
#define PWM_FRQ 62000
Configuration of PWM frequency, 62 kHz.
To get the worst-case scenario of periodic noise in the test setup, the PWM frequency can be selected close to ADC sampling frequency.
- ADC_64X_ACCUMULATOR_ENABLE
#define ADC_64X_ACCUMULATOR_ENABLE 1
Enable configuration of consecutive sample accumulation.
1
: 64 consecutive sample accumulation.0
: No multiple sample accumulation (only one ADC sample accumulation).Note that this example shows a result graph with the ADC sample accumulation of 1 sample or 64 samples by using only the ADC_64X_ACCUMULATOR_ENABLE macro.
The Microchip tinyAVR® 1-series and megaAVR® 0-series support sample accumulation of 1, 2, 4, 8, 16, 32, and 64. For sample accumulation other than 1 or 64, the code needs to be changed accordingly.
- SAMPLING_DELAY
#define SAMPLING_DELAY 5
0
: No sampling delay between consecutive samples in one single burst.1 to 15: Configures the sampling delay between consecutive samples in one single burst. The delay is expressed as CLK_ADC cycles, 1 being a delay of one cycle.
Note: In the test setup, maximum noise filtering is achieved when the sampling delay value has been configured to 5. It has been configured using trial and error to tune this value correctly for obtaining the desired results and to suppress the present frequency components. It may vary from one setup to another. - ENABLE_ASDV
#define ENABLE_ASDV 0
1
: Enable the automatic sampling delay between consecutive samples in one single burst.0
: Do not enable automatic sampling delay variation.