Timer Interrupt stop working after malloc

ricardo_crudo wrote on Monday, 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()
  /*   when the two below lines are commented, all works fine */
  char *p = pvPortMalloc(16);
  if (p) turn_on_led2();
  // task creations and other setups
void timer1_handler(void)

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?

ricardo_crudo wrote on Monday, 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?

rtel wrote on Monday, 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.


ricardo_crudo wrote on Monday, 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.