lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] stm32 ethernet interrup priority


From: Noam Weissman
Subject: Re: [lwip-users] stm32 ethernet interrup priority
Date: Mon, 22 Aug 2016 13:40:15 +0000

Hi Erkan,

 

This is what I am using, a modified ST example with FreeRTOS 8.x

 

For example this is how ETH is set:

 

void ETH_IRQConfig(void)

{

  NVIC_InitTypeDef NVIC_InitStructure;

 

  // Configures and enable the Ethernet global interrupt.

  NVIC_InitStructure.NVIC_IRQChannel = ETH_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = ETH_ISR_PRIO;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);   

}

 

 

 

This is my OS config with ISR priorities etc…

Sorry for the alignment it’s the mail editor.

 

 

/*

 

#ifndef FREERTOS_CONFIG_H

#define FREERTOS_CONFIG_H

 

/*-----------------------------------------------------------

* Application specific definitions.

*

* These definitions should be adjusted for your particular hardware and

* application requirements.

*

* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE

* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.

 *

* See http://www.freertos.org/a00110.html.

*----------------------------------------------------------*/

 

#define configUSE_PREEMPTION                       1

#define configUSE_IDLE_HOOK                  0

#define configUSE_TICK_HOOK                  0

#define configCPU_CLOCK_HZ        ( ( unsigned long ) 168000000 )        

#define configTICK_RATE_HZ          ( ( portTickType ) 1000 )

#define configMAX_PRIORITIES               ( ( unsigned portBASE_TYPE ) 20 )

#define configMINIMAL_STACK_SIZE   ( ( unsigned short ) 200 )

#define configTOTAL_HEAP_SIZE                       ( ( size_t ) (55 * 1024 ) )

#define configMAX_TASK_NAME_LEN                        ( 20 )

#define configUSE_TRACE_FACILITY  0

#define configUSE_16_BIT_TICKS                     0

#define configIDLE_SHOULD_YIELD                1

#define configUSE_MUTEXES               1

#define configUSE_COUNTING_SEMAPHORES   1

#define configUSE_MALLOC_FAILED_HOOK    0

 

#define configUSE_RECURSIVE_MUTEXES 0

 

 

#define configUSE_TIMERS                  1

#define configTIMER_QUEUE_LENGTH      20

#define configTIMER_TASK_STACK_DEPTH  configMINIMAL_STACK_SIZE

#define configTIMER_TASK_PRIORITY     ( tskIDLE_PRIORITY + 4 )

 

// for plugin

//#define configQUEUE_REGISTRY_SIZE 6

 

/* Co-routine definitions. */

#define configUSE_CO_ROUTINES                  0

#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

 

/* Set the following definitions to 1 to include the API function, or zero

to exclude the API function. */

 

#define INCLUDE_vTaskPrioritySet                      1

#define INCLUDE_uxTaskPriorityGet                   1

#define INCLUDE_vTaskDelete                                 1

#define INCLUDE_vTaskCleanUpResources   0

#define INCLUDE_vTaskSuspend                                      1

#define INCLUDE_vTaskDelayUntil                                  0

#define INCLUDE_vTaskDelay                        1

#define INCLUDE_xTaskGetCurrentTaskHandle 1

 

 

 

 

/*The table below gives the allowed values of the pre-emption priority and subpriority according

  *  to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function

  *    ==========================================================================================================================

  *      NVIC_PriorityGroup   | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority  |       Description

  *    ==========================================================================================================================

  *     NVIC_PriorityGroup_0  |                0                  |            0-15             | 0 bits for pre-emption priority

  *                           |                                   |                             | 4 bits for subpriority

  *    --------------------------------------------------------------------------------------------------------------------------

  *     NVIC_PriorityGroup_1  |                0-1                |            0-7              | 1 bits for pre-emption priority

  *                           |                                   |                             | 3 bits for subpriority

  *    --------------------------------------------------------------------------------------------------------------------------   

  *     NVIC_PriorityGroup_2  |                0-3                |            0-3              | 2 bits for pre-emption priority

  *                           |                                   |                             | 2 bits for subpriority

  *    --------------------------------------------------------------------------------------------------------------------------   

  *     NVIC_PriorityGroup_3  |                0-7                |            0-1              | 3 bits for pre-emption priority

  *                           |                                   |                             | 1 bits for subpriority

  *    --------------------------------------------------------------------------------------------------------------------------   

  *     NVIC_PriorityGroup_4  |                0-15               |            0                | 4 bits for pre-emption priority

  *                           |                                   |                             | 0 bits for subpriority                       

  *    ==========================================================================================================================

*/

 

#define IRQ_SYS_PRIORITY_MODEL  NVIC_PriorityGroup_4

 

 

/* Cortex-M specific definitions. */

