2017-10-27 3 views
1

작업 지연 기능이나 타이머 기간을 사용할 때 두 가지 타이밍이 원하는 것보다 두 배 빠르기 때문에 현재 freertos 설정에 실수가 있어야합니다.freertos tick factor 2가 stm32f4xx에서 너무 빠름

  1. DEBUG 변수 : 난 아직 선택이 무엇

    이 세 부분이 틱 증가에 포함 (TIMER IRQ 핸들러, FREERTOS TICK HANDLER, FREERTOS TICK의 HOOK)은 10 초당 10'000 타이머라고합니다. 지금까지는 괜찮습니다.

  2. TASK 및 TIMER 기간 : 기간에 2를 곱하면 타이밍은 정상이며 지금까지는 만족스럽지 않습니다.
  3. Freertos 구성 : SystemClockCore는 168MHz입니다. 틱은 초당 1000 틱으로 설정됩니다. 구성에 어딘가에 실수가 있습니까?

나는 누군가가 나를이 문제를 일으키는 원인이 될 수 있기를 바랍니다. 추신 : 시스템 틱이 현재 너무 느리게 실행되고 있지만이 문제는 현재 사용하지 않은 이후로는 걱정하지 않습니다. 영향을 미친다. STM32F4에

// DEBUG VARIABLES 
DEBUG_CT DEBUG_CLOCK_TICK_T {...} 
    DEBUG_CT_ISR_SYSTEM_TICK  uint32_t 65 // IS NOT USED 
    DEBUG_CT_ISR_TIM_TICK   uint32_t 10036 
    DEBUG_CT_FREERTOS_HOOK_TICK  uint32_t 10036 
    DEBUG_CT_FREERTOS_TICK_HANDLER uint32_t 10036 

// FREERTOS TICK HANDLER 
#ifdef DEBUG_CLOCK_TICK 
DEBUG_CT.DEBUG_CT_FREERTOS_TICK_HANDLER++; 
#endif 
xPortSysTickHandler(); 

// THREAD DELAY 
void delay(uint32_t ms) 
{ 
    M_ASSERT_BOOL(_created); 
    ms *= 2; // !!! CORRECTION, WHY ??? 
    vTaskDelay(ms/portTICK_PERIOD_MS); 
} 

// TIMER CREATION 
_handle = xTimerCreateStatic(
    _name, 
    pdMS_TO_TICKS(_msDelay*2), // !!! CORRECTION, WHY ??? 
    autoreload, 
    (void*)_name, 
    _expired, 
    &_timerBuffer); 

// PORTMACRO.H 
#define portSTACK_GROWTH   (-1) 
#define portTICK_PERIOD_MS   ((TickType_t) 1000/configTICK_RATE_HZ) 
#define portBYTE_ALIGNMENT   8 

// FREERTOS CONFIG 
#define configUSE_PREEMPTION      1 
#define configSUPPORT_STATIC_ALLOCATION   1 
#define configSUPPORT_DYNAMIC_ALLOCATION   0 
#define configUSE_IDLE_HOOK      1 
#define configUSE_TICK_HOOK      1 
#define configCPU_CLOCK_HZ      (SystemCoreClock) 
#define configTICK_RATE_HZ      ((TickType_t)1000) 
#define configMAX_PRIORITIES      (7) 
#define configMINIMAL_STACK_SIZE     ((uint16_t)32) 
#define configMAX_TASK_NAME_LEN     (32) 
#define configUSE_16_BIT_TICKS     0 
#define configUSE_MUTEXES      1 
#define configQUEUE_REGISTRY_SIZE    8 
#define configCHECK_FOR_STACK_OVERFLOW   1 
#define configUSE_MALLOC_FAILED_HOOK    1 
#define configUSE_DAEMON_TASK_STARTUP_HOOK  1 
#define configENABLE_BACKWARD_COMPATIBILITY  0 
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 
#define configUSE_TICKLESS_IDLE     1 

/* Co-routine definitions. */ 
#define configUSE_CO_ROUTINES     0 
#define configMAX_CO_ROUTINE_PRIORITIES   (2) 

/* Software timer definitions. */ 
#define configUSE_TIMERS       1 
#define configTIMER_TASK_PRIORITY    (2) 
#define configTIMER_QUEUE_LENGTH     10 
#define configTIMER_TASK_STACK_DEPTH    256 

