Hello!
I have a new problem about the interrupt.
First,I can entry the IRQ function by following the demo and it's correctly.
But now,I want to set a function like this:
I have tried,but I failed.
So,my problem is that I just set the IRQ funtion before compiling in this array:
but I want to get a function to install the IRQ funtion.How can I do?
Solved! Go to Solution.
Hi,
normally - the vector table is copied in the RAM - to be able change IRQ handler address in runtime. As you can see from startup - the vector table is defined at beginning of flash (m_text) and in startup is copied to RAM (0x40000000) and IACKR0->VTBA is set to 0x40000 (aligned to 0x1000) in startup.c.
So, if you create another vector table (in the FLASH area) with your function (and there is still present the default vector table) - you also need to modify startup.c where vector table is copied from FLASH to RAM:
if (__VECTOR_RAM != __VECTOR_TABLE)
{
/* Copy the vector table from ROM to RAM */
for (n = 0; n < (((uint32_t)__RAM_VECTOR_TABLE_SIZE)/sizeof(uint32_t)); n++)
{
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
}
/* Point the VTOR to the position of vector table */
*vectors[coreId] = (uint32_t)__VECTOR_RAM;
}
else
{
/* Point the VTOR to the position of vector table */
*vectors[coreId] = (uint32_t)__VECTOR_TABLE;
}
Hope it helps.
Jiri
Hi,
If I'm understand it correctly - you like to add Interrupt handler in compile time, correct?
So - just add your particular handler instead &dummy - that's all. Don't forget declare this handler like the dummy is and of course you need to implement it.
For example:
void dummy (void);
void MyPitHandler(void);
(uint32_t) &dummy, /* Vector # 223 */
(uint32_t) &dummy, /* Vector # 224 Real Time Counter (RTC) RTC */
(uint32_t) &dummy, /* Vector # 225 Autonomous Periodic Interrupt (API) API */
(uint32_t) &MyPitHandler, /* Vector # 226 Periodic Interrupt Timer (PIT0) PIT_1_TFLG0[TIF] */
(uint32_t) &dummy, /* Vector # 227 Periodic Interrupt Timer (PIT1) PIT_1_TFLG1[TIF] */
(uint32_t) &dummy, /* Vector # 228 Periodic Interrupt Timer (PIT2) PIT_1_TFLG2[TIF] */
Jiri
I am sorry that i don't state my problem clearly.
Your method is a good way to solve the problem,Jiri.
But I want to ask you for another.
In fact, the array is definitioned
the array is definitioned in text section,So I can't change the value of the definitioned vector table.
Now I want to set a new arrary to store the ISRs' address,like this:
uint32_t IntcIsrVectorTable[750] = {(uint32_t)(&dummy),(uint32_t)(&dummy) ...};
and then
INTC.IACKR[0].R = (uint32_t)&IntcIsrVectorTable;
last I replace the corresponding value of the array with ISR address,like:
void Pit0Ch0Isr(void)
{
PIT_0.TIMER[0].TFLG.B.TIF = 1; //clear the flag
SIUL2.GPDO[30].B.PDO_4n3 = ~SIUL2.GPDO[30].B.PDO_4n3; //turn
}
IntcIsrVectorTable[226] = (uint32_t)(&Pit0Ch0Isr);
and then I enable the interrupt,I find that I can't enter the changed ISR,what happen?
Thank for your help!
Hi,
normally - the vector table is copied in the RAM - to be able change IRQ handler address in runtime. As you can see from startup - the vector table is defined at beginning of flash (m_text) and in startup is copied to RAM (0x40000000) and IACKR0->VTBA is set to 0x40000 (aligned to 0x1000) in startup.c.
So, if you create another vector table (in the FLASH area) with your function (and there is still present the default vector table) - you also need to modify startup.c where vector table is copied from FLASH to RAM:
if (__VECTOR_RAM != __VECTOR_TABLE)
{
/* Copy the vector table from ROM to RAM */
for (n = 0; n < (((uint32_t)__RAM_VECTOR_TABLE_SIZE)/sizeof(uint32_t)); n++)
{
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
}
/* Point the VTOR to the position of vector table */
*vectors[coreId] = (uint32_t)__VECTOR_RAM;
}
else
{
/* Point the VTOR to the position of vector table */
*vectors[coreId] = (uint32_t)__VECTOR_TABLE;
}
Hope it helps.
Jiri
Thank you,Jiri!
According to your method,I find it is a problem that interrupt redirect,and I solved the problem already,thank you!