I am trying to send a mailbox message from a DMA complete ISR to some thread that should process data.
However, I am running into SV#8 errors instantly!
It seems like "ch.dbg.lock_cnt" is equal to 1 in "_dbg_check_enter_isr()". What does that mean?
This is the dma ISR handler.
Code: Select all
void dma_complete_handler(stm32_dma_stream_t * dmastp)
{
/**
* Current buffer is Memory 0
*/
m_send.control = DATA_READY;
if((dmastp->stream->CR & DMA_SxCR_CT) == 0)
{
m_send.datap = mem0;
}
/**
* Current buffer is Memory 1
*/
else
{
m_send.datap = mem1;
}
m_send.len = 1024;
chSysLockFromISR();
chMBPostI(&mb_sender, (msg_t)&m_send);
chSysUnlockFromISR();
}
This is where the mailbox is read:
Code: Select all
THD_FUNCTION(tcp_sender, p) {
(void)p;
struct netconn * conn;
uint32_t status = CLIENT_DISCONNECTED;
chRegSetThreadName("tcp_sender");
while (true)
{
/**
* Wait for signal from DMA ISR to start transmitting data
*/
msg_t msg;
m_send_t * m_send;
if (chMBFetch(&mb_sender, &msg, TIME_INFINITE) == MSG_OK)
{
m_send = (m_send_t *) msg;
switch (m_send->control)
{
case CLIENT_CONNECTED:
conn = m_send->conn;
status = CLIENT_CONNECTED;
break;
case CLIENT_DISCONNECTED:
conn = NULL;
status = CLIENT_DISCONNECTED;
break;
case DATA_READY:
if(status == CLIENT_CONNECTED)
{
netconn_write( conn, m_send->datap, m_send->len, NETCONN_NOCOPY );
}
break;
}
}
}
}
The DMA is configured to run that function when the transfer complete interrupt is triggered:
Code: Select all
dmaStreamAllocate(STM32_DMA2_STREAM2,
0,
(stm32_dmaisr_t)dma_complete_handler,
(void *)STM32_DMA2_STREAM2);
Thanks for your input,
Adrian