File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ extern "C" {
2727
2828void z_dspic_save_context (void );
2929void z_dspic_do_swap (void );
30+ extern uint32_t vector_start ;
3031
3132/* dsPIC33A interrupt functionality initialization */
3233static 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 */
You can’t perform that action at this time.
0 commit comments