MikroC Compiler Interrupt issue vPortValidateInterruptPriority STM32F407

pcat271264 wrote on Tuesday, June 13, 2017:

Hi, my first few days with freeRTOS I have been using the MikroC latest release ARM compiler and all was well, until I created tasks to handle UART interrupt.

My code based on examples:-

// Serial interrupt
void UART_Rx() iv IVT_INT_USART1 ics ICS_AUTO
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

 xSemaphoreGiveFromISR( xBinarySemaphore, &xHigherPriorityTaskWoken );
 portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

}
// and sends reads byte and send to display task
void UART_RX_Task( void *pvParameters )
{
while (1)
{
if (xSemaphoreTake(xBinarySemaphore, portMAX_DELAY) == pdPASS)
{
msgBuffer.msgData[0] = UART1_Read(); // read the received data;
msgBuffer.msgType = MSG_UARTA;

     //UART1_Write(rxmsgBuffer.msgData[0]);    // Used for testing interrupt
     xQueueSend(displayQueueHandle, &msgBuffer, 0xFFFFFFFFU); // Post Byte to Display task
  }
}

}

I get the following error after compile :-
0 360 Unresolved extern ‘vPortValidateInterruptPriority’ queue.c

I have searched and this snippet of port.c file (please ignore the quote before the hash) :-

'#if (configASSERT_DEFINED == 1)
// Limitations in the MikroC inline asm means ulCurrentInterrupt has to be
// global - which makes vPortValidateInterruptPriority() non re-entrant.
// However that should not matter as an interrupt can only itself be
// interrupted by a higher priority interrupt. That means if
// ulCurrentInterrupt, so ulCurrentInterrupt getting corrupted cannot lead
// to an invalid interrupt priority being missed.
void vPortValidateInterruptPriority( void )
{
uint32_t ulCurrentInterrupt;
uint8_t ucCurrentPriority;

config_ASSERT is defined in freeRTOS.h, is this a possible bug or do I need to change interrupt priorities ?
as I have read in some of the docs.

Any assistance would be great.

Thanks

Paul

rtel wrote on Thursday, June 15, 2017:

I’m not sure how you can get to a point where that error occurs. Are you using the FreeRTOS port from the FreeRTOS download? The defnition of configASSERT() in FreeRTOS.h is the default value - which will only be used if configASSERT() is not defined in FreeRTOSConfig.h. http://www.freertos.org/a00110.html#configASSERT

Do you have configASSERT() defined in FreeRTOSConifg.h? If so then configASSERT_DEFINED should be 1 and the function will be available. If configASSERT() is not defined then configASSERT_DEFINED will be 0 and the function should never be called.

pcat271264 wrote on Thursday, June 15, 2017:

Hi thanks for the reply, Im using the port supplied with the MikroC demo prog and below is a copy and paste from the end of my freeRTOSConfig.h file.

// This is the raw value as per the Cortex-M3 NVIC.
// Values can be 255 (lowest) to 0 (1?) (highest).
'#define configKERNEL_INTERRUPT_PRIORITY 255
// !!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!
// See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html.
// Equivalent to 0xb0, or priority 11.
'#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191

// Normal assert() mechanics without relying on assert.h header file.
'#define configASSERT(x)
if ((x) == 0) { taskDISABLE_INTERRUPTS(); while (1); }

'#endif // FREERTOS_CONFIG_H

rtel wrote on Thursday, June 15, 2017:

So you have configASSERT() defined. That means configASSERT_DEFINED
should also be 1, which comes from the following lines in FreeRTOSConfig.h:

#ifndef configASSERT
     #define configASSERT( x )
     #define configASSERT_DEFINED 0
#else
     #define configASSERT_DEFINED 1
#endif

Which then follows that vPortValidateInterruptPriority() should also be
available to you, which can be seen from your original post.

This would get messed up if the include files were in the wrong order,
but as this is presumably coming from queue.c, which is a file we
provide, the include files should be in the correct order. For
reference you need to #include FreeRTOS.h, then #include the header
files that contains the API function you want to use (tasks.h, queue.h,
etc.). Never include FreeRTOSConfig.h or portmacro.h directly.

pcat271264 wrote on Friday, June 16, 2017:

Hi ,the freeRTOS.h file supplied with their demo had the whole definition of the configASSERT commented out. //
Since putting it back in there are different errors as it now configASSERT_DEFINED == 1 :-

0 1004 interrupt handler (vPortSVCHandler at 0x000B) port.c
296 324 Undeclared identifier ‘portNVIC_IP_REGISTERS_OFFSET_16’ in expression port.c
296 324 Undeclared identifier ‘portFIRST_USER_INTERRUPT_NUMBER’ in expression port.c
0 1004 interrupt handler (xPortPendSVHandler at 0x000E) port.c
479 348 Assembler instruction ‘BL’ was not found. port.c
0 1004 interrupt handler (xPortSysTickHandler at 0x000F) port.c
725 317 Operator ‘’ is not applicable to these operands ‘’ port.c
783 324 Undeclared identifier ‘portFIRST_USER_INTERRUPT_NUMBER’ in expression port.c
787 324 Undeclared identifier ‘portNVIC_IP_REGISTERS_OFFSET_16’ in expression port.c
828 324 Undeclared identifier ‘portAIRCR_REG’ in expression port.c

I checked in the port.c of their example and the defines do not exist but they are in the example from you web
\FreeRTOSv9.0.0\FreeRTOS\Source\portable\MikroC\ARM_CM4F\port.c
the files are very different though, I copied the defines across and the above errors but then other errors.

pcat271264 wrote on Wednesday, June 21, 2017:

Just for your information MikroE have updated the Port on their Libstock page and it now compiles.

Thank you for your assistance