Interrupts Intialization (GCC for Renesas 4.9.2.201801-GNURL78 Linux Toolchain (ELF Format)
Interrupts Intialization (GCC for Renesas 4.9.2.201801-GNURL78 Linux Toolchain (ELF Format)
I am using compiler “GCC for Renesas 4.9.2.201801-GNURL78 Linux Toolchain (ELF Format)” for RL78/I1b MCU,
I don’t know how to setup interrupt handler functions.
I tried below interrupt code which was generated from CS+ CA RENESAS IDE, it compiles successfully but i didn’t get output on RL78 MCU.
#pragma interrupt INTRTC r_rtc_interrupt
__interrupt static void r_rtc_interrupt(void)
{
if (1U == RIFG)
{
RTCWEN = 1U;
RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG; /* clear RIFG */
RTCWEN = 0U;
r_rtc_callback_constperiod();
}
}
I am developing this code for Contiki-OS, I need support for setup interrupt handlers in Contiki-OS.
Hello,
Our toolchain is GCC conformant, therefore it uses the standard way to declare interrupt handles, available on all platforms that have GCC compiler support.
The first aspect is to declare interrupt handlers by using attribute pragma, eg:
void interrupt_prototype(void) __attribute__ ((interrupt));
The second aspect is to declare the interrupt vector table, initialize it with interrupt handlers and place it in a section, eg:
const void *Vectors[] __attribute__ ((section (".vects"))) = { ..., interrupt_prototype, ... };
Finally, in the linker description we must place the reset vector and interrupt vector table at the right address starting from 0:
MEMORY { VEC : ORIGIN = 0x0, LENGTH = 4 IVEC : ORIGIN = 0x4, LENGTH = 188 ... } SECTIONS { .vec 0x0: AT(0x0) { KEEP(*(.vec)) } > VEC .vects 0x4: AT(0x4) { KEEP(*(.vects)) } > IVEC ... }
Following the above 3 steps, you can set up interrupt handlers. Please don’t forget to add peripheral related code to actually enable the interrupt source, and also you will need startup code which initializes stack pointers, data sections, etc. You can borrow startup code start.S by downloading e2studio from Renesas and create a sample project to obtain the code.
–
Thank you,
The GNU Tools Team