Skip to content

Commit 3ce5456

Browse files
authored
arch: Added provision interrupt vector table relocation (zephyrproject-rtos#27)
Added the provision of relocating vector table in dspic Signed-off-by: Adhil Xavier <[email protected]>
1 parent ba5bbb2 commit 3ce5456

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/dspic/include/kernel_arch_func.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C" {
2727

2828
void z_dspic_save_context(void);
2929
void z_dspic_do_swap(void);
30+
extern uint32_t vector_start;
3031

3132
/* dsPIC33A interrupt functionality initialization */
3233
static ALWAYS_INLINE void z_dspic_interrupt_init(void)
@@ -35,7 +36,6 @@ static ALWAYS_INLINE void z_dspic_interrupt_init(void)
3536
* clear all the interrupts, set the interrupt flag status
3637
* registers to zero.
3738
*/
38-
3939
IFS0 = 0x0;
4040
IFS1 = 0x0;
4141
IFS2 = 0x0;
@@ -45,11 +45,21 @@ static ALWAYS_INLINE void z_dspic_interrupt_init(void)
4545
IFS6 = 0x0;
4646
IFS7 = 0x0;
4747
IFS8 = 0x0;
48-
4948
/* enable nested interrupts */
5049
INTCON1bits.NSTDIS = 0;
5150
/* enable global interrupts */
5251
INTCON1bits.GIE = 1;
52+
53+
/**
54+
* After a reset default values IVTBASEWR will be having value 1, IVTBASELK will be 0
55+
* even though writing to these bits to make sure IVTBASE register is writable.
56+
*/
57+
PACCON1bits.IVTBASELK = 0;
58+
PACCON1bits.IVTBASEWR = 1;
59+
/* set the new base address */
60+
IVTBASE = (uint32_t)((void *)&vector_start);
61+
PACCON1bits.IVTBASEWR = 0;
62+
PACCON1bits.IVTBASELK = 1;
5363
}
5464

5565
/* dsPIC33A fault initialization */

0 commit comments

Comments
 (0)