Hello, I am running freeRTOS together with LWIP on a SAME70Q19. I implemented freeRTOS out of the ASF in my AtmelStudio 7.0.
My Problem: When I create a new task, my application stucks in the Function vTaskStartScheduler(): Subfunction: xPortStartScheduler() Subfunction prvPortStartFirstTask() From here the application jumps with hardfault error to the dummy interrupt handler. I noticed that this must be a problem with the heap memory. When I increase configTOTALHEAPSIZE to 40000 I cannot receive CAN messages any longer. Although the application jumps into the RX Interrupt, the Mailboxes stay empty (0x00) When I decrease the Heap size, I receive proper data. Very strange to me!! I am using heap4.c and I configured freeRTOS as following:
/* Co-routine definitions. */
/* Software timer definitions. */
/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */
/* FreeRTOS+CLI definitions. */
/* Dimensions a buffer into which command outputs can be written. The buffer can be declared in the CLI code itself, to allow multiple command consoles to share the same buffer. For example, an application may allow access to the command interpreter by UART and by Ethernet. Sharing a buffer is done purely to save RAM. Note, however, that the command console itself is not re-entrant, so only one command interpreter interface can be used at any one time. For that reason, no attempt at providing mutual exclusion to the buffer is attempted. */
/* Cortex-M specific definitions. */
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ #define configPRIO_BITS __NVIC_PRIO_BITS
#define configPRIO_BITS 4 /* 15 priority levels */
/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
/* 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. */
/* 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. */
/* Normal assert() semantics without relying on the provision of an assert.h header file. */
My Tasks are:
~~~ xTaskCreate(taskled, "test", TASKLEDSTACKSIZE, NULL, TASKLEDSTACK_PRIORITY, NULL);
xTaskCreate(CAN_to_ETH_TASK, "CANTOETH", TASK_CAN_TO_ETH_STACK_SIZE, NULL, TASK_CAN_TO_ETH_STACK_PRIORITY, NULL); xTaskCreate(CAN0_Task, "CAN0", CAN_TASK_STACK_SIZE, NULL, CAN_TASK_STACK_PRIORITY, NULL); xTaskCreate(vStartEthernetTask, "ETHLAUNCH", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 4, NULL);
~~~ Here the defines: ~~~
/*! define stack size for WEB server task */
/*! define stack size for TFTP server task */
/*! define stack size for SMTP Client task */
/*! define stack size for lwIP task */
/*! define stack size for netif task */
/*! define WEB server priority */
/*! define TFTP server priority */
/*! define SMTP Client priority */
/*! define lwIP task priority */
/*! define netif task priority */
Can somebody help me with this issue? How much Heap should I use? How is it possible that the CAN-Bus doesn't receive messages any longer with greater heap size? Why can't I add new Tasks without jumping into hard fault error? I am looking forward to your answers.
First question. You say the first task doesn't start unless you set the heap to 40000. Does that mean that with this change to the heap size the first task does start, and the system runs ok other than the CAN interrupts?
Have you ever seen the CAN interrupts working, and if so, is it only when you use FreeRTOS that they don't work?
If the CAN interrupts only don't work when you are using FreeRTOS, are you talking about them not working before the scheduler starts or after the scheduler starts?