#ifdef __NVIC_PRIO_BITS

            /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */

            #define configPRIO_BITS                         __NVIC_PRIO_BITS

#else

            #define configPRIO_BITS                         4        /* 15 priority levels */

#endif

 

/* The lowest interrupt priority that can be used in a call to a "set priority"

function. */

#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY                                   0xF

 

/* The highest interrupt priority that can be used by any interrupt service

routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL

INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER

PRIORITY THAN THIS! (higher priorities are lower numeric values. */

#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY           5

 

/* Interrupt priorities used by the kernel port layer itself.  These are generic

to all Cortex-M ports, and do not rely on any particular library functions. */

#define configKERNEL_INTERRUPT_PRIORITY                   ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!

See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */

#define configMAX_SYSCALL_INTERRUPT_PRIORITY      ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

 

 

#define ADC3_DMA_ISR_PRIO      (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 6)

#define ETH_ISR_PRIO           (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 5)

#define IR_TIMERS_ISR_PRIO     (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 2)

#define SERIAL_ISR_PRIO        (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1)

 

 

#endif /* FREERTOS_CONFIG_H */

 

 



From: lwip-users [mailto:lwip-users-bounces+address@hidden On Behalf Of Erkan Ersoy
Sent: Monday, August 22, 2016 3:00 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] stm32 ethernet interrup priority

 

Thank you Noam;

 

Somethings are confusing but i think i get it 

 

So I shouldn't use priority higher than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY value which is 5 by defult.

cortexM3 have priority 0 to 255 but ST uses 0 to 15. 

Confusing part is ST used those defines

 

#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

 

those values are 

configKERNEL_INTERRUPT_PRIORITY : 240

configMAX_SYSCALL_INTERRUPT_PRIORITY: 80

 

but they never used those defines so they used only values above 5 without defines. Those defines stay there idle.

 

I use 6 for ethernet interrupt and 7 for USART interrupt now it seems work fine

 

On Monday, August 22, 2016 11:51 AM, Jan Menzel <address@hidden> wrote:

 

Hi Erkan!
    Despite interrupt priorities, system freezes are usually an indication
for badly designed interrupt handlers. Interrupt handler shall only do
necessary things and execute as fast as possible. In some designs I've
see interrupt handler do as little as only wakeup a task that to do the
actual work.
    Next, FreeRTOS splits the available interrupt priorities into two
classes. In the lower one RTOS functions may be executed like waking up
a task or sending data using a queue, while in the higher class RTOS
functions are not allowed. The lower class interrupts are sometimes
blocked by certain RTOS functions and hence provide less precise
response behaviour. The higher class is never blocked and therefore
executes immediately if there is no other interrupt of same of higher
priority currently active. The classes are defined by
"configMAX_SYSCALL_INTERRUPT_PRIORITY"
    Finally, systemtick handler is usually running at lowest priority. All
it does is count ticks, watch for sleeping tasks and cycle tasks of same
priority. If that does not happen for you, you're back at the beginning,
badly designed interrupt handlers...

    Jan


On 20.08.2016 11:54, Erkan Ersoy wrote:
> Hello;
>
> I am trying to implement usart interrupt to my project
>
> So iread freertos stm32 interrupt warnings and set i lilk that
>
> /* Enable the Ethernet global Interrupt */
> NVIC_InitStructure.NVIC_IRQChannel = ETH_IRQn;
> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =2;
> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
> NVIC_Init(&NVIC_InitStructure);
>
> //USART 5 interrupt
> NVIC_InitTypeDef NVIC_InitStruct;
> NVIC_InitStruct.NVIC_IRQChannel = UART5_IRQn;
> NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
> NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority =
> configMAX_SYSCALL_INTERRUPT_PRIORITY;
> NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1;
> NVIC_Init(&NVIC_InitStruct);
>
> But I begin to have system freezes so i changed it like that
>
> /* Enable the Ethernet global Interrupt */
> NVIC_InitStructure.NVIC_IRQChannel = ETH_IRQn;
> NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =
> configMAX_SYSCALL_INTERRUPT_PRIORITY;
> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
> NVIC_Init(&NVIC_InitStructure);
>
> //USART 5 interrupt
> NVIC_InitTypeDef NVIC_InitStruct;
> NVIC_InitStruct.NVIC_IRQChannel = UART5_IRQn;
> NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
> NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority =
> configMAX_SYSCALL_INTERRUPT_PRIORITY;
> NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1;
> NVIC_Init(&NVIC_InitStruct);
>
> Now I don't have a problem. The diffference is ethernet interrupts. I
> didnt have a problem until i added the usart interrupt. And I look at
> ST's freertos examples they set it to 2.
>
> is there something wrong with my current code that will cause problem in
> the future?
> (I will move UART5 task to USART1 after I finish writing functionality)
>
> Thank you


>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

 

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]