RTOS osThreadFlagsSet in ISR leads to osRtxErrorISRQueueOverflow

Hello everyone,

I encounter a problem when working with RTX RTOS V2 thread flags when waiting for flags twice in a thread: When my thread waits for the ANALOG_WATCHDOG_FLAG, an ISR (adcIsrCallback()) eventually sets the flag and the program continues perfectly fine. In the further course of the thread, I wait for another flag "DMA_FLAG" . And when this flag gets set by the adcDmaCallback() function, the program crashes, calling osRtxErrorNotify with my thread ID and "osRtxErrorISRQueueOverflow" error code.

Please note: When the thread waits for the first time and the DMA_FLAG gets set, this works flawlessly!

I use DMA_FLAG = 0x0010U and ANALOG_WATCHDOG_FLAG = 0x0008U

I would be grateful for any help to fix this!
Simon

ADC ISR code:

void adcIsrCallback ( void )
{
  if ( (ADC1->SR) & ADC_SR_AWD )
  {
    //ADC1 analog watchdog interrupt (current/line monitoring of dout):
    osThreadFlagsSet(threadOneId, ANALOG_WATCHDOG_FLAG);
  }
}

DMA ISR code:

void adcDmaCallback ( void )
{
  if ( (DMA2->LISR) & DMA_LISR_TCIF0 )
  {
    ///DMA2 transfer complete:
    ADC1->CR2 &= ~ADC_CR2_DMA;        //stop the ADC triggering the DMA
    DMA2->LIFCR |= DMA_LIFCR_CTCIF0;  //clear the interrupt bit

    osThreadFlagsSet(threadOneId, DMA_FLAG);
    osThreadFlagsSet(threadTwoId, 0x0001U);
    
  }
  
  osSemaphoreRelease(fgtAdcSemaphore);
}

Thread code:

void threadOne (void * argument)
{
  //init stuff

  for(;;)
  {
    uint32_t flags = osThreadFlagsWait ( (ANALOG_WATCHDOG_FLAG | DMA_FLAG), osFlagsWaitAny, 1000 );
    
    if (flags == osFlagsErrorTimeout)
    {
        //timeout behaviour, doing some maintenance stuff
        flags = 0;
    }
    
    if (flags & DMA_FLAG)
    {
        //doing some data processing and calculations... This works reliable!
    }
    
    if ( flags & ANALOG_WATCHDOG_FLAG)
    {
        //Info: The ADC analog watchdog triggered, we want to analyse new data.
        //Info: The ADC is running all the time. To get fresh data, I activate the DMA to transfer 100 samples once.
        triggerDmaTransfer();
    
        flags = osThreadFlagsWait ( DRVDOUT_FLAG_DMA, osFlagsWaitAny, osWaitForever );
        //This is never reached. The program crashes after the ISR sets the flag.
    }
  }

Parents Reply Children
No data