Hello, Please help me. I tried to set an interrupt in MPC5744P. But no matter how hard I try, I cannot initial INTC registers and the IPVR register. As writing in MPC57XX_Interrupt_Init.c, I use "INTC.CPR0.R = 0U;" to ensure INTC's current priority is 0 and use "INTC.IACKR0.R = (uint32_t) &IntcIsrVectorTable[0];" "SetIVPR ((unsigned int) &VTABLE);" to set IACKR0 register and IVPR register. It did not work. The values of all those registers are initial values. I'm sure these codes are running because I changed the value of the general register r7 on the next line of "INTC.CPR0.R = 0U;" during debugging, and r7 was successfully assigned. Three days have passed, I tried many methods, but I still couldn't successfully assign values to the INTC registers and IVPR register. This is my project. Please help me have a look. I really need your help.
Thank you so much.
Hello,
I have just tested your SW and you are really not triggering any interrupt.\
I did it manually in my test on your SW and the interrupt is triggered as soon as I set priority and set SWTN.
So it is good to understand how INTC works before going into any tests.
I am not sure if you want to trigger SW interrupt or peripheral one, but you are setting none of them.
Please have a close look at reference manual where it is explained:
Your approach is quite chaotic and I cant say what you want to achieve. Have also a look at my interrupt example for better understanding:
Best regards,
Peter
Hello,
Now I am confused. You are mixing 2 thing together. INTC (external interrupt to core) and core interrup IVOR7 which is the:
The conditions for triggering IVOR7 are set above.
Best regards,
Peter
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.
Hello,
What comes to my mind is the you disable interrupts in your code. Those are enabled by default after reset and pending interrupt is then executed.
Have a look how you configure MSR (machine state register).
Best regards,
Peter
Hello, peter
When I press reset button, MSR changed, from 1001001000000010(set MSR[EE][ME][DE][RI] = 1) to 10101100100100(set MSR[FP][FE0][DE][FE1][IS][PMM] = 1), So I directly initialize MSR to the latter in startup.s. It does not work, I also have to press the reset to change "inhandler".
PS: It is not mentioned in any user manual that the values of Fe0, Fe1, and IS need to be set to trigger the performance monitor interrupt.
After that, I added a branch to the main function like this:
int main(void)
{
int a = 1;
int b = 2;
if (a==1){
a = a+b;
}
else{
b = a+b;
}
for(;;)
{
a++;
b++;
}
}
And set PMLCa register event as event10 (Completed branch instructions, includes branch and link type instructions)
Then I debug the project in S32DS. "inhandler" never changed no matter whether I press the reset or not. I have set event to make PMC(performance monitor counter) count the branch completed. And the initial value of PMC is 7fff ffff (Theoretically, running a branch can trigger an interrupt but it has not worked). It seems PMC never counts the code in main.c. Did I have any problem in my setting? I have studied PMU for many days but I also cannot make it interrupt as I wish. I wish your help. Thank you sooo much. I uploaded the code I corrected. I hope you can read it and give some suggestions.
Best regards,
Billie