The SWI interrupt handler (modified by Martin Thomas)looks: @******************************************************************** @* SWI interrupt handler * @* Function : SoftwareInterrupt(SWI_Number) * @* The SWI_Number is 0 through 3 * @* See below "SwiFunction" table below * @* Parameters: None * @* input : SWI_Number * @* output : None * @******************************************************************** SoftwareInterrupt: CMP R0, #4 LDRLO PC, [PC, R0, LSL #2] MOVS PC, LR It assumes, that the SWI instruction's low bits value is already placed in R0. But I could not find the code, which does this. What is my mistake? Great thanks in advance, Varuzhan
Dear Martin, Thank you very much. But I think that your answer is interesting for the forum members too. Best regards, Varuzhan ----- Original Message ----- From: "Martin Thomas" <mthomas@> To: <dan@> Sent: Wednesday, June 27, 2007 8:44 PM Subject: Re: swi_handler.S in the LPC2378_demo1 > Hello Varuzhan, > > dan@ wrote: >> Dear Martin, >> >> Waiting several days for my forum question, I am forced >> again repeat it: >> >> The SWI interrupt handler (modified by Martin Thomas)looks: >> >> @******************************************************************** >> @* SWI interrupt handler * >> @* Function : SoftwareInterrupt(SWI_Number) * >> @* The SWI_Number is 0 through 3 * >> @* See below "SwiFunction" table below * >> @* Parameters: None * >> @* input : SWI_Number * >> @* output : None * >> @******************************************************************** >> SoftwareInterrupt: >> CMP R0, #4 >> LDRLO PC, [PC, R0, LSL #2] >> MOVS PC, LR >> >> It assumes, that the SWI instruction's low bits value is already >> placed in R0. But I could not find the code, which does this. What >> is my mistake? > > I did read your question in the forum but as written in the source: I have > not tested the SWI-handler in the 2378-demo so I can not give a final > answer. I have just adpated the original NXP source so it can be assembled > with the GNU assembler. > I don't know why the NXP developer ceated the handler like this. It does not > look like the recommended SWI handling documented in the ARM manuals. It > should be easy to adapt the SWI-handler from my GNU port of the LPC2138/48 > examples at > http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/lpc2k_bundle_port/index.html > which I have tested with an LPC2138 (also ARM7TDMI-S-core). > > I will extend the LPC2378 example to demonstrate SWI-calls and modify the > source if needed when I have some spare time. > > Regards, > Martin Thomas
>> I will extend the LPC2378 example to demonstrate SWI-calls and modify the >> source if needed when I have some spare time. An extended version of "demo_1/epsilon" is available at: http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#lpc23xx_demo1 I have modified the swi-handler and startup-code: - modified decoding of swi-number in swi-handler (from arm-mode only, since the assembler-functions with the swi instruction are in arm-mode, so the decoding from thumb is not needed here) (swi_handler.S) - Exception vector "routes" SWI-exceptions to swi-handler (in startup.S) - application starts in USR-mode with IRQ-exceptions disabled (startup.S) - IRQs enabled in main() thru swi (main.c) Hope this helps, feedback welcome Martin Thomas
Martin Thomas wrote: >>> I will extend the LPC2378 example to demonstrate SWI-calls and modify the >>> source if needed when I have some spare time. > > An extended version of "demo_1/epsilon" is available at: > http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#lpc23xx_demo1 > > I have modified the swi-handler and startup-code: > - modified decoding of swi-number in swi-handler (from arm-mode only, > since the assembler-functions with the swi instruction are in arm-mode, > so the decoding from thumb is not needed here) (swi_handler.S) > - Exception vector "routes" SWI-exceptions to swi-handler (in startup.S) > - application starts in USR-mode with IRQ-exceptions disabled > (startup.S) > - IRQs enabled in main() thru swi (main.c) > > Hope this helps, feedback welcome > Martin Thomas Hello Martin, Thank you very much! With addition of the SWI handler, your example is really a great one. I adapted your code for my own board (not industry standard) and now it works fine. To support watchdog I added a small asembler function to your swi_handler.S and it works too, though I am not an ARM assembler expert: WDTfeed: STMFD sp!, {r4} MOV r4,#0xaa MOV r0,#0xe0000000 STR r4,[r0,#8] MOV r4,#0x55 STR r4,[r0,#8] LDMFD sp!, {r4}^ MOVS PC, LR Maybe it is not a nice code and experts can suggest a better one. One more question: I use Programmers Notepad from the standard WinARM, but I could not find (if exists) how to let it know about the '@' character as a comment. So to avoid ugly highlights in comments I replaced it with "//@". Maybe there is a better way? Thanks in advance, Varuzhan
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.