FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2015 Threads] Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by ajienikicio on March 19, 2015 Hi,
I'm having a problem of a crash whenever a FromISR function is called in my TWI0_Handler(). I have followed the interrupt priority rule as mentioned here (and tried different numbers) http://www.freertos.org/RTOS-Cortex-M3-M4.html but the problem persists.
So configLIBRARYMAXSYSCALLINTERRUPTPRIORITY is set to 5 and configLIBRARYLOWESTINTERRUPT_PRIORITY is set to 0x0f (as in Demo for SAM3X). And this is how the interrupt is initialized:
NVIC_SetPriorityGrouping( 0 );
NVIC_DisableIRQ(TWI0_IRQn);
NVIC_ClearPendingIRQ(TWI0_IRQn);
NVIC_SetPriority(TWI0_IRQn, 6);
NVIC_EnableIRQ(TWI0_IRQn);
and this is the TWI ISR:
void TWI0Handler()
{
int status = twigetinterruptstatus(TWI0);
portBASE_TYPE xTaskWoken = pdFALSE;
printf("entered testISRn");
xSemaphoreGiveFromISR( testHandle, &xTaskWoken ); // hangs here
printf("passed fromISR\n");
portEND_SWITCHING_ISR( xTaskWoken );
}
Do I miss anything here?
Thank you very much for your help!
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by davedoors on March 19, 2015 Can you try again without the printf() in the ISR.
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by ajienikicio on March 19, 2015 Just tried and it still crashed at the same place
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by davedoors on March 19, 2015 Did you remove both printfs? Which version of FreeRTOS are you using? Have you defined configASSERT()? Is taskHandle valid? When you step into the function where does the crash happen?
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by ajienikicio on March 19, 2015 Yes I removed both printfs and it crashed again.
I'm not familiar with configASSERT, do I have to define it by myself? I found some lines related to it in the FreeRTOS source codes such as this in the FreeRTOSConfig.h:
define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
and in FreeRTOS.h:
ifndef configASSERT
#define configASSERT( x )
#define configASSERT_DEFINED 0
else
#define configASSERT_DEFINED 1
endif
taskHandle is just a SemaphoreHandle_t defined globally.
The crash happens at xSemaphoreGiveFromISR( testHandle, &xTaskWoken ). This problem also happened with xQueueSendToBackFromISR.
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by rtel on March 19, 2015 Here is the link to configASSERT() info:
http://www.freertos.org/a00110.html#configASSERT
You define it in FreeRTOSConfig.h - it can do what you want as long as
you know it has been called. The normal thing to do is disable
interrupts and sit in a loop, as per your post, so when you break the
debugger you can see it is sat on a configASSERT() statement. There are
more elaborate schemes you can implement - but the simpler the better I
think.
Generally calling printf() in an interrupt is not recommended.
The crash happens at xSemaphoreGiveFromISR( testHandle, &xTaskWoken ).
I think the intention was for you to find out where inside the function
the crash happens. If you place a break point on the line, then step
into the function in the debugger you should be able to see why the
crash happens.
Regards.
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by ajienikicio on March 23, 2015 Hi!
I had confirmed that there was no configASSERT() called and I just found out the problem :).
After looking at the FreeRTOS Demo Application again, I noticed that the Demo sets configTOTALHEAPSIZE as 40960, while I had 8096. After setting it to 40960, the problem disappeared. But I don't understand why the value was causing the problem.
Problem with FromISR functions and TWI Interrupt using Atmel SAM3XPosted by rtel on March 23, 2015 If you run out of heap then queues, semaphores, event groups, tasks,
etc. cannot be created - and the return value of the function used to
create the object will return pdFAIL. Are you checking the return
values of such functions - or any direct call to pvPortMalloc().
You can also define a malloc failed hook
function to get notification that the heap was exhausted.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|