Fire IRQ, triggered from Source Code...

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Is there any simple solution, (XMC, DaveApp,...) to generate call of IRQ-Function from Source Code?
(I guess, I can use HW-Pheripheral... and set IRQ-Request Bits... but may, there is a more simple solution without pheripherals?)

Backround... I need an additional IRQ/Level-Priority-task, between my SYSTIMER(IRQ)-task and Backround task.

Best Thanks for help.
0 Likes
12 Replies
chismo
Employee
Employee
First like received
Hello,

You can use directly the CMSIS set IRQn pending function to trigger the interrupt.

For example to trigger SCU.SR0:

/* CMSIS function void NVIC_SetPendingIRQ (IRQn_t IRQn) */
NVIC_SetPendingIRQ(SCU_0_IRQn);


Hope this helps.

Regards,
Min Wei
0 Likes
Not applicable
Thanks...

But,where and how I have to declare the IRQ(callback) function? And set IRQ priorities... ? Over DAVE App?

Thanks for help...
0 Likes
chismo
Employee
Employee
First like received
I think the easiest is to simply add the NVIC node initialization codes and handler function directly to your existing program, without going through DAVE.

For example:

/* Handler function */
void SCU_0_IRQHandler(void)
{
/* Code */
}

int main(void)
{
DAVE_STATUS_t status;
...
/* Initialize NVIC */
NVIC_SetPriority(SCU_0_IRQn, 3U);
NVIC_EnableIRQ(SCU_0_IRQn);
...
while(1U)
{
}
return 1;
}


And as mentioned previously, the CMSIS set IRQn function can be used to trigger the interrupt.
Or if this is not needed, the handler function can be also called directly in the program.

Regards,
Min Wei
0 Likes
Not applicable
Hi,

In your solution... How I can Register the callback IRQ-function ???

----

In the meantime...
I try to use DAVE App INTERRUPT (4.0.8)
Define, "Enable", Prio. and Interrupt handler in DAVE-APP...

Use Method "SetEnable + SetPending" by SW...

With Debugger, I can set a BP inside IRQ-Handle... it's called... OK...
But after leaving IRQ-Handler, CPU/Debugger jumps to anyway??? And Stops ? Not back...

What I am doing wrong?
0 Likes
Not applicable
2089.attach

Here a screenshoot...
0 Likes
chismo
Employee
Employee
First like received
Hello,

Sorry, what do you mean by "register the callback IRQ-function"?

The non-DAVE App code is doing the same thing as the DAVE app, i.e.:
- enable and configure priority for interrupt node
- define interrupt handler or call back function
- trigger the interrupt

In either case, the interrupt handler would exit to the point of the code execution before the interrupt occurrence.
In your project, you are always getting the breakpoint trap as shown in your attached screenshot?

Regards,
Min Wei
0 Likes
Not applicable
"register the callback IRQ-function" means for me, to tell the Compiler the IRQ-function for a specific IRQ.
But OK, that's made with the DAVe App...

Yes, Debugger/CPU is always lost after exiting IRQ function...
A BPoint inside IRQ function is working OK. IRQ fucnction is called...
0 Likes
Not applicable
How can I go on with Analyzing/Debugging that Problem?
0 Likes
lock attach
Attachments are accessible only for community members.
chismo
Employee
Employee
First like received
Hello,

For the non-APP case, the IRQ function "SCU_0_IRQHandler" is defined in the startup file and hence, the compiler will take care that when the IRQ is triggered, the function will be called.

I am not sure what is causing the breakpoint trap.
I have created a simple pin-toggling example with the XMC2GO kit where:
- P1.0 is toggling always in the while loop of main function
- In the while loop, IRQ0 is being triggered by SW
- IRQ0 function toggles P1.1

Can you try with this simple example to see if it works for you?


Regards,
Min Wei
0 Likes
Not applicable
Hello,

Thanks for Support, but I have no SKit2Go here...


BUT, In the meantime, I find out, that my DAVE-APP solution is working...

IF:

I define in "Manual Ressource Assignment / INTERRUPT / NVIC-Node: XXX"

Otherwise I get a Hard-Fault.

I can define the node numbers betwwen 2 and 31...
Some are working, some results in Hard-Fault...
e.g. Number 10 is working, I am using that now...

Please, May somebody can give me more backround Information, why and which Node-Numbers I can use, or use for best case ???

Best Thanks.
0 Likes
chismo
Employee
Employee
First like received
Hello,

So the previous problem is due to unassigned NVIC node?

In the XMC1100, most of the NVIC nodes are assigned to specific service request lines of the peripherals:
2113.attach

The interrupt handler is not implemented in DAVE for the NC (not connected) lines, though an exception is IRQ2.
These are the ones causing the default handler (from startup file) to be entered.

For your purpose, I would suggest to use IRQ2 or whichever nodes (IRQ10 is USIC0.SR1) that are not used in your application, for the SW interrupt.

Hope this helps.

By the way, the code that I provided can also be used for XMC1100 boot kit but probably you don't need it anymore.

Regards,
Min Wei
0 Likes
Not applicable
OK, I understood.

2 is already used...
So I am using 6, and it's working fine.

Best Thanks for help!
0 Likes