Hello!
Now I can enter the performance monitor interrupt! But it's not an interruption in the way I expected. So I still have a problem.
I want to enter the interrupt from IVOR7.
I set some values in MSR and PM registers in startup.s. Like this:
mfmsr r7
e_or2i r7, 0x1201
mtmsr r7
wrteei 1 //set EE, ME, DE and RI = 1 in MSR
e_bl xcptn_xmpl //init INTC.IACKR, INTC.BCR and IVPR.
e_lis r7, 0x8000
e_or2i r7, 0x0000
mtpmr 400, r7 //freeze all global counters
se_isync
e_lis r7, 0x0402
e_or2i r7, 0x7000
mtpmr 144, r7 //set up Instructions completed event in counter 0, se_isync //(set CE and EVENT = 0000 0010 in PMLCa0 register)
e_lis r7, 0X7fff
e_or2i r7, 0xffff
mtpmr 16, r7 //Set the initial value of PMC0 to 7fffffff, that is, interrupt after running an instruction.
se_isync
e_lis r7, 0x4000
e_or2i r7, 0x0000
mtpmr 400, r7 //un-freeze all global counters, set PMGC[PMIE] = 1,
se_isync //Performance monitor interrupt Enable
;# Jump to Main
e_bl main
I write main like this:
void IVOR7_Exception_Handler(void);
int inhandler = 0;
int main(void)
{
int a = 1;
int b = 2;
for(;;)
{
a++;
b++;
}
}
void IVOR7_Exception_Handler(void){
inhandler ++;
}
My idea is to trigger the performance monitor interrupt when the program runs an instruction. But when it running, inhandler still = 0.
However, when I run the dead loop in the program, press the reset key of the development board. Then I suspend the code and check the expressions view, inhandler changed to 1.
But why can't the interrupt be entered when the program is running normally, and the inhandler value can only be changed after pressing the reset key? I have no idea. Can you help me?
Thank you so much.
It seems to me as coincidence, as registers are re-initialized after reset.
Please check how you set-up PMU events. How you have it, it does not fit to AN4341 description:
Hello, David
I'm afraid it's no coincidence that the value of inhandler will be changed only after pressing the reset button, because I've tried it many times, and the results are the same. And, I think AN4341's description of set events is wrong. You can see this at https://www.nxp.com/docs/en/supporting-information/ftf-acc-F1184.pdf
Obviously, the event is set in bits 8-15 of the register (the eighth bit is also the event bit), but the event in your image is set after 16 bits.
I hope you can help me see what the problem is from the perspective of code logic. Thank you soooo much.