I have a board here with nrf52832 rev B attached to a max98089 i2s codec. In this application we are only really using the ADC channel of the codec. Everything is configured for 8khz 24bit samples. Since the i2s RATIO register settings are kind of limited. I opted to send a 16Mhz MCLK out of the i2s module. Then operate the codec in i2s master mode since it has a much more advanced clocking scheme and then try to run nrf52 in slave mode.
This seems to more or less work. Except that my data buffer is all full of zero's all the time. I have used a scope to measure all the signals going to into the nrf and the data is definitely not 0 all the time. The actual data is an 8khz wave on LRCLK, and 384khz BCLK. Which bunch of random noise on SDIN. So this is exactly 48bit i2s frames. It seems like LRCLK and BCLK must be working correctly or my i2s data handler would never even get called.
Here are the relevant pieces of code. I am using the nrf5 V11 alpha2 SDK, and the s132 stack is active.
drv_config.h
#if (I2S_ENABLED == 1)
#define I2S_CONFIG_SCK_PIN 5
#define I2S_CONFIG_LRCK_PIN 3
#define I2S_CONFIG_MCK_PIN 7
#define I2S_CONFIG_SDOUT_PIN 4
#define I2S_CONFIG_SDIN_PIN 6
#define I2S_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
#define I2S_CONFIG_MASTER NRF_I2S_MODE_SLAVE
#define I2S_CONFIG_FORMAT NRF_I2S_FORMAT_I2S
#define I2S_CONFIG_ALIGN NRF_I2S_ALIGN_LEFT
#define I2S_CONFIG_SWIDTH NRF_I2S_SWIDTH_24BIT
#define I2S_CONFIG_CHANNELS NRF_I2S_CHANNELS_STEREO
#define I2S_CONFIG_MCK_SETUP NRF_I2S_MCK_32MDIV2
#define I2S_CONFIG_RATIO NRF_I2S_RATIO_256X
#endif
main.c
#define I2S_BUFFER_SIZE 256
static uint32_t m_buffer_rx[I2S_BUFFER_SIZE];
static void i2s_init(void){
uint32_t err_code;
nrf_drv_i2s_config_t config = NRF_DRV_I2S_DEFAULT_CONFIG;
err_code = nrf_drv_i2s_init(&config, i2s_data_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_i2s_start(m_buffer_rx, 0, I2S_BUFFER_SIZE, 0);
APP_ERROR_CHECK(err_code);
}
static void i2s_data_handler(uint32_t const * p_data_received,
uint32_t * p_data_to_send,
uint16_t number_of_words){
blocks_rx++;
for(int i=0; i < number_of_words; i++){
if(p_data_received[i])
non_zero++;
}
}
The results of running this are that blocks_rx increments at the expected rate and non_zero remains 0. Is there anything obvious I am doing wrong here? Is it possible there is some unknown errata related to i2s slave mode? Thanks for any pointers.