/* 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    1 
#define INCLUDE_vTaskDelay     1 
#define INCLUDE_xTaskGetSchedulerState  1 
#define INCLUDE_pcTaskGetTaskName   1 
#define INCLUDE_xTaskGetCurrentTaskHandle 1 
#define INCLUDE_eTaskGetState    1 
#define INCLUDE_xTaskGetHandle    1 

/* 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 
#endif 

/* The lowest interrupt priority that can be used in a call to a "set priority" 
function. */ 
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 

/* 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)) 

/* Normal assert() semantics without relying on the provision of an assert.h 
header file. */ 
/* USER CODE BEGIN 1 */ 
#define configASSERT(x) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for(;;);} 
/* USER CODE END 1 */ 

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS 
standard names. */ 
#define vPortSVCHandler SVC_Handler 
#define xPortPendSVHandler PendSV_Handler 

/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware, 
       to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ 
/* #define xPortSysTickHandler SysTick_Handler */ 

/* USER CODE BEGIN Defines */    
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ 
/* USER CODE END Defines */ 

#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) 
void PreSleepProcessing(uint32_t *ulExpectedIdleTime); 
void PostSleepProcessing(uint32_t *ulExpectedIdleTime); 
#endif /* defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) */ 

/* The configPRE_SLEEP_PROCESSING() and configPOST_SLEEP_PROCESSING() macros 
allow the application writer to add additional code before and after the MCU is 
placed into the low power state respectively. */ 
#if configUSE_TICKLESS_IDLE == 1 
#define configPRE_SLEEP_PROCESSING      PreSleepProcessing 
#define configPOST_SLEEP_PROCESSING      PostSleepProcessing 
#endif /* configUSE_TICKLESS_IDLE == 1 */ 

#endif /* FREERTOS_CONFIG_H */ 

답변

0

FreeRTOS는 보통 OS 틱 타이머를 생성하는 타이머로서 SysTick을 사용하도록 구성된다. 그러나 올바르게 설정하면 원하는 타이머를 사용할 수 있습니다.

SysTick이 절반의 속도로 실행 중이면 주 클럭 (예 : 168MHz)이 실행될 때 문제가 설명되어야합니다.

이 경우에는 PLL이 잘못 구성되어 있고 주 클럭 주파수가 168MHz가 아닌 168MHz/2 (또는 다른 시계를 사용하고 있습니다)라고 생각합니다.

아마도 더 쉽게 작업을 수행 할 수 있기 때문에이 데모를 사용하지 않는 것이 좋습니다.

+0

안녕하세요, 귀하의 의견에 감사드립니다. 예, STMCubeMX는 기본적으로 Cortex M System Tick을 사용하여 FreeRTOS SystemTick Handler를 증가 (또는 호출)합니다. 앞서 언급 한 것처럼 다른 경우에는 틱 소스를 사용할 수 있습니다. 내 경우에는 하드웨어 타이머와 같습니다. 아니요, 하드웨어 타이머에 의해 호출 된 FreeRTOS SysTick 핸들러는 올바르게 1000x/초로 호출합니다. 이것은 증명되었습니다. 그래서 문제는 여전히 남아 있습니다. 왜 RTOS 속도가 너무 빠릅니까? (PS : TickLess idle은 현재 빈 훅 콜백입니다. 아직 구현하지 않았습니다.) –

+0

STM32F4를주의 깊게 살펴볼 또 다른 사항은 하나의 버스에는 타이머가 있고 다른 하나는 컨트롤러 블록 다이어그램을 보는 것입니다. 버스 중 하나는 다른 속도의 두 배 속도로 작동합니다 (타이머는 버스 속도의 두 배 속도를냅니다. 따라서 한 세트의 타이머가 168MHz에서 실행되고 다른 하나는 168MHZ/2에서 실행됩니다) –

+0

안녕하세요, 귀하의 답변에 감사드립니다. 좋아, 내가 돌볼거야! 것은 나의 타이머가 10 초당 1000 번 또는 1 초당 1000 타이머가 만료되고 그 콜백 루틴에서 FreeRtosTickHandler가 올바르게 호출된다는 것을 측정 한 것입니다 ... 그래서 이것은 괜찮습니다. –

관련 문제