Hi,
I have a SPI driver for nRF Connect SDK that I'm using to write and read from an IMU sensor using the nRF52840DK.
I use a SPI burst write to set the configuration file (this works fine) and a SPI burst read to read the IMU data stored on the sensor's FIFO buffer.
If I do the SPI burst read with a low array index count (say less than 500) everything works great. But if I use anything higher, the application crashes.
This is the function I'm using to do the burst read (and where the crash happens):
void bmi270_spi_fifo_read()
{
int err;
//TEST_SIZE set to 1000, it crashes
uint8_t tx_buffer[TEST_SIZE];
//Set the first byte as the reister address
tx_buffer[0] = READ_CMD | FIFO_DATA;
int length = sizeof(tx_buffer)/sizeof(tx_buffer[0]);
//Set the other bytes to 0x00
for (int i=1; i<length;i++)
{
tx_buffer[i] = 0x00;
}
//fifo_data is the receive buffer
for (int i=0; i<sizeof(fifo_data);i++)
{
fifo_data[i] = 0x00;
}
const struct spi_buf tx_buf = {
.buf = tx_buffer,
.len = sizeof(tx_buffer)
};
const struct spi_buf_set tx = {
.buffers = &tx_buf,
.count = 1
};
struct spi_buf rx_buf = {
.buf = fifo_data,
.len = sizeof(fifo_data)
};
const struct spi_buf_set rx = {
.buffers = &rx_buf,
.count = 1
};
gpio_pin_set(gpio1_dev, GPIO_1_CS, 0);
err = spi_transceive(spi_dev, &spi_cfg, &tx, &rx);
gpio_pin_set(gpio1_dev, GPIO_1_CS, 1);
if (err) {
printk("SPI error: %d\n", err);
} else {
//Remove the first two read dummy bytes
for(int i=2; i<sizeof(fifo_data); i++)
{
fifo_data[i-2] = fifo_data[i];
}
}
}
Any help would be appreciated.