Hello,
I´m working on my audio project and I try to stream some audio data (currently a 1 kHz square wave signal with 3.3 V peak) over I2S. The audio signal is sampled by an ADC in the free-running mode.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "app_error.h"
#include "nrf_drv_ppi.h"
#include "nrf_drv_i2s.h"
#include "nrf_drv_saadc.h"
#include "nrf_drv_timer.h"
#include "nrf_gpio.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#define LED_0 17
#define BUTTON_0 13
#define BUTTON_1 14
#define TRIGGER 31
#define SAMPLES 128
static bool IsStarted = false;
static volatile uint32_t* I2S_BlockToFill = NULL;
static volatile uint32_t* ADC_BlockToFill = NULL;
The code from above will give a pretty poor signal when I use the ADC.
I have tried to figure out the reason for this and replaced the line
Fullscreen
1
I2S_BlockToFill[i] = (uint32_t)(0x0000 | (ADC_BlockToFill[i] & 0xFFFF));
with
Fullscreen
1
I2S_BlockToFill[i] = (uint32_t)(0x0000 | (i & 0xFFFF));
to produce data from a ramp signal and the signal looks much better.
So it looks like the problem is based on the ADC. I have tried to use two buffers to use the same swapping buffer system as in the I2S example.
How can I improve this result?