ophelieadveez wrote on Wednesday, April 26, 2017:
Hi,
I’m working on IAR. I’m using FreeRTOS v9.0.0 on a STM32F417 microcontroller.
I encounter problems when I declare and use float variables and double variables.
The following code causes an Hardfault Handler.
void vTestTask(void *pvParameters)
{
for(;;)
{
float test;
test = (float)(0x22);
vTaskDelay(2000U);
}
}
Some details:
- I use heap 4.
- MCU frequency 16MHz
- Operating system used the systick
- FPU is activated.
- The heap is located in the RTOS_RESERVED region, which is located in the CCRAM (see the linker file above).
- The hardfault doesn’t occur when I write this code outside the task.
- The hardfault occurs when vTaskDelay function ends, so it seems it’s when the context task is restored.
Could you give me some hint please ?
Please find abovemy FreeRTOSConfig.h file and the linker file.
Regards,
Ophélie
Linker file:
/###ICF### Section handled by ICF editor, don’t touch! /
/-Editor annotation file-/
/ IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" /
/-Specials-/
define symbol ICFEDIT_intvec_start = 0x08000000;
/-Memory Regions-/
define symbol ICFEDIT_region_ROM_start = 0x08000000;
define symbol ICFEDIT_region_ROM_end = 0x080DFFFF;
define symbol ICFEDIT_region_RAM_start = 0x20000000;
define symbol ICFEDIT_region_RAM_end = 0x2001FAFF;
define symbol ICFEDIT_region_CCMRAM_start = 0x10000000;
define symbol ICFEDIT_region_CCMRAM_end = 0x1000FFFF;
/-Sizes-/
define symbol ICFEDIT_size_cstack = 0x500;
define symbol ICFEDIT_size_heap = 0x00;
/*** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from ICFEDIT_region_ROM_start to ICFEDIT_region_ROM_end];
define region RAM_region = mem:[from ICFEDIT_region_RAM_start to ICFEDIT_region_RAM_end];
define region CCMRAM_region = mem:[from ICFEDIT_region_CCMRAM_start to ICFEDIT_region_CCMRAM_end];
define block CSTACK with alignment = 8, size = ICFEDIT_size_cstack { };
define block HEAP with alignment = 8, size = ICFEDIT_size_heap { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:ICFEDIT_intvec_start { readonly section .intvec };
place in ROM_region { readonly };
place in CCMRAM_region { readwrite data section RTOS_RESERVED_RAM };
place in RAM_region { readwrite, block CSTACK, block HEAP};
FreeRTOSCongig.h:
#ifdef __ICCARM__
#include "system_stm32f4xx.h"
extern void assert_failed(uint8_t* file, uint32_t line); /* Function prototype defined in errorUtils.h */
#endif
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_TICKLESS_IDLE 1
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 5
#define configCPU_CLOCK_HZ SystemCoreClock
#define configTICK_RATE_HZ 100
#ifdef NDEBUG
/* TODO : remove NDEBUG once we have real board : if we remove it we lost debug, but with right SWD connection it should work */
#define configSYSTICK_CLOCK_HZ SystemCoreClock/8
#endif
#define configMAX_PRIORITIES 10
#define configMINIMAL_STACK_SIZE 128
#define configMAX_TASK_NAME_LEN 16
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */
#define configQUEUE_REGISTRY_SIZE 40
#define configUSE_QUEUE_SETS 1
#define configUSE_TIME_SLICING 0
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
#define configUSE_APPLICATION_TASK_TAG 0
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE (17 * 1024)
#define configAPPLICATION_ALLOCATED_HEAP 1
/* Hook function related definitions. */
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#ifndef NDEBUG
#define configCHECK_FOR_STACK_OVERFLOW 2
#else
#define configCHECK_FOR_STACK_OVERFLOW 0
#endif
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
/* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY 5
#define configTIMER_QUEUE_LENGTH 5
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
/* 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 nesting behaviour configuration. */
/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4 /* 15 priority levels - __NVIC_PRIO_BITS value is 4 */
#endif
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* Define to trap errors during development. */
#define configASSERT( x ) if( ( x ) == 0 ) { assert_failed(__FILE__, __LINE__); }
/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_xResumeFromISR 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_eTaskGetState 0
#define INCLUDE_xEventGroupSetBitFromISR 1
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 0
#define INCLUDE_xTaskGetHandle 0
#define INCLUDE_xTaskResumeFromISR 1