SPI Transmit with command phase only affects next rx transmission
Posted: Tue Jan 07, 2020 2:35 pm
I've noticed that using SPI transactions with CMD phase only eg:
affects next RX transmissions, eg.:
Executing such code in a loop (fram_writeWREN them fram_readData and print buffer) results in receiving one byte less for each loop iteration.
Primarily I receive 512 bytes, than 510, then 510. After some time I receive only one byte, rest of a buffer is zero.
What is happening?
Code: Select all
void fram_writeWREN() {
spi_transaction_ext_t transaction;
memset(&transaction, 0, sizeof(transaction));
transaction.base.cmd = WREN;
assert(spi_device_polling_transmit(fram_spi, (spi_transaction_t*) &transaction) == ESP_OK);
}
Code: Select all
void fram_readData(uint16_t address, char * data, size_t length) {
spi_transaction_ext_t transaction;
memset(&transaction, 0, sizeof(transaction));
transaction.base.cmd = READ;
transaction.base.addr = address;
transaction.base.flags = SPI_TRANS_VARIABLE_ADDR;
transaction.base.rx_buffer = data;
transaction.base.rxlength = length * 8;
transaction.base.length = transaction.base.rxlength;
transaction.address_bits = 16;
assert(spi_device_polling_transmit(fram_spi, (spi_transaction_t*) &transaction) == ESP_OK);
}
Primarily I receive 512 bytes, than 510, then 510. After some time I receive only one byte, rest of a buffer is zero.
What is happening?