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] [December 2007 Threads] Task seems to stop at 2nd callPosted by Wildcard on December 31, 2007 Hello, i finally got the RTOS Code running on my SAM7S256 using gcc-tools. I tried a simple test, by having 2 processes writing to the UART.
..... printf("Task a creation %d \r", xTaskCreate(( void * ) test_taskA, ( signed portCHAR * ) "Task A", 500, NULL, 3, NULL )); printf("Task b creation %d \r", xTaskCreate(( void * ) test_taskB, ( signed portCHAR * ) "Task B", 500, NULL, 3, NULL )); vTaskStartScheduler();
.....
static void test_taskA(void) { int i; while(1) { // taskENTER_CRITICAL(); // no solution :/ uart0_putc('a'); // taskEXIT_CRITICAL(); for(i=0;i<0xfffff;i++); } }
.....
static void test_taskB(void) { int i; while(1) { uart0_putc('b'); for(i=0;i<0xfffff;i++); } }
The output is as follows:
" Task a creation 1 Task b creation 1 bbbbbbbbbbbbbaaaaaaaaaaa"
The MCU hangs now and is in an "Prefetch Abort exception" endless loop. I tried different startup codes (for Mode stack init ...) with the same result.
What could be the Problem? Thank you very much!
RE: Task seems to stop at 2nd callPosted by Wildcard on December 31, 2007 Okey, finally i got the command which causes the prefetch abort. It's in the portRESTORE_CONTEXT() macro in portmacro.h.
#define portRESTORE_CONTEXT()\ {\ extern volatile void * volatile pxCurrentTCB;\ extern volatile unsigned portLONG ulCriticalNesting;\ \ /* Set the LR to the task stack. */\ asm volatile (\ "LDRR0, =pxCurrentTCB\n\t"\ "LDRR0, [R0]\n\t"\ "LDRLR, [R0]\n\t"\ \ /* The critical nesting depth is the first item on the stack. */\ /* Load it into the ulCriticalNesting variable. */\ "LDRR0, =ulCriticalNesting\n\t"\ "LDMFDLR!, {R1}\n\t"\ "STRR1, [R0]\n\t"\ \ /* Get the SPSR from the stack. */\ "LDMFDLR!, {R0}\n\t"\ "MSRSPSR, R0\n\t"\ \ /* Restore all system mode registers for the task. */\ "LDMFDLR, {R0-R14}^\n\t"\ "NOP\n\t"\ \ /* Restore the return address. */\ "LDRLR, [LR, #+60]\n\t"\ \ /* And return - correcting the offset in the LR to obtain the */\ /* correct address. */\ "SUBSPC, LR, #4\n\t"\ );\ ( void ) ulCriticalNesting;\ ( void ) pxCurrentTCB;\ }
Here the prefetchabort occours: http://cashfox.net/prefetchabort.JPG
Can anyone help me now? Thank you!
RE: Task seems to stop at 2nd callPosted by Wildcard on December 31, 2007 Okey i found a SOLUTION :) I used the startup and linker file from the SAM7X - Eclipse Sample Projekt. I think the Problem is, that my old startup code did support nested interrupts.
But can someone help me with an explanation what could go wrong if the startupcode supports nested interrupts?
RE: Task seems to stop at 2nd callPosted by Richard on December 31, 2007 The startup code must either configure the IRQ handler to vector directly to the interrupt handler or vector to a common entry point that contains the context saving code. Examples are provided of both methods. In either case the first code executed after the jump must be the FreeRTOS.org context save code, not any compiler provided intermediary code. This is to ensure that the task finds the stack in exactly the state it expects when exiting an ISR.
The main reason for this is that a task can be placed into the blocked state from a call to Yield at the task level, but start executing again after being moved out of the blocked state within an ISR. In both cases it needs to have the stack popped back into the registers in exactly the same way.
You can implement nesting of interrupts by modifying the code after the saving of the context only. It is unlikely that nesting of interrupts would be required though. See http://www.freertos.org/FAQISR.html#Nest for more info.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|