Hi
Last week I started porting Helix mp3 decoder to FreeRTOS enviroment and I stuck on DMA1
Stream7IRQHandler. Inside the interrupr routine I release transmission complete semaphore by xSemaphoreGiveFromISR (xSemaphoreTC, &xHigherPriorityTaskWoken). Calling of this function causes permanent stuck inside vPortValidateInterruptPriority( void ). I know the problem is related to the priorities, but i can’t solve it by myself. Is there any helping hand? By the way, i’m rookie to FreeRTOS. 🙂
Dma configuration code
~~~
void DMA1
Stream7cfg ()
{
DMA
InitTypeDef DMAInitStructure;
NVIC
InitTypeDef NVICInitStructure;
RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_DMA1, ENABLE);
DMA_DeInit (DMA1_Stream7);
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) & SPI3->DR;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_Memory0BaseAddr = 0;
DMA_InitStructure.DMA_BufferSize = 0;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init (DMA1_Stream7, &DMA_InitStructure);
/* Config the DMA Stream IRQ Channel */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream7_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init (&NVIC_InitStructure);
/* Enable DMA request after last transfer (Single-ADC mode) */
DMA_ITConfig (DMA1_Stream7, DMA_IT_TC, ENABLE);
NVIC_EnableIRQ (DMA1_Stream7_IRQn);
}
~~~
DMA Irq
~~~
void DMA1
Stream7IRQHandler ()
{
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
if (DMA_GetITStatus (DMA1_Stream7,DMA_IT_TCIF7) != RESET)
{
DMA_ClearITPendingBit (DMA1_Stream7, DMA_IT_TCIF7);
/* and after that kernel hangs in vPortValidateInterruptPriority( void ) */
xSemaphoreGiveFromISR (xSemaphoreTC, &xHigherPriorityTaskWoken);
wait = 0;
}
portYIELD_FROM_ISR (xHigherPriorityTaskWoken);
}
~~~
and code fired transmission
~~~
if (buff
ready)
{
DMA1Stream7->NDTR = buff
len;
DMA1Stream7->M0AR = (uint32
t) buff;
DMA1Stream7->CR |= DMA
SxCREN;
buff_nr ^= 1;
while (xSemaphoreTake (xSemaphoreTC, (TickType_t) 20) == pdFALSE)
{
vTaskDelay(1);
}
~~~
Regards
Krzysztof Sroka