Esp32 i2s parallel driver using FreeRtos

No, that’s not a typo.

Display data/command ( dc ) pin:
data = 1
command = 0

I am sending pixels, so is data.

I think compiler do this:

buf_a[ i ] are 32 bits uint32_t.
ptr[ j ] are 8 bits uint8_t.

Suppose ptr[ j ] = 0x55

buf_a[ i ] = ptr[ j ] | 0x000;

ptr[ j ]   =  0x 00 00 00 55    // the compiler "cast" to uint32_t
           |  0x 00 00 00 00
buf_a[ i ] =  0x 00 00 00 55  

bit8 = 0 of buf_a[ i ] =  0x 00 00 00 55
, but internal hardware invert the signal, so, 0 ~ = 1.

I still don’t understand your magic OR with 0x000.
Luckily I don’t have to, so I don’t care :slightly_smiling_face:

The i2s hardware module inside the esp32 chip invert the signal.

uint32_t data_idx = ( port == I2S_NUM_0 ) ? I2S0O_DATA_OUT8_IDX : I2S1O_DATA_OUT8_IDX;

void gpio_matrix_out ( uint32_t gpio, uint32_t signal_idx, bool out_inv, bool oen_inv );

gpio_matrix_out ( LCD_DC_PIN, data_idx + 8, true, false ); // bit8 is used to control the DC signal !!!

bool out_inv = true.

The espressif documentation is horrible.

Now i tested without or operation and worked too.

Probably the loop will be faster now, but i need to put the oscilloscope to measure, and now i’m too lazy :slight_smile:

for ( i = 11, j = 0 ; i < length + 11 ; i = i + 2, j = j + 2 )    // Takes ???? ms when length = 15360 bytes.
{                                                                                                  
    buf_b[ i ]     = ptr[ j ];
    buf_b[ i + 1 ] = ptr[ j + 1 ];
}

I guess the OR 0x000 is optimized out anyway because it’s in fact a no-op.
Remember clearing a bit is done by AND ~(bitmask).