您好,欢迎光临本网站![请登录][注册会员]  
文件名称: R8C族中断处理
  所属分类: C
  开发工具:
  文件大小: 224kb
  下载次数: 0
  上传时间: 2019-01-11
  提 供 者: u0112*****
 详细说明:R8C族中断处理,初学都必须学的中断处理文档。。。。。RENESAS APPLICATION NOTE R8C/25 Group Interrupt Handling in C Language 1. Abstract This document describes how to set up and use the interrupt handling in C language in the r8C/25 Group 2. Introduction The application example described in this document is applied to the following MCu and parameter(s) MCU: R8C/25 Group This program can be used with other r&C/Tiny Series MCUs which have the same special function registers (SFRS)as the rgC/25 Group. Check the manual for any additions and modifications to functions. Careful evaluation is recommended before using this application note REJ05B08470100/Rev1.00 January 2007 Page 1 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3. Application Description 3.1 Writing Interrupt Handling Function The NC30 allows the interrupt handling to be written as a C language function The procedure consists of the following two steps (1) write the interrupt handling function 2) Register it to the interrupt vector table This sections describes an example for writing a function for each interrupt handling 3.1.1 Writing Hardware Interrupt(pragma INTERRUPT) #pragma INTERRUPT interrupt function name When declared as the above, the prograrm saves and restores all registers in the r8C/Tiny Series and generates the reit instruction, in addition to ordinary function procedures on entry and exit to and from the specified function. The valid type of interrupt handling function is void only for both arguments and return values Declaring any other ty pes generates a warning when compiling Figure 3. 1 shows the Expanded Image of Interrupt Handling Function #pragma INTERRUPT intr section program glb intr void intr( void ntr. All registers are sav Expanded push RO, R1, R2, R3, AO.Al SB. FB erru Interrupt handling All registers are resotred papm RO, R1, R2, R3, Only void type is valid for both arguments and return values AO. Al SB Returm by reit instruction Figure 3.1 Expanded Image of Interrupt Handling Function REJ05B0847-0100/Rev.1.00 January 2007 Page 2 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3.1.2 Writing Interrupt to be Activated in Short Time pragma INTERRUPT/B) The r8CTiny Series can provide shorter interrupt activation time by switching the register banks while protecting the contents such as those of the registers. To use this function, write as follows #pragma INTERRUPT/B interrupt function name When written as above. the program generates the reit instruction, instead of the instruction for saving and restoring the registers. Note that only one interrupt can be specified because the register banks of the r&C/Tiny Series are the sets of register bank 0 and 1 (). Use this function for interrupts to be activated in the shortest time Figure 3.2 shows an Expanded Image of Interrupt Handling Function #pragma INTERRUPT/B intr section program glb intr void intr( void Register bank 1 is used tset B Interrupt handling Interrupt handling fclr B Returned to register bank O Return by reit instruction Figure 3.2 Expanded Image of High-speed Interrupt Handling Function NOTE 1. These register banks are available for all interrupts if multiple interrupts are not used REJ05B0847-0100/Rev.1.00 January 2007 Page 3 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3.1.3 Writing Software Interrupt#pragma INTCALL To use the rsc software interrupt, write as follows #pragma INTCALL INT number function name The soflware interrupt can pass arguments via registers and ackno wledge return values except for struct/union types Figure 3. 3 shows an Example of Writing"#pragma INTCALL Function prototype is declared before #pragma iNTCALL is declared void call 32 int, int INT number (decimal number) #pragma INTCALL 32 call32( RO, R1) Available register names R0.R1.R2.R3 ROL, ROH, R1L, R1H void main( void Aruguments are passed to the function via these registers m, n, call32( m, n) Function "CALL32 is called by INT instruction enter Argument is set to regi mov. W -2[FB], R1; n -2B],R0 exit Figure33 Example of Writing“# pragma| NTCALL” REJ05B0847-0100/Rev.1.00 January 2007 Page 4 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3.2 Registering Interrupt Handling Function To use interrupts correctly, it is necessary to write and register the interrupt function to the interrupt vector table This section describes how to register the interrupt function to the interrupt vector table 3.2.1 Registering to Interrupt Vector Table a written interrupt function is registered by changing the interrupt vector table in the sample startup program sectio.inc To change the interrupt vector table, use the following procedure (1)Externally define the interrupt handling function name by the simulated instruction ".glb (2) Change the interrupt handling function name with the interrupt dummy function name"dummy intto be used Figure 3. 4 shows an Example of Registering to Interrupt Vector Table("sect30. inc) variable vector section section vector. ROMDATA variable vector table org YECTOR ADR int ummy_ Ir vector o Iword dummy int vector 1 word dummy_ int vector 2 lword d Iword dummy int vector 4 ord dummy int vector 5 lword dummy int vector 6 dt vector 7 dummy_i vector 8 vector 9 dummy_int vector 10 vector 12 glb Iword dt int vector 14 dummy_int vector 15 word dummy int vector 16 d dummy int vector 17 to key input interrupt tered Function kupic"is regist Iword dummy int vector 1 Figure 3. 4 Example of Registering to Interrupt Vector Table ("sect30 inc") REJ05B0847-0100/Rev.1.00 January 2007 Page 5 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3.3 Example of Writing Interrupt Handling Function This section shows an example of writing a program that increments the content of the "counter"each time an INTO interrupt occurs 3.3.1 Writing Interrupt Handling Function Figure 3.5 shows an Example of writing Source fild /* prototype declaration**木”*本木木有本木本*木木木木/ void into( void ) #pragma interrupt into 读**★南★南***大大*被★★*读**★★★******/ unsigned int counter =0 void into( void interrupt handling function if( counter <9 counter++ y else counter =0 void main( void nc=0x00; interrupt enabled * into /*INTO interrupt enabled * intOpl =1; /INTO input polarity: both edges selected " intf 0x03 /*INTO input fiter: sampling with f32*/ intOiC = 0x01 interrupt priority level setting asm("fset 1"); interrupt disabled*/ while (1): /interrupt wait loop * Figure 3.5 Example of Writing Source File REJ05B0847-0100/Rev.1.00 January 2007 Page 6 of 10 RENES∧s R8C/25 Group Interrupt Handling in C Language 3.3.2 Registering to Interrupt Vector Table Figure 3.6 shows an Example of Registering to Interrupt Vector Table. variable vector section section vector ROMDATA variable vector table org VECTOR ADR Iword my_int rector o lward dummy int vector 1 lword dummy int vector 2 Iword dummy int Iword dummy int vector 4 wor dummy int Iword dummy_ int Iword dummy_ir dummy int vector 8 vector 9 Iword dt vector 10 lword dummy int vector 1 1 Iword dummy_ int vector 12 Iword dummy int lword dummy int vector 14 Iword dummy_ int vector 15 Iword du tor 16 lword dummy int tor 17 Iword dummy int Iword dummy in vector 19 Iword ddd vector 20 uuu dummy in vector 21 Iword dummy int vector 22 lword dummy int vector 23 Iword dummy int ctor 24 Iword dummy int vector 25 lword dummy int vector 26 Wore dummy int vector 27 Iword glb lword into dummy_ int vector 30 IwaI ector 3 1 Iword dummy int vector 32 Iword dummy in vector 33 Iword dummy_ int vector 34 lword dummy int vector 35 Iword dummy int vector 36 Figure 3.6 Example of Registering to Interrupt Vector Table REJ05B0847-0100/Rev.1.00 January 2007 Page 7 of 10 RENES∧s R8C/25 Group Interrupt handling in c language 4. Reference documents Hardware manual r&C,/25 Group hardware manual The latest version can be downloaded from the renesas Technology website Technical News/Technical Update The latest information can be downloaded from the Renesas Technology website REJ05B0847-0100/Rev.1.00 January 2007 Page 8 of 10
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: R8C族中断处理
 输入关键字,在本站1000多万海量源码库中尽情搜索: