Hi kolban,
Thanks for the reply. It gives hope that someone can help me out
Regards to using I2S in Master Rx in LCD mode, I think it is not supported yet because the datasheet says LCD Master Transmitter and Camera Slave Receiver when it mentions LCD mode of I2S. Actually, I tried to modify this demo code
https://github.com/har-in-air/ESP32-LCD ... aster/docs in which I enable RX operation (eg, dev->conf.rx_start = 1;) and check clock signal output, the result is no clock output. When I re-enable TX operation (eg, dev->conf.tx_start=1) like the demo, the clock signal is avaiable. That comes to a conclusion that LCD mode does not support RX now.
Next, I tried to use Camera Slave mode, I modified the demo
https://github.com/igrr/esp32-cam-demo in which I change I2S0.conf.rx_slave_mod to 0 for Master RX mode and configure clock pin to OUTPUT and map to I2S0O_WS_OUT_IDX signal.The result is that ESP32 can go to I2S interrupt when DMA transfer done as usual but when I probe the clock output signal, there are few pulses which does not make sense to me
Here is my code to init I2S:
Code: Select all
static void cam_i2s_init()
{
// Enable and configure I2S peripheral
periph_module_enable(PERIPH_I2S0_MODULE);
// Toggle some reset bits in LC_CONF register
// Toggle some reset bits in CONF register
i2s_conf_reset();
// Enable slave mode (sampling clock is external)
//I2S0.conf.rx_slave_mod = 1;
I2S0.conf.rx_slave_mod = 0;
// Enable parallel mode
I2S0.conf2.lcd_en = 1;
// Use HSYNC/VSYNC/HREF to control sampling
I2S0.conf2.camera_en = 1;
// Configure clock divider
I2S0.clkm_conf.val = 0;
I2S0.clkm_conf.clka_en = 0;
I2S0.clkm_conf.clkm_div_a = 63;
I2S0.clkm_conf.clkm_div_b = 63;
I2S0.clkm_conf.clkm_div_num = 80000000L/2000000L;
// FIFO will sink data to DMA
I2S0.fifo_conf.dscr_en = 1;
// FIFO configuration
I2S0.fifo_conf.rx_fifo_mod = SM_0A0B_0C0D; //16-bit single channel
I2S0.fifo_conf.rx_fifo_mod_force_en = 1;
I2S0.conf_chan.rx_chan_mod = 1; //only capture Left channel data
// Clear flags which are used in I2S serial mode
I2S0.sample_rate_conf.rx_bits_mod = 0;
I2S0.conf.rx_right_first = 0; //not skip first sample
I2S0.conf.rx_msb_right = 0; //LSB byte received first
I2S0.conf.rx_msb_shift = 0; //use MSB Alignment Standard
I2S0.conf.rx_mono = 0; //disable mono mode in PCM standard mode
I2S0.conf.rx_short_sync = 0; //disable receiver in PCM standard mode
I2S0.timing.val = 0;
// Allocate I2S interrupt, keep it disabled
esp_intr_alloc(ETS_I2S0_INTR_SOURCE,
ESP_INTR_FLAG_INTRDISABLED | ESP_INTR_FLAG_LEVEL1 | ESP_INTR_FLAG_IRAM,
&i2s_isr, NULL, &CameraInfo.i2s_intr_handle);
}
And the code to init I2S pins (I fixed HSYNC, H_ENABLE signals to 1 and only connect VSYNC signal)
Code: Select all
static void gpio_setup_out(int gpio, int sig, int inv) {
if (gpio == -1) return;
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO);
gpio_set_direction(gpio, GPIO_MODE_DEF_OUTPUT);
gpio_matrix_out(gpio, sig, inv, false);
}
static void cam_gpio_init()
{
gpio_num_t pins[] = {
CAM_DATA7_IO, CAM_DATA6_IO, CAM_DATA5_IO,
CAM_DATA4_IO, CAM_DATA3_IO, CAM_DATA2_IO,
CAM_DATA1_IO, CAM_DATA0_IO, CAM_VSYNC_IO,
};
gpio_config_t gpio_conf = {
.mode = GPIO_MODE_INPUT,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE
};
for (int i = 0; i < sizeof(pins) / sizeof(gpio_num_t); ++i) {
if (rtc_gpio_is_valid_gpio(pins[i])) {
rtc_gpio_deinit(pins[i]);
}
gpio_conf.pin_bit_mask = 1LL << pins[i];
gpio_config(&gpio_conf);
}
gpio_conf.pin_bit_mask = 1LL << 4;
gpio_conf.mode = GPIO_MODE_OUTPUT;
gpio_config(&gpio_conf);
// Route input GPIOs to I2S peripheral using GPIO matrix
gpio_matrix_in(CAM_DATA0_IO, I2S0I_DATA_IN0_IDX, false);
gpio_matrix_in(CAM_DATA1_IO, I2S0I_DATA_IN1_IDX, false);
gpio_matrix_in(CAM_DATA2_IO, I2S0I_DATA_IN2_IDX, false);
gpio_matrix_in(CAM_DATA3_IO, I2S0I_DATA_IN3_IDX, false);
gpio_matrix_in(CAM_DATA4_IO, I2S0I_DATA_IN4_IDX, false);
gpio_matrix_in(CAM_DATA5_IO, I2S0I_DATA_IN5_IDX, false);
gpio_matrix_in(CAM_DATA6_IO, I2S0I_DATA_IN6_IDX, false);
gpio_matrix_in(CAM_DATA7_IO, I2S0I_DATA_IN7_IDX, false);
gpio_matrix_in(CAM_VSYNC_IO, I2S0I_V_SYNC_IDX, true);
gpio_matrix_in(0x38, I2S0I_H_SYNC_IDX, false);
gpio_matrix_in(0x38, I2S0I_H_ENABLE_IDX, false);
gpio_setup_out(CAM_PCLK_IO, I2S0O_WS_OUT_IDX, false);
}
I also attach the waveform.
Should I miss anything?
HuyK