The use of the Hardware Interrupt block in Target Support Package TC2

2 views (last 30 days)
In the hardware Interrupt block, there is a parameter named preemption flag. In the help document,i got that "Preemption overrides prioritization, such that a preemptable task of higher priority can be preempted by a non-preemptable task of lower priority."
I set my interrupt1' priority is 30 and the preemptition flag is 0(non-preemptable);the interrupt2's priority is 25 and the preemptition flag is 1(preemptable).
So i think when the interrupt1 happened and the program runs in the interrupt1 service routine,if interrupt2 is triggered, my program will run to the interrupt2 service routine immediately.And when the interrupt2 service routine ran over,the program returned to interrupt1 service routine.Is this right? But i didn’t get this result in my oscillograph after loading the generted code to my DSP board. Could somebody explain the use of the preemptition flag?
What is the relationship between the sample time and the base rate?
Best regards.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 23 Nov 2011
I think the expected behavior would be as follows:
when the interrupt1 happened and the program runs in the interrupt1 service routine,if interrupt2 is triggered -> interrupt1 will continue to run because it is non-preemptable.
You probably want to switch your pre-emption flags around if you need interrupt2 to pre-empt interrupt1.
  2 Comments
w w
w w on 24 Nov 2011
Thank you for your reply.And I am sorry for my mistake, I described the question in the direct opposite.
I want that when the interrupt2(higher priority) happened and the program runs in the interrupt2 service routine,if interrupt1(lower priority) is triggered, my program will run to the interrupt1 service routine immediately.And when the interrupt1 service routine ran over,the program returned to interrupt2 service routine.So I set the interrupt1 is non-preemption and the interrupt2 is preemption. But the program didn't run as excepted!
I look up the generated code carefully,I found that in the Interrupt2's interrupt service routine, it disables the interrupts that have equal or lower priority than interrupt2.So no matter the preemptition flag is '1' or '0', the interrupt1 which has a lower priority than interrupt2 will not pre-empt interrupt2.
So how could i realize that "Preemption overrides prioritization, such that a preemptable task of higher priority can be preempted by a non-preemptable task of lower priority."?
Thank you!
Kaustubha Govind
Kaustubha Govind on 21 Dec 2011
w: Could you report this to MathWorks Tech Support with a simple model for reproduction? Perhaps it is a bug?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!