Hi ESP_houwenxiang,
"I think it's no use to reset the tx fifo, can you try resetting the tx module with the following code ?"
I am already doing this.
Code: Select all
int i2s_lcd_write_data ( uint32_t length, bool buffer_id ) // length = number in bytes. length <= 7680.
{
static uint32_t i;
static uint8_t* ptr = NULL;
if ( length > pixels_size_in_bytes ) // Length > buffer capacity. pixels_size_in_bytes = 7680 bytes.
{
printf( "Error: length > %d. \n\n", pixels_size_in_bytes );
return -1;
}
if ( buffer_id == 0 )
{
ptr = (uint8_t *) &buffer_a; // buffer_a is uint16_t.
/*
printf( "\n&buf_a = %p\n", &buf_a );
printf( "&buffer_a = %p\n", &buffer_a );
printf( "ptr = %p\n\n", ptr );
*/
for ( i = 0 ; i < length ; i = i + 2 ) // length <= 7680 bytes. loop max 7680/2 = 3840 times.
{
buf_a[ i ] = ptr[ i ]; // The address of buf_a increment in 4 bytes while the address of buffer_a(ptr) increment in 1 byte.
buf_a[ i + 1 ] = ptr[ i + 1 ];
/*
printf( "&ptr[ %d ] = %p\n", i, &ptr[ i ] );
printf( "ptr[ %d ] = 0x%02X\n", i, ptr[ i ] );
printf( "&ptr[ %d ] = %p\n", i+1, &ptr[ i+1 ] );
printf( "ptr[ %d ] = 0x%02X\n", i+1, ptr[ i+1 ] );
printf( "&buf_a[ %d ] = %p\n", i, &buf_a[ i ] );
printf( "buf_a[ %d ] = 0x%08X\n", i, buf_a[ i ] );
printf( "&buf_a[ %d ] = %p\n", i+1, &buf_a[ i+1 ] );
printf( "buf_a[ %d ] = 0x%08X\n", i+1, buf_a[ i+1 ] );
printf("\n");
*/
}
fill_dma_descriptor_a( (uint32_t) 4 * length ); // ( 4 * length ) = change from byte(8 bits) to word(32bits).
I2SX.out_link.addr = (uint32_t) &dma_desc_buf_a[0]; // ( (uint32_t) ( &dma_desc_buf_a[0] ) ) & I2S_OUTLINK_ADDR;
}
else
{
ptr = (uint8_t *) &buffer_b;
for ( i = 0 ; i < length ; i = i + 2 )
{
buf_b[ i ] = ptr[ i ];
buf_b[ i + 1 ] = ptr[ i + 1 ];
}
fill_dma_descriptor_b( (uint32_t) 4 * length );
I2SX.out_link.addr = (uint32_t) &dma_desc_buf_b[0];
}
I2SX.out_link.start = 1; // Set this bit to start outlink descriptor. (R/W).
I2SX.fifo_conf.dscr_en = 1; // Set this bit to enable I2S DMA mode. (R/W).
I2SX.conf.tx_start = 1; // Set this bit to start transmitting data. (R/W).
while ( ! ( I2SX.state.tx_idle ) ) // The status bit of the transmitter. 1: the transmitter is idle. 0: the transmitter is busy.(RO)
{ }
I2SX.conf.tx_start = 0; // Set this bit to start transmitting data. (R/W).
I2SX.fifo_conf.dscr_en = 0; // Set this bit to enable I2S DMA mode. (R/W).
tx_reset( ); // Set this bit to reset the transmitter. (R/W)
dma_tx_reset( ); // Set this bit to reset out DMA FSM. FSM = Finite State Machine. (R/W)
/*
I2SX.lc_conf.ahbm_rst = 1;
I2SX.lc_conf.ahbm_rst = 0;
I2SX.lc_conf.ahbm_fifo_rst = 1;
I2SX.lc_conf.ahbm_fifo_rst = 0;
*/
return 2019;
}
I already tried with all possibilities with different sequential order using:
* tx_reset( );
* dma_tx_reset( );
* fifo_tx_reset( ):
And enable only tx_reset( ).
After tx_reset( ) and fifo_tx_reset( ) and dma_tx_reset( ) and so on.
I am try this to:
I2SX.lc_conf.ahbm_rst = 1;
I2SX.lc_conf.ahbm_rst = 0;
I2SX.lc_conf.ahbm_fifo_rst = 1;
I2SX.lc_conf.ahbm_fifo_rst = 0;
But nothing solved the problem.
Thank's for the help.