AnsweredAssumed Answered

Changing IVPR on the P1021 causes Program Interrupt Exception

Question asked by Zachary Wilcox on Jan 28, 2019
Latest reply on Jan 28, 2019 by Zachary Wilcox

I'm attempting to change the IVPR.  I'm doing this by setting MSR[EE] = 0, setting the IVPR register, some other initialize stuff, then setting MSR[EE]  = 1.
I then get a program interrupt exception and jump to the new IVPR + IVOR6.   


When I comment out the section that sets IVPR, and interrupts fire, then it jumps to the old IVPR + IVOR4, as expected.
This indicates that I'm doing something wrong when setting IVPR

 

MSR[PR] = 0 when I'm setting IVPR and the MSR bits so I'm in supervisor mode.

IVOR4, IVOR6 is 0x500 and 0x700 respectively and don't change.

Below is an abbreviated code of me changing the IVPR:

 

uint32_t msr_reg = 0;
__asm__ volatile
(
"mfmsr %0 \n"
: "=r" (msr_reg)
:
: "0" /* clobbered register */
);
//MSR = 0x2029200 at this point
msr_reg &= ~MSR_EE_MASK; //MSR_EE_MASK = 0x00008000

__asm__ volatile
(
"mtmsr %0 \n"
:
: "r" (msr_reg)
: "0"
);
//MSR = 0x2021200 at this point

//IVPR = 0x3ff60000 at this point
uint32_t ivpr = 0x200000;
__asm__ volatile
(
"mtspr ivpr, %0\n"
:
: "r" (ivpr)
);
//IVPR = 0x00200000 at this point

/*
* initializing PIC code
*/


msr_reg = 0;
__asm__ volatile
(
"mfmsr %0 \n"
: "=r" (msr_reg)
:
: "0" /* clobbered register */
);
//MSR = 0x2021200 at this point

msr_reg |= MSR_EE_MASK; //MSR_EE_MASK = 0x00008000
__asm__ volatile
(
"mtmsr %0 \n"
:
: "r" (msr_reg)
: "0"
);
//Sudden jump to new IVPR + IVOR6

 

I'd be grateful for any pointers on what I'm doing wrong.

 

Edit: The problem exists when I change the IVPR manually through the JTAG device

 

Edit: The ESR register is: 0x08000000 indicating an illegal instruction.

 

Edit:  The SRR0 register is indicating the exception occurred at: IVPR + IVOR10.  

Outcomes