Quality RTOS & Embedded Software

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


Loading

Timer Interrupt stop working after malloc

Posted by Ricardo Crudo on August 19, 2013
I am using the FreeRTOS V7.4.2 with ARM-CM3 port (NXP LPC1788) and GCC cross compiler.

Below is a pseudo code to reproduce my trouble:


void main()
{
setup_timer1_with_interrupt_1ms();

/* when the two below lines are commented, all works fine */
char *p = pvPortMalloc(16);
if (p) turn_on_led2();

while(1);

the_function();

// task creations and other setups

vTaskStartScheduler();

}

void timer1_handler(void)
{
count_until_500_and_toggle_led1();
}


When I run this piece of code the led1 don't blink and the led2 turn on, but when I comment the malloc line the led1 blink, so, the Time1 interrupt stop working after allocate memory. I knew that malloc disable/re-enable the interrupts, so, Is possible that re-enable is not restoring the interrupts properly?

RE: Timer Interrupt stop working after malloc

Posted by Ricardo Crudo on August 19, 2013
I noticed that after the scheduler is started the interrupt works properly. Is not possible use the interrupts while the scheduler is not running, even with timer priority out of configMAX_SYSCALL_INTERRUPT_PRIORITY range?

RE: Timer Interrupt stop working after malloc

Posted by Richard on August 19, 2013
We always recommend leaving interrupts disabled until the scheduler has started, and, as your found out, if you call certain (most) API functions before the scheduler has started then interrupts will be left masked when the API function exits. Interrupts will automatically be enabled when the scheduler starts.

However, I would only expect interrupts below configMAX_SYSCALL_INTERRUPT_PRIORITY to be masked.

Regards.

RE: Timer Interrupt stop working after malloc

Posted by Ricardo Crudo on August 19, 2013
Thanks for your reply Richard.

My timer1 interrupt don't use FreeRTOS API. I found a post with exact same situation that I am facing: http://www.embeddedrelated.com/groups/AT91SAM/show/4236.php, and I guess that solution response it's yours.

My Makefile use -mthumb for all sources files, but I gotten a error when I tried use the -marm flag in gcc (target CPU does not support ARM mode). And the -mthumb-interwork flag, build fine, but don't work too.

Regards


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner