Hello, peter!
Now I can enter the interrupt! But I still have a problem.
I changed the code and entered 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.