Quality RTOS & Embedded Software

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




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists