ARM菜鸟外部中断学习笔记.doc_第1页
ARM菜鸟外部中断学习笔记.doc_第2页
ARM菜鸟外部中断学习笔记.doc_第3页
ARM菜鸟外部中断学习笔记.doc_第4页
ARM菜鸟外部中断学习笔记.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ARM菜鸟外部中断学习笔记*- ARM菜鸟外部中断学习笔记HotP 2005.7.21 与西安大雁塔村队部-*/*/* This file is part of the CA ARM C Compiler package */* Copyright KEIL ELEKTRONIK GmbH 2002 - 2004 */*/* */* MAIN.C: Demonstration of various interrupt functions */* */*/#include / Philips Peripheral Registers#include LPC21xxDEF.H /ARM菜鸟HotPower创建定义文件/* software interrupt function accept parameters and run in* supervisor mode (interrupt protected).*/int myfunc1 (int i1, long i2) _swi (8) return (i1 / i2);int myfunc2 (int i1) _swi (9) return (i14);/* standard interrupt function saves only R0 - R12 and returns with*/void DefaultIRQ (void) _irq unsigned int temp; temp = VICIRQStatus; IOPIN1 = (1 P1_15); /取反P1.15void EINT0IRQ (void) _irq unsigned int temp; temp = VICIRQStatus; IOPIN1 = (1 P1_16); /取反P1.16 EXTINT = (1 EINT0); /清除INT0中断标志 VICVectAddr = 0;void EINT1IRQ (void) _irq unsigned int temp; temp = VICIRQStatus; IOPIN1 = (1 P1_14); /取反P1.14 EXTINT = (1 EINT1); /清除INT1中断标志 VICVectAddr = 0;/* fast interrupt function saves only R0 - R7 and returns with*/void FIQ_Handler (void) _fiq /IOSET1 = 0x00010000; / Set pin P1.16/ IOSET1 = (1 P1_15); / Set pin P1.15 IOPIN1 = (1 P1_15); /取反P1.15/EXTINT = 0x00000002; / Clear the peripheral interrupt flag EXTINT = (1 EINT2); /清除INT2中断标志/* task functions have no register save/restore and no return.*/void tsk (void) _task while (1);/* Sample main function*/int res;void main (void) / IODIR1 = 0x00FF0000; / Set the LED pins as outputs IODIR1 = (1 P1_23) | (1 P1_22) | (1 P1_21) | (1 P1_20) |(1 P1_19) | (1 P1_18) | (1 P1_17) | (1 P1_16);/设置LED输出方式/ PINSEL0 = 0x20000000; / Enable the EXTINT1 interrupt PINSEL0 |= (P0_14_EINT1 P0_14_PINSEL);/选择P0.14为INT1外部中断引脚 EXTMODE |= (1 EXTMODE1);/设置INT1为边沿触发,低电平有效 PINSEL1 |= (P0_16_EINT0 P0_16_PINSEL);/选择P0.16为INT0外部中断引脚 EXTMODE |= (1 EXTMODE0);/设置INT1为边沿触发,低电平有效 PINSEL0 |= (P0_15_EINT2 P0_15_PINSEL);/选择P0.15为INT2外部中断引脚 EXTMODE |= (1 EXTMODE2);/设置INT2为边沿触发,低电平有效/ VICVectAddr15 = (unsigned long) DefaultIRQ;/ VICIntSelect = 0x00008000; / Enable a Vic Channel as FIQ VICIntSelect = (1 VICIntSel_EINT2); / Enable a Vic Channel as FIQ/ VICIntSelect = 0; / Enable a Vic Channel as FIQ VICVectCntl0 = VICIntSel_Enable | VICIntSel_EINT0; VICVectAddr0 = (unsigned long *) &EINT0IRQ;/取INT0中断服务地址 VICVectCntl1 = VICIntSel_Enable | VICIntSel_EINT1; VICVectAddr1 = (unsigned long *) &EINT1IRQ;/取INT1中断服务地址/ VICIntEnable = 0x00008000; / Set Default interrupt vector VICIntEnable = (1 VICIntSel_EINT0) | (1 VICIntSel_EINT1) | (1 VICIntSel_EINT2);/使能中断 EXTINT = (1 EINT0) | (1 EINT1) | (1 EINT2); /清除INT中断标志/ VICDefVectAddr = (unsigned long *) &DefaultIRQ;/ VICSoftInt = (1 VICIntSel_EINT1); res = myfunc1 (10, 2); / call SWI functions res += myfunc2 (res); while (1); / endless loopLPC21XXDEF.H/*-文 件 名: LPC21XXDEF.H创 建 人: ARM菜鸟HotP最近修改日期: 2005.7.21创 建 地 点 : 西安大雁塔村队部-*/#ifndef _LPC21xxDEF_H#define _LPC21xxDEF_H#define BV(val) (1 val)#define VICIntSel_Watchdog 0#define VICIntSel_VicInt1 1#define VICIntSel_VicInt2 2#define VICIntSel_VicInt3 3#define VICIntSel_Time0 4#define VICIntSel_Time1 5#define VICIntSel_UART0 6#define VICIntSel_UART1 7#define VICIntSel_PWM 8#define VICIntSel_I2C0 9#define VICIntSel_SPI0 10#define VICIntSel_SSP 11#define VICIntSel_PLLLock 12#define VICIntSel_RTC 13#define VICIntSel_EINT0 14#define VICIntSel_EINT1 15#define VICIntSel_EINT2 16#define VICIntSel_EINT3 17#define VICIntSel_ADC0 18#define VICIntSel_I2C1 19#define VICIntSel_BOD 20#define VICIntSel_ADC1 21#define VICIntSel_VicInt22 22#define VICIntSel_VicInt23 23#define VICIntSel_VicInt24 24#define VICIntSel_VicInt25 25#define VICIntSel_VicInt26 26#define VICIntSel_VicInt27 27#define VICIntSel_VicInt28 28#define VICIntSel_VicInt29 29#define VICIntSel_VicInt30 30#define VICIntSel_VicInt31 31#define VICIntSel_Enable 32/#define P0_0 0/P0.0#define P0_1 1/P0.1#define P0_2 2/P0.2#define P0_3 3/P0.3#define P0_4 4/P0.4#define P0_5 5/P0.5#define P0_6 6/P0.6#define P0_7 7/P0.7#define P0_8 8/P0.8#define P0_9 9/P0.9#define P0_10 10/P0.10#define P0_11 11/P0.11#define P0_12 12/P0.12#define P0_13 13/P0.13#define P0_14 14/P0.14#define P0_15 15/P0.15#define P0_16 16/P0.16#define P0_17 17/P0.17#define P0_18 18/P0.18#define P0_19 19/P0.19#define P0_20 20/P0.20#define P0_21 21/P0.21#define P0_22 22/P0.22#define P0_23 23/P0.23#define P0_24 24/P0.24#define P0_25 25/P0.25#define P0_26 26/P0.26#define P0_27 27/P0.27#define P0_28 28/P0.28#define P0_29 29/P0.29#define P0_30 30/P0.30#define P0_31 31/P0.31/#define P1_0 0/P1.0#define P1_1 1/P1.1#define P1_2 2/P1.2#define P1_3 3/P1.3#define P1_4 4/P1.4#define P1_5 5/P1.5#define P1_6 6/P1.6#define P1_7 7/P1.7#define P1_8 8/P1.8#define P1_9 9/P1.9#define P1_10 10/P1.10#define P1_11 11/P1.11#define P1_12 12/P1.12#define P1_13 13/P1.13#define P1_14 14/P1.14#define P1_15 15/P1.15#define P1_16 16/P1.16#define P1_17 17/P1.17#define P1_18 18/P1.18#define P1_19 19/P1.19#define P1_20 20/P1.20#define P1_21 21/P1.21#define P1_22 22/P1.22#define P1_23 23/P1.23#define P1_24 24/P1.24#define P1_25 25/P1.25#define P1_26 26/P1.26#define P1_27 27/P1.27#define P1_28 28/P1.28#define P1_29 29/P1.29#define P1_30 30/P1.30#define P1_31 31/P1.31#define EXTMODE0 0/EXTMODE.0#define EXTMODE1 1/EXTMODE.1#define EXTMODE2 2/EXTMODE.2#define EXTMODE3 3/EXTMODE.3#define EINT0 0/EXTINT.0#define EINT1 1/EXTINT.1#define EINT2 2/EXTINT.2#define EINT3 3/EXTINT.3/#define P0_0_GPIO 0 #define P0_0_TXD0 1 #define P0_0_PWM1 2#define P0_0_PINSEL 2 * P0_0#define P0_1_GPIO 0 #define P0_1_RXD0 1 #define P0_1_PWM1 2 #define P0_1_EINT0 3#define P0_1_PINSEL 2 * P0_1#define P0_2_GPIO 0 #define P0_2_SCL0 1#define P0_2_PINSEL 2 * P0_2#define P0_3_GPIO 0 #define P0_3_SDA0 1 #define P0_3_EINT1 3#define P0_3_PINSEL 2 * P0_3#define P0_4_GPIO 0#define P0_4_PINSEL 2 * P0_4#define P0_5_GPIO 0#define P0_5_PINSEL 2 * P0_5#define P0_6_GPIO 0#define P0_6_PINSEL 2 * P0_6#define P0_7_GPIO 0#define P0_7_PINSEL 2 * P0_7#define P0_8_GPIO 0#define P0_8_PINSEL 2 * P0_8#define P0_9_GPIO 0#define P0_9_PINSEL 2 * P0_9#define P0_10_GPIO 0#define P0_10_PINSEL 2 * P0_10#define P0_11_GPIO 0#define P0_11_PINSEL 2 * P0_11#define P0_12_GPIO 0#define P0_12_PINSEL 2 * P0_12#define P0_13_GPIO 0#define P0_13_PINSEL 2 * P0_13#define P0_14_GPIO 0 #define P0_14_CD 1/LPC2138 #define P0_14_EINT1 2 #define P0_14_SDA1 3#define P0_14_PINSEL 2 * P0_14#define P0_15_GPIO 0 #define P0_15_RI 1/LPC2138 #define P0_15_EINT2 2#define P0_15_PINSEL 2 * P0_15#define P0_16_GPIO 0 #define P0_16_EINT0 1#define P0_16_PINSEL 2 * P0_0#define P0_17_GPIO 0#define P0_17_PINSEL 2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论