Jan 14, 2015
08:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 14, 2015
08:03 AM
I want to implement a bus system. For this bus system I need a very well timing performance. For the timing interval I use the CCU40_0 from the XMC4500. To provide a jitter free signal I need to program the Interrupt handler in Assembler. At this point I have big problems. If I debug the interrupt handler step by step every think works fine. But ifI run the program I get an hard fault (Invalid state UsageFault). As I recognized this error I tried out to implement the interrupt handler in C. This works fine. So I copied the generated assembler Code to my own assembler written interrupt handler and tried it again. The same error occurs.
Enclosed the two Disassembly Cases and the associated program codes. That shows that the Disassembly Codes are the same.
Does anyone have an idea what could be wrong?
yours sincerely
Stephan
Assembler Case:
C Case
Enclosed the two Disassembly Cases and the associated program codes. That shows that the Disassembly Codes are the same.
Does anyone have an idea what could be wrong?
yours sincerely
Stephan
Assembler Case:
Code
#include
.thumb
.text
//.global swhp_updatetimer
.global swhp_pulse
.func swhp_pulse
.align 4
swhp_pulse:
push {r7}
add r7, sp, #0x0
nop
mov r13, r7
pop {r7}
bx r14
Disassembly:
080005da: df f8 24 04 ldr r0, [pc, #1060]
080005de: 00 b5 push {lr}
080005e0: 81 b0 sub sp, #0x4
080005e2: 80 47 blx r0
08001540: 80 b4 push {r7}
08001542: 00 af add r7, sp, #0x0
08001544: c0 46 mov r8, r8
08001546: bd 46 mov r13, r7
08001548: 80 bc pop {r7}
0800154a: Unable to retrieve disassembly data from backend. (bx r14)
080005e4: 01 b0 add sp, #0x4
080005e6: 00 bd pop {pc}
C Case
Code:
void CCU40_0_IRQHandler() {
return;
}
Disassembly
080005da: df f8 24 04 ldr r0, [pc, #1060]
080005de: 00 b5 push {lr}
080005e0: 81 b0 sub sp, #0x4
080005e2: 80 47 blx r0
08001530: 80 b4 push {r7}
08001532: 00 af add r7, sp, #0x0
08001534: 00 bf nop
08001536: bd 46 mov r13, r7
08001538: 80 bc pop {r7}
0800153a: 70 47 bx r14
080005e4: 01 b0 add sp, #0x4
080005e6: 00 bd pop {pc}
10 Replies
Jan 14, 2015
06:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 14, 2015
06:34 PM
At this point I have big problems. When I debug the interrupt handler step by step every think works fine. But when I run the program I get an hard fault (Invalid state UsageFault).
Travis: Can you provide a screen shot when the hard fault happens and hope we can get some hints from there.
Travis: Can you provide a screen shot when the hard fault happens and hope we can get some hints from there.
Jan 15, 2015
02:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 15, 2015
02:15 AM
Thanks for your answer. It is difficult to find the point when the hard fault happens, because when I debug it step by step every think works fine. And as soon as I press the resume button a hard fault happens. Interesting on this point is that if I place a breakpoint on the point where the Insert_exceptionHandler branches to my interrupt handler and I press resume, also every think works.
The picture below shows the Debug Window on that point.
The picture below shows the Debug Window on that point.
Not applicable
Jan 29, 2015
12:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 29, 2015
12:34 AM
Hi,
sometimes it is helpful to overwrite the usage fault handler with your own C function. Add a breakpoint and try to rebuild the stack trace (e.g. memory watch window or debugger stack trace) to see where you coming from. Maybe it's not your assembler code throwing this fault.
Attention must be payed if the stack is corrupted. In this cases you have no chance to find out where you are coming from.
sometimes it is helpful to overwrite the usage fault handler with your own C function. Add a breakpoint and try to rebuild the stack trace (e.g. memory watch window or debugger stack trace) to see where you coming from. Maybe it's not your assembler code throwing this fault.
Attention must be payed if the stack is corrupted. In this cases you have no chance to find out where you are coming from.
Attachments are accessible only for community members.
Jan 29, 2015
06:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 29, 2015
06:49 PM
Feb 10, 2015
01:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 10, 2015
01:15 AM
Hi,
Thank you for your efforts!
Travis: I was testing your project, and saw that you also used a C function to call the assembler function. That was the case which worked. I want to implement the interrupt handler direct in assembler. In this case the HardFauld occurs. I attached my Project. Maybe you can take a look on it.
Tomwel: The stack has always the same value when the program enters the CCU40_0 Insert_ExceptionHandler. And by debugging it words fine. So I think I can’t find the error on this way.
Best regards
Stephan
Thank you for your efforts!
Travis: I was testing your project, and saw that you also used a C function to call the assembler function. That was the case which worked. I want to implement the interrupt handler direct in assembler. In this case the HardFauld occurs. I attached my Project. Maybe you can take a look on it.
Tomwel: The stack has always the same value when the program enters the CCU40_0 Insert_ExceptionHandler. And by debugging it words fine. So I think I can’t find the error on this way.
Best regards
Stephan
Feb 10, 2015
02:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 10, 2015
02:28 AM
Hi Stephan,
This is a little bit too hard core which we don't usually do. Why can't you just code your assembly within the interrupt function and let the compiler take care of the push pull of the stack.
Best Regards
Travis
This is a little bit too hard core which we don't usually do. Why can't you just code your assembly within the interrupt function and let the compiler take care of the push pull of the stack.
Best Regards
Travis
Attachments are accessible only for community members.
Feb 10, 2015
05:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 10, 2015
05:14 AM
Stephan Hochmüller wrote:
Hi,
Thank you for your efforts!
Travis: I was testing your project, and saw that you also used a C function to call the assembler function. That was the case which worked. I want to implement the interrupt handler direct in assembler. In this case the HardFauld occurs. I attached my Project. Maybe you can take a look on it.
Tomwel: The stack has always the same value when the program enters the CCU40_0 Insert_ExceptionHandler. And by debugging it words fine. So I think I can’t find the error on this way.
Best regards
Stephan
Sorry forget to attach the Project:
Feb 12, 2015
01:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 12, 2015
01:56 AM
Hi Stephan,
I will have a look at your code when I am free. But at the moment I recommend that you embed your assembly code inside the interrupt C function. May I know if this way actually generates more codes?
Best Regards
Travis
I will have a look at your code when I am free. But at the moment I recommend that you embed your assembly code inside the interrupt C function. May I know if this way actually generates more codes?
Best Regards
Travis
Feb 19, 2015
12:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 19, 2015
12:50 AM
Hallo Travis,
Yes it generates more code. If an interrupt appears the program jumps into the C interrupt handler. And in this handler the program jumps to the assembler function. Thus there is one jump more than it is needed.
Best Regards
Stephan
Yes it generates more code. If an interrupt appears the program jumps into the C interrupt handler. And in this handler the program jumps to the assembler function. Thus there is one jump more than it is needed.
Best Regards
Stephan
Not applicable
Feb 21, 2015
11:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 21, 2015
11:11 AM
You could try using inline assembler in the interrupt handler function.