Using SPI master to send large amount of data

muaiyd
Posts: 3
Joined: Mon Aug 10, 2020 1:18 pm

Using SPI master to send large amount of data

Postby muaiyd » Mon Aug 10, 2020 4:17 pm

Hi All,
I am trying to read data from SD card then write them into LCD.
For that I am reading the data to buffer of 8K bytes then write them to the LCD. It works fine but sometime there is error of:
spi_master: check_trans_valid(811): trans tx_buffer should be NULL and SPI_TRANS_USE_TXDATA should be cleared to skip MOSI phase
specially with large files. Tryed using 215, 512, .. buffer size but always getting this error! also, tried adding delay but still same.
can anyone help please?
The code is :

void startTrans(U32 addr , U8 cmd)
{
esp_err_t ret;
spi_transaction_t tx;
memset(&tx, 0, sizeof(tx));

U8 len = 0;
U32_t tr;
tr.u32 = 0;

switch (cmd)
{
case 0:
len = 32;
break;

case 1:
case 2:
len = 24;
break;
}

tr.u8[0] = (U8)((addr >> 16) | (U8)(cmd << 6));
tr.u8[1] = (U8)(addr >> 8);
tr.u8[2] = (U8)(addr & 0xFF);

tx.length = len;
tx.rx_buffer = NULL;
tx.tx_buffer = (U8*)&tr.u32;

ret = spi_device_transmit(FT_spi , &tx);
assert(ret==ESP_OK);
//delay_us(3);
}

void Write(U32 addr, U8 *Src, U32 NBytes)
{
esp_err_t ret;
spi_transaction_t tx;
memset(&tx, 0, sizeof(tx));

gpio_set_level(FT_CS, 0);
startTrans(addr & 0x3FFFFF,cmd_wr);

tx.length = NBytes * 8;
tx.rx_buffer = NULL;
tx.tx_buffer = Src;

ret = spi_device_transmit(FT_spi , &tx);
assert(ret==ESP_OK);
//delay_us(NBytes*2);

gpio_set_level(FT_CS, 1);
}

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Using SPI master to send large amount of data

Postby ESP_Sprite » Tue Aug 11, 2020 11:04 am

Are you sure you can never have a situation where NBytes is 0?

muaiyd
Posts: 3
Joined: Mon Aug 10, 2020 1:18 pm

Re: Using SPI master to send large amount of data

Postby muaiyd » Tue Aug 11, 2020 8:59 pm

Thank you :),
I am not sure! could that be the problem?

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Using SPI master to send large amount of data

Postby ESP_Sprite » Wed Aug 12, 2020 9:50 am

That is the most likely scenario that would trigger that error message, so I'd say so.

muaiyd
Posts: 3
Joined: Mon Aug 10, 2020 1:18 pm

Re: Using SPI master to send large amount of data

Postby muaiyd » Thu Aug 13, 2020 7:33 pm

Many thanks, that was the problem :)

Who is online

Users browsing this forum: antonjung, ESP_Roland, Google Adsense [Bot] and 145 guests