Keil arm7 crashes at startup with at91sam7s

I am using the Keil arm7 port to run on atmels at91sam7s256. When I come to the first portRESTORE_CONTEXT (vPortISRStartFirstTask) the following instructions:     __asm{ LDMFD    LR, {R0-R14}^    };     __asm{ NOP        };     __asm{ LDR        LR, [LR, #+60]    }; will load 0xaaaaaaaa into LR(=R14), and then try to load LR from there. I have also access to the IAR port, where the same instruction comes, but of some strange reason R13 and R14 are not loaded! Therefore it works with IAR. I find this very strange. Does anyone have an explanation, and most important of course, how should it be for Keil? Shouldn’t the correct content be on stack first? Where should that be put there the first time? Jokke

Keil arm7 crashes at startup with at91sam7s

The processor is in the wrong mode.  It must be in Supervisor mode when vPortISRStartFirst is called. My guess is that you are using the startup code from the FreeRTOS download when you are running using IAR, but not using something other than that included in the download when running using Keil. Take a look at the startup code from the downloaded .zip file for the keil demo.  This will show you what you need. (unless the mode is set using the IDE for Keil?) This is a common mistake which is why the code is littered with comments saying that the processor must be in Supervisor mode when the scheduler is started ;-) [as is the WEB documentation].

Keil arm7 crashes at startup with at91sam7s

OK, I made an attempt to put it in the right mode, but apparently I failed. Thanks Jokke