Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on July 31, 2015

Hello All,

I am new to FreeRTOS with STM32F303 (ARM CM4F). I am trying to send data received from UART in queue using xQueueSendFromISR call. I am always entering into assert while accessing xQueueSendFromISR from UART interrupt. If i call xQueueSend() from same ISR it works. Is there anyone gives the clue what could be wrong.

Regards, Mukesh


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on July 31, 2015

Is there anyone gives the clue what could be wrong.

Probably not unless you give us some clues first. You have not said which assert is being hit, or shown any code as to how the xQueueSendFromISR() is being called.

Please say which assert is being triggered, as that should tell you what is wrong. If not, place a break point in the assert then either look at the call stack to see how you got there, or step out of the assert function back to where the assert was triggered so you can easily see the values of the variables at that point - as that will probably tell you.

If you still have a problem then please post some code so we can see how you are using the function.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on July 31, 2015

Thanks for Quick reply.

After geeting the USART receive interrupt it hits the assert as explained below:

configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );

I tried the diffrent priorities setting with the interrupt and NVIC controller still not able to understand the issue.

as per call stack it is entering into assert from xQueueGenericSendFromISR().

Please find the code bellow for your reference.: controller used STM32f303 (ARM CORTEX M4), ST Standard peripheral library used. IAR EWARM 7.20 is used.

USART Initialization void vUsartConfig(void) { USARTInitTypeDef USARTInitStructure; NVICInitTypeDef NVICInitStructure;

SerialComm_vGPIOInit();	


/* USARTx configuration ----------------------------------------------------*/
/* USARTx configured as follow:
- BaudRate = 230400 baud  
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 38400;//19200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(COMM2_PORT, &USART_InitStructure);

/* NVIC configuration */
/* Configure the Priority Group to 2 bits */
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = COMM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/* Enable USART */
USART_Cmd(COMM2_PORT, ENABLE);
USART_ITConfig(COMM2_PORT, USART_IT_RXNE, ENABLE);

}

USART RX Interrupt where Queue send is called void USART2IRQHandler(void) { UBYTE ubData =0; /* USART in mode Receiver */ if (USARTGetITStatus(COMM2PORT, USARTITRXNE) == SET) { ubData = USARTReceiveData(COMM2_PORT); xQueueSendFromISR(xRXQueueHandle, &ubData, &isPriorityTaskWoken); //xQueueSend(xRXQueueHandle,&ubData,100); }
}

Task Creattion and Que Creation void vCommServiceInit(void) { vSerialCommInit(); xRXQueueHandle = xQueueCreate(USBSERIALRXBUFFERSIZE, sizeof(UBYTE)); xRXQueueHandle = xQueueCreate(USBSERIALTXBUFFERSIZE,sizeof(UBYTE)); /* Create one of the two tasks. / xTaskCreate( vSerialCommTask, "Serial Comm Task", 1000, NULL, 2, NULL ); / We are not using the task handle. */ }

void vSerialCommTask( void pvParameters ) { UBYTE ubRxData=0; portBASE_TYPE myErrorVal = 0; / As per most tasks, this task is implemented in an infinite loop. / for( ;; ) { myErrorVal = xQueueReceive(xRXQueueHandle, &ubRxData, portMAX_DELAY); / Print out the name of this task. */ if(myErrorVal == 1) { vByteRecieved(ubRxData); } vSerialCommunication(); } }

Main functiona and kernel initialization void main() {
SYSTICKInit(); vCommServiceInit(); //Intializing the USART, Creating Task and Queue ADCvInit(); NVIC_SetPriorityGrouping(0);

    /* Create one of the two tasks. */
    xTaskCreate( vTask1, "Task 1", 1000, NULL, 1, NULL );		/* We are not using the task handle. */
    /* Create the other task in exactly the same way. */
    xTaskCreate( vTask2, "Task 2", 1000, NULL, 1, NULL );
    /* Create the other task in exactly the same way. */
    xTaskCreate( vTask3, "Task 3", 1000, NULL, 1, NULL );

    xAdcTimer = xTimerCreate("AdcTimer",10,pdTRUE,0,vAdcTimerCallBack);
    xTimerStart( xAdcTimer, 0 );

    /* Start the scheduler so our tasks start executing. */
    vTaskStartScheduler();	

    /* If all is well we will never reach here as the scheduler will now be
    running.  If we do reach here then it is likely that there was insufficient
    heap available for the idle task to be created. */
    for( ;; );

}


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by davedoors on July 31, 2015

Read the link to see the two things that are wrong in the code http://www.freertos.org/RTOS-Cortex-M3-M4.html


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on July 31, 2015

Thanks dave for reply, found accroding the link shared by you i need to set the priority grouping to NVICSetPriorityGrouping(NVICPriorityGroup_4); an dtried with this with no sub pritoriy in the USART interrupt and Main pririty setting to 0x0f to make it low priority inteeurpt. But still i am facinf the same issue.

I found when it is entering to Assert if( ulCurrentInterrupt >= portFIRSTUSERINTERRUPTNUMBER ) is getting true where ulCurrentInterrupt is 54 and portFIRSTUSERINTERRUPTNUMBER is 16. this is in port.c file. I didnt get any clue.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on July 31, 2015

When you hit the line:

configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );

