AURIX TC27x, How to get out from Trap Handler?

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

cross mob
User19956
Level 1
Level 1
Hi everyone.

I am trying to enter Trap Handler when i access memory protected by 'memory protection system'.
It goes to protect_trap_handler well, but i want to return from trap handler and execute pc line that occurred trap.

when trap handler finished by "rfe" instruction, i checked it goes to pc line that occurred trap but trap repeated infinitely.
How can i get out from trap handler without repetition when the trap occurred by memory protection?

Thank you for reading.
0 Likes
6 Replies
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
You can manipulate the return address in register A11. You must get the instruction of address in register A11. Dependent of the size of this instruction (16 bit or 32 bit) you increase the register A11 by 2 or 4. When you now return from trap with rfe you will return to the next instruction after the faulty one.
0 Likes
User19956
Level 1
Level 1
Thank you for reply.

I want to execute faulty PC line even if return from trap handler.
But, if code execute the next instruction after the faulty one, Couldn't i execute faulty PC value?
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
If you don't resolve the reason why you get a protection trap then you can't execute the faulty instruction because this will result in the same trap. E.g. your trap handler must switch off the memory protection.
0 Likes
User19956
Level 1
Level 1
Thank you for reply.

We want to record global data that generates memory protection traps before the input trap handler.
We use registers to set memory protection boundaries for global variables intentionally. ex) CPU_DPR0, CPU_DPRE0, CPU_DPWE0 ...

So if we approach a global variable, it triggers a protective trap and records global data ahead of the input trap handler.
And then, we want to execute faulty pc line that generates the trap after the trap is over.

But now we have found that the trap repeats indefinitely because I have not solved the cause of causing the protective trap.
We want to execute a faulty pc line that generates the trap after the trap is over. Not repeated infinitely.

How can we get out of the trap after finishing it just once?
We already know why we got protection traps because we intentionally set memory protection boundaries.

Thank you for reading.
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
This will never work. You have an instruction which will not executed because of a protection (e.g. not allowed to read/write any specific address). You get a trap and execute your trap handler. Then you come back to the instruction which causing the trap but the reason for the trap is not solved. Now you will access the same specific address but you don't have the permission. The CPU must trap otherwise.
If you need to execute the instruction without trap then you must switch off the protection for the address inside of your trap handler.
0 Likes
LijoDan
Level 2
Level 2
25 sign-ins 10 replies posted First question asked

Hello,

How to switch off protection for the address i am writing? to eg: 0xA0300000?

0 Likes