Quality RTOS & Embedded Software

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


xTaskCreate in an interrupt

Posted by malcolmsmc on October 10, 2017

I am currently using the FreeRTOS in a project using a PIC32MX. It all worked properly until I added an xTaskCreate from inside an interrupt routine. The system crashed!.

The created task started with an xTaskDelay and although it reached this function it never returned but failed on an address problem.

/* Task started. */

static void downloadtask( void *param ) {     uint8t     result;     BFRHANDLE  bfr;     uint16t    cChr;     uint8t     retry;     uint8t     schar = 0;

    vTaskDelay( DOWNLOADDELAYTO_START );     fileClean( 1 );     .............

I WILL find a way round my problem but it would be interesting to know if there is a known problem.

Regards Malcolm

Technical Manager (R&D) ENS Group Orpheus House Calleva Park Aldermaston Berks RG7 8TA UK

Email: malcolm@smc-electronics.co.uk Web: www.smc-electronics.co.uk Web: www.ens-group.co.uk

This email has been checked for viruses by AVG. http://www.avg.com

xTaskCreate in an interrupt

Posted by rtel on October 10, 2017

There is a simple rule of thumb (which doesn't hold in all cases, but is easy to state and follow): Do not call any API function that doesn't end if 'FromISR' from an interrupt.

That is particularly true of xTaskCreate(), which will allocate memory.

If you want to create a task from an interrupt then use one of the deferred interrupt handling techniques, or use xTimerPendFunctionCallFromISR() http://www.freertos.org/xTimerPendFunctionCallFromISR.html

I would recommend reading the book, its free, and won't take long: http://www.freertos.org/Documentation/RTOS_book.html

xTaskCreate in an interrupt

Posted by malcolmsmc on October 11, 2017

Many thanks. My problem was using the taskENTERCRITICAL/taskEXITCRITICAL inside an interrupt.

I noted your comments and changed to starting the task then suspended it. Whan I wanted to use it I just did an xTaskResumeFromISR to activate it.

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

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

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

FreeRTOS kernel V10.0.1 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