Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

FreeRTOS in Harmony project on PIC32MZEF crashes when multitasking started

Posted by racarter on June 6, 2017

My dev system: PIC32MZ2048EFM064 processor on Microchip IoT eval board MpLab X v3.60 XC C compiler v1.43 MPLab Harmony v2.03b FreeRTOS9.0.0

I have a small project which requires Ethernet and UART interfaces with TCP/IP stack.

I've created a project using Harmony and configured it as I think looks reasonable. I've increased the total heap available to the RTOS to 200Kb and allocated 4kb to the interrupt stack. The system task stack has 8k words allocated, the main app task stack 4K words, the TCP/IP task stack 2K words.

I've generated code using MHC and added no user code to the project to keep things simple. I have 1 main app task and a second (currently empty) app task, driver libraries for USART, Ethernet and system timers in the system task, and a seperate task for TCP/IP stack. The system task is set as the highest priority (6), TCP/IP is 3 and the main app task is 2.

Every time I run the code it crashes according to the call stack at the start of SYSTasks() with a run time exception when run under the debugger.

To attempt to catch the cause I've added the configASSERT macro to FreeRTOSConfig.h and enabled the MallocFailed and CheckForStackOverfow hooks, but none of these traps the crash in the debugger.

I assume the problem must be caused by some sort of stack/ memory usage problem, but the exact cause is not obvious and I can't trace the call sequence to the crash other than by single stepping to find that the initialisation completes, and as soon as multitasking starts the exception occurs.

Is there something obvious that I've configured incorrectly?

Are there any other tricks I can use to catch the cause of the problem?

My FreeRTOSConfig.h config below: ~~~

define configUSE_PREEMPTION 1
define configUSEPORTOPTIMISEDTASKSELECTION 1
define configUSETICKLESSIDLE 0
define configCPUCLOCKHZ ( 200000000UL )
define configPERIPHERALCLOCKHZ ( 100000000UL )
define configTICKRATEHZ ( ( TickType_t ) 1000 )
define configMAX_PRIORITIES ( 10UL )
define configMINIMALSTACKSIZE ( 512 )
define configISRSTACKSIZE ( 2048 )
define configSUPPORTDYNAMICALLOCATION 1
define configSUPPORTSTATICALLOCATION 0
define configTOTALHEAPSIZE ( ( size_t ) 204800 )
define configMAXTASKNAME_LEN ( 16 )
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 1
define configUSERECURSIVEMUTEXES 0
define configUSECOUNTINGSEMAPHORES 1
define configUSETASKNOTIFICATIONS 1
define configQUEUEREGISTRYSIZE 0
define configUSEQUEUESETS 0
define configUSETIMESLICING 0
define configUSENEWLIBREENTRANT 0
define configENABLEBACKWARDCOMPATIBILITY 0
define configUSETASKFPU_SUPPORT 0

/* Hook function related definitions. */

define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCHECKFORSTACK_OVERFLOW 2
define configUSEMALLOCFAILED_HOOK 1

/* Run time and task stats gathering related definitions. */

define configGENERATERUNTIME_STATS 0
define configUSETRACEFACILITY 0
define configUSESTATSFORMATTING_FUNCTIONS 0

/* Co-routine related definitions. */

define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES 2

/* Software timer related definitions. */

define configUSE_TIMERS 0
define configTIMERTASKPRIORITY
define configTIMERQUEUELENGTH
define configTIMERTASKSTACK_DEPTH
define configUSEDAEMONTASKSTARTUPHOOK 0

/* Misc */

define configUSEAPPLICATIONTASK_TAG 0

/* Interrupt nesting behaviour configuration. */

/* The priority at which the tick interrupt runs. This should probably be kept at 1. */

define configKERNELINTERRUPTPRIORITY 1

/* The maximum interrupt priority from which FreeRTOS.org API functions can be called.
Only API functions that end in ...FromISR() can be used within interrupts. */

define configMAXSYSCALLINTERRUPT_PRIORITY 3

/* Define configASSERT() to disable interrupts and sit in a loop. */

define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

~~~


FreeRTOS in Harmony project on PIC32MZEF crashes when multitasking started

Posted by rtel on June 6, 2017

I'm afraid I'm not familiar enough with the code generated by Harmony. If you have done nothing other than use Harmony to create a project that has not been edited, and that project is failing, then you might be best posting to the Microchip support forum as others may have seen the issue before. If on the other hand you have added your own interrupt service routines, or application code, then perhaps posting some of that code would help identify the issue.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS