[SOLVED] Systemview stuck in configASSERT with FreeRTOS + STM32CubeMX

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Systemview stuck in configASSERT with FreeRTOS + STM32CubeMX

    Hello,

    I'm trying to use the Systemview with the FreeRTOS 9.0 in the project created by STM32CubeMx, but the program always stuck in the configASSERT, line 764 in the file port.c (line 18 below). I think the problem occurred because of the level of current nterrupt, got in __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) ), is equal to zero.

    Does anybody now fix this?

    I called the main file before init the FreeRTOS. Is it the right place?

    Thanks!


    Source Code

    1. SEGGER_SYSVIEW_Conf();
    2. SEGGER_SYSVIEW_Start();

    Source Code

    1. void vPortValidateInterruptPriority( void )
    2. {
    3. uint32_t ulCurrentInterrupt;
    4. uint8_t ucCurrentPriority;
    5. /* Obtain the number of the currently executing interrupt. */
    6. __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) );
    7. /* Is the interrupt number a user defined interrupt? */
    8. if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
    9. {
    10. /* Look up the interrupt's priority. */
    11. ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ];
    12. configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
    13. }
    14. configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) <= ulMaxPRIGROUPValue );
    15. }
    Display All
  • I think the problem was caused by the no initialization of variable ulMaxPRIGROUP before start call

    Source Code

    1. SEGGER_SYSVIEW_Start();

    This variable is only initialized in the function

    Source Code

    1. BaseType_t xPortStartScheduler(void);
    and this function is called when the scheduler is started. In this case, I created a new function, based on xPortStartScheduler, for initializing the variable ulMaxPRIGROUP correctly and call it before the SEGGER_SYSVIEW_Start().

    Until now, everything looks good for me.

    Following the function that was created.

    Source Code

    1. //###########################################################
    2. // Add function below in file portmacro.h
    3. #ifdef configASSERT
    4. void vSetVarulMaxPRIGROUPValue( void );
    5. #endif
    6. //###########################################################
    7. // Add function below in file port.c
    8. #if( configASSERT_DEFINED == 1 )
    9. void vSetVarulMaxPRIGROUPValue( void )
    10. {
    11. volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER );
    12. volatile uint8_t ucMaxPriorityValue;
    13. /* Determine the number of priority bits available. First write to all
    14. possible bits. */
    15. *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE;
    16. /* Read the value back to see how many bits stuck. */
    17. ucMaxPriorityValue = *pucFirstUserPriorityRegister;
    18. /* Calculate the maximum acceptable priority group value for the number
    19. of bits read back. */
    20. ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
    21. while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE )
    22. {
    23. ulMaxPRIGROUPValue--;
    24. ucMaxPriorityValue <<= ( uint8_t ) 0x01;
    25. }
    26. #ifdef __NVIC_PRIO_BITS
    27. {
    28. /* Check the CMSIS configuration that defines the number of
    29. priority bits matches the number of priority bits actually queried
    30. from the hardware. */
    31. configASSERT( ( portMAX_PRIGROUP_BITS - ulMaxPRIGROUPValue ) == __NVIC_PRIO_BITS );
    32. }
    33. #endif
    34. #ifdef configPRIO_BITS
    35. {
    36. /* Check the FreeRTOS configuration that defines the number of
    37. priority bits matches the number of priority bits actually queried
    38. from the hardware. */
    39. configASSERT( ( portMAX_PRIGROUP_BITS - ulMaxPRIGROUPValue ) == configPRIO_BITS );
    40. }
    41. #endif
    42. /* Shift the priority group value back to its position within the AIRCR
    43. register. */
    44. ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT;
    45. ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK;
    46. }
    47. #endif /* conifgASSERT_DEFINED */
    Display All