Hi,
Among others, I have the following functions in my SPI module:
void spi_memory_display_callback(spi_callback_args_t * p_args)
{
if(p_args->event == SPI_EVENT_TRANSFER_COMPLETE)
{
switch(p_args->channel)
{
case 2:
tx_semaphore_ceiling_put(&spi_tx_done_sem, 1);
break;
default:
break;
}
}
}
void spi_send(spi_instance_t * spi, u8 * data, u16 size)
{
if(spi->p_api->write(spi->p_ctrl, data, size, SPI_BIT_WIDTH_8_BITS) == SSP_SUCCESS)
{
switch(spi->p_cfg->channel)
{
case 2:
tx_semaphore_get(&spi_tx_done_sem, TX_WAIT_FOREVER);
break;
default:
break;
}
}
}
I have being using these functions since the project started and they were working well until now.
Today my program stoped working and I discovered that a given thread was blocked waiting for the spi_tx_done_sem.
Placing some breakpoints I noticed that when spi_send() is called, somehow it goes directly to line "tx_semaphore_get(&spi_tx_done_sem, TX_WAIT_FOREVER);" without run the previous spi function "spi->p_api->write(spi->p_ctrl, data, size, SPI_BIT_WIDTH_8_BITS)".
Because of this, it doesn't call the write function, the callback will never be triggered and I will never receive the semaphore.
I already tried to set the optimization level to ZERO and the problem still remains.
What can I do to deeply investigate this problem?