Hi, I’m trying to compile and debug FreeRTOS port Demo/ARM7_LPC2106_GCC in Keil. I copied all files, including boot.s and lpc2106-rom into a new project. Project compiles fine, saying:
It continues uploading, but program doesn’t work at all (I’ve put some simple blinking on very beginning).
When I use different startup.s and target.ld from ‘c:\Keil\ARM\GNU\Examples\Blinky’ I can upload and debug it in Keil, and everything seem fine till I enable a interrupt from TMR0, it hops then to some messy area. I’m pretty sure interrupt initialisation is OK, because I took it from my recent project and it works fine there (the problem is, that that recent project I compiled in Keils native compiler - not using GCC)
So I think it’s something to do with .s, or .ld files. Especialy interrupts handling definition. But WHAT???
Also make sure you are calling main() in Supervisor mode, and have setup the IRQ and Supervisor mode stacks. The user mode stacks get setup by individual tasks so no need to worry about those.
I believe I’ve setup the stacks correctly, but I don’t have a clue what do You mean by supervisor mode??? There is nothing about it in LPC2129’s datasheet and in forum I haven’t found anything useful… I suppose It should be done in startup.s, right, but HOW?
You will not be able to disable interrupts unless you are in Supervisor mode. The modes the processor operates in are part of the ARM7 code, which the LPC2129 uses. Its documentation can be found in the ARM manual, rather than the LPC2129 manual which really only tells you about the LPC2129 peripherals.
If you look in the startup.s file that comes with the Keil LPC2129 demo (in the FreeRTOS.org distribution) then you will see the lines:
// Start in supervisor mode
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
this sets the processor mode prior to main being called.
User mode is not a privileged mode, so you cannot access the CPSR. As you cannot access the CPSR you cannot switch back to Supervisor mode.
The only way out of user mode once entered is within an exception handler. When an exception occurs you switch to a privileged mode so can access the CPSR again.