MPC5744P INTC unable to assign value

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5744P INTC unable to assign value

1,236 Views
billie60
Contributor I

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.

 

5ecae606e1103eeda12d77888941bed.jpg

5a85ea0aa15f68e6284c89ea5d1ccc6.jpg

billie60_0-1658502694708.png

 

0 Kudos
9 Replies

1,219 Views
petervlna
NXP TechSupport
NXP TechSupport

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.

petervlna_0-1658821208079.png

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:

petervlna_1-1658821440004.png

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:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5744P-PIT-triggering-interrupts/ta-p/...

Best regards,

Peter

 

0 Kudos

1,211 Views
billie60
Contributor I

Hello, I wanna set a performance monitor interrupt. But I wanna do it by software vector mode. Is this feasible?

0 Kudos

1,203 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Now I am confused. You are mixing 2 thing together. INTC (external interrupt to core) and core interrup IVOR7 which is the:

petervlna_0-1658924316506.png

The conditions for triggering IVOR7 are set above.

Best regards,

Peter

 

0 Kudos

1,200 Views
billie60
Contributor I

Hello. So if I want to set a performance monitor interrupt, I do not need to set INTC registers?

Thanks

0 Kudos

1,199 Views
billie60
Contributor I

PS: Do you have any example about performance monitor interrupt? If you have, please share me. I'm a beginner and I'm confused too. Thank you so much.

0 Kudos

1,162 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

I do not think there is such example code.

But it is not that complex. Just follow core reference manual:

petervlna_0-1659347203700.png

Best regards,

Peter

0 Kudos

1,157 Views
billie60
Contributor I

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.

b261f5985eb219efa511d7f2f94817d.jpg

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.

b943d22b0651e4fa6db6f9708f3f6bf.jpg

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.

 

 

0 Kudos

1,152 Views
petervlna
NXP TechSupport
NXP TechSupport

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

0 Kudos

1,145 Views
billie60
Contributor I

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)

0feb221ec6a524f7ce2ca14cca9a443.jpg

 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

 

0 Kudos