Hello,
We configured 2 SPI devices to use a shared bus with the sf_spi framework. We are using SSP v1.3.2. As mentioned in this other discussion, we have implemented a top-level mutex because we need to hold the chip select during the whole transaction.
Everything works most of the time, but under specific circumstances, we get an error SSP_ERR_HW_LOCKED right in the middle of a given transaction. After debugging, we could determine a specific sequence of read/write operations that can reproduce the problem. It seems to happen some time after changing from one device to the other.
We were able to create a very simple test case project with the Starter Kit that creates the issue (see attached zip file). We were also able to reproduce with a single thread running simplifying further more this test case. Here is the snippet of code that can reproduce the error:static void testSpi(void)
{
volatile uint8_t bufIn[4];
ERROR_CHECK(g_sf_spi_fpga.p_api->lock(g_sf_spi_fpga.p_ctrl));
ERROR_CHECK(g_sf_spi_fpga.p_api->read(g_sf_spi_fpga.p_ctrl, (void*)bufIn, sizeof(bufIn), SPI_BIT_WIDTH_8_BITS, TX_WAIT_FOREVER));
ERROR_CHECK(g_sf_spi_fpga.p_api->write(g_sf_spi_fpga.p_ctrl, (void*)"test", 4U, SPI_BIT_WIDTH_8_BITS, TX_WAIT_FOREVER));
ERROR_CHECK(g_sf_spi_fpga.p_api->unlock(g_sf_spi_fpga.p_ctrl));
ERROR_CHECK(g_sf_spi_eeprom.p_api->lock(g_sf_spi_eeprom.p_ctrl));
ERROR_CHECK(g_sf_spi_eeprom.p_api->read(g_sf_spi_eeprom.p_ctrl, (void*)bufIn, sizeof(bufIn), SPI_BIT_WIDTH_8_BITS, TX_WAIT_FOREVER));
ERROR_CHECK(g_sf_spi_eeprom.p_api->write(g_sf_spi_eeprom.p_ctrl, (void*)"test", 4U, SPI_BIT_WIDTH_8_BITS, TX_WAIT_FOREVER));
ERROR_CHECK(g_sf_spi_eeprom.p_api->unlock(g_sf_spi_eeprom.p_ctrl));
}
In that code, the second write fails (g_sf_spi_eeprom.p_api->write).
Is this a known issue and if so is there any workaround for it?
Thanks
Franck
(Please visit the site to view this file)