What are the values of ucCurrentPriority and ucMaxSysCallPriority?

What are the settings for the following constants in your FreeRTOSConfig.h file?

configPRIOBITS configLIBRARYLOWESTINTERRUPTPRIORITY [optional] configLIBRARYMAXSYSCALLINTERRUPTPRIORITY [optional] configKERNELINTERRUPTPRIORITY configMAXSYSCALLINTERRUPT_PRIORITY

Regards.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on July 31, 2015

ucCurrentPriority = 54 ucMaxSysCallPriority = 0x50 FreeRTOSConfig.h is attached in the post for reference.

Attachments

FreeRTOSConfig.h (8003 bytes)

Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on July 31, 2015

...and you are still hitting the asset? If ucCurrentPriority is greater than ucMaxSysCallPriority, meaning it has a lower logical priority, so everything should be ok.

I'm not sure why ucCurrentPriority is 54 though. You say you are setting the priority to 0x0f, so I would expect it to be 0xf0 (240) when viewed in the debugger (because it is shifted up 4)


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on August 3, 2015

The value of these variable is

ucCurrentPriority = 54 ucMaxSysCallPriority = 0x50 at the time of entering the if condition if( ulCurrentInterrupt >= portFIRSTUSERINTERRUPT_NUMBER ) and after entering here there is one more line of code /* Look up the interrupt's priority. */ ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ]; after exicution of this instruction the value of ulCurrentInterrupt = 0; and then hitting the assert.

I can also share the complete project which can run on STM32f3 Discovery board if nedded for understading the issue. But still not get any idea why this is happening


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on August 3, 2015

I am confused.

Is ucCurrentPriority 54 before it is set (so when it holds a random value), or after it is set (so after the line ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ]; has executed.

If ulCurrentInterrupt is 0 (not ulCurrentInterrupt, not ucCurrentPriority) then it is not the interrupt you think it is, and has probably never had its priority set.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on August 3, 2015

54 i am getting before the line ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ]; has executed. After exicution of this line I am getting zero. if I am not wrong it means USART pririty is still higher set to zero which is higher, if so please suggest where i am doing the mistake.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on August 3, 2015

As per my previous email - the fact ulCurrentInterrupt is 0 would make me think the interrupt is not the one you think it is. What is the number of the interrupt you are setting the priority of?


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on August 3, 2015

I have 3 interrupt running i have given the same priority to all 0xf and sub prirority to 0.

Can you suggest me the interrupt pririty settings, I can try that.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on August 4, 2015

Hey guys i could able to crack the issue. To set the usart priority i was using the code below:

NVICInitStructure.NVICIRQChannel = COMM2IRQn; NVICInitStructure.NVICIRQChannelPreemptionPriority= configLIBRARYLOWESTINTERRUPTPRIORITY; //0xf NVICInitStructure.NVICIRQChannelSubPriority = 0x0; NVICInitStructure.NVICIRQChannelCmd = ENABLE; NVICInit(&NVICInitStructure);

Ideally it should set the usart interrupt priority in NVIC but actally it was not, because of it in the NVIC the USART was always set to 0 means highest priority, and hitting the assert.

Now i used 
NVIC_SetPriority(COMM2_IRQn, 6); 
and now code is working as required.

But I am confused and not able to understand why this is not working because of the function defined in STM32f3 standard peripheral is not working, or compiler issue of IAR or something else.

Thanks RTE for quick responses.

Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by rtel on August 4, 2015

Thanks for reporting back.

Did you try stepping into the NVIC_Init() function? Maybe it is performing a test that fails and just returns without doing anything?

Regards.


Facing issue with Stm32F303 + FreeRTOS : xQueueSendFromISR in UART Rx interrupt.

Posted by mukeshtalks on August 4, 2015

This function is not returning anything out of that. for your reference function implemented in stm32f3 standard peipheral libray is

/** * @brief Initializes the NVIC peripheral according to the specified * parameters in the NVICInitStruct. * @note To configure interrupts priority correctly, the NVICPriorityGroupConfig() * function should be called before. * @param NVICInitStruct: pointer to a NVICInitTypeDef structure that contains * the configuration information for the specified NVIC peripheral. * @retval None / void NVICInit(NVICInitTypeDef NVICInitStruct) { uint32t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;

/* Check the parameters */ assertparam(ISFUNCTIONALSTATE(NVICInitStruct->NVICIRQChannelCmd)); assertparam(ISNVICPREEMPTIONPRIORITY(NVICInitStruct->NVICIRQChannelPreemptionPriority));
assertparam(ISNVICSUBPRIORITY(NVICInitStruct->NVIC_IRQChannelSubPriority));

if (NVICInitStruct->NVICIRQChannelCmd != DISABLE) { /* Compute the Corresponding IRQ Priority --------------------------------*/
tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; tmppre = (0x4 - tmppriority); tmpsub = tmpsub >> tmppriority;

tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
tmppriority |=  NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
tmppriority = tmppriority << 0x04;

NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;

/* Enable the Selected IRQ Channels --------------------------------------*/
NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);

} else { /* Disable the Selected IRQ Channels -------------------------------------*/ NVIC->ICER[NVICInitStruct->NVICIRQChannel >> 0x05] = (uint32t)0x01 << (NVICInitStruct->NVICIRQChannel & (uint8t)0x1F); } }


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists