
reu05b0038_m16cap| Application Note
APPLICATION NOTE
M16C/26
Writing Interrupt Handlers in C
1.0 Abstract
This application note describes how to write hardware and software interrupt handlers using NC30 C (version 4.XX and earlier) compiler for M16C microcontrollers. Interrupt mechanisms are processor (hardware) specific, the ANSI C specification for writing interrupt functions is, at best, vague.
2.0 Introduction
The Renesas M30262 is a 16-bit MCU based on the M16C/60 series CPU core. The MCU features include up to 64K bytes of Flash ROM, 2K bytes of RAM, and 4K bytes of virtual EEPROM. The peripheral set includes 10-bit A/D, UARTs, Timers, DMA, and GPIO. In order to process interrupts, your program must do two things: 1. Properly declare the function handling the interrupt. 2. Set the appropriate interrupt vector to point to the function.
3.0 Hardware Interrupts
By declaring the function as an interrupt handler, the compiled output ends in a "reit" (return from interrupt) instruction rather than the standard "rts" (return from subroutine). For hardware interrupts, use the declaration, #pragma INTERRUPT function_name /B
Note: "INTERRUPT" must be uppercase.
and the prototype, void function_name (void);
Obviously, a hardware interrupt can neither be passed a value nor return a value. Section 5.0 gives an example hardware interrupt processing program. Note the "/B" option in the #pragma statement. This option speeds up interrupt response by switching to CPU register Bank 1. Without this switch, the compiler generates code to stack all registers used by the interrupt functions. Be careful when using this option if using an RTOS or nested interrupts.
REU05B0038-0100Z
June 2003
Page 1 of 4
reu05b0038_m16cap Application Note renesas Download PDF
Add this permalink to your bookmarks for future download of reu05b0038_m16cap ApplicationNote
Permalink: http://application.emcelettronica.com/renesas/reu05b0038_m16cap