完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include "hw_memmap.h"
#include "hw_ints.h" #include "hw_nvic.h" #include "hw_types.h" #include "interrupt.h" #include "sysctl.h" #include "gpio.h" #define LED3 GPIO_PIN_6 #define KEY3 GPIO_PIN_4 #define PINS GPIO_PIN_5 void delay(int d)//延时函数 [ for( ; d; --d); ] int main() [ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPadConfigSet(GPIO_PORTB_BASE, PINS, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);//配置管脚驱动,驱动电流2MA其实已足够 GPIODirModeSet(GPIO_PORTB_BASE, PINS, GPIO_DIR_MODE_OUT);//设置管脚输出 GPIOPadConfigSet(GPIO_PORTB_BASE,KEY3,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); GPIODirModeSet(GPIO_PORTB_BASE,KEY3,GPIO_DIR_MODE_IN); IntMasterEnable(); // IntEnable(INT_GPIOB); //使能B端口中断 GPIOIntTypeSet(GPIO_PORTB_BASE,KEY3,GPIO_FALLING_EDGE); //下降沿中断 // GPIOPinIntEnable(GPIO_PORTB_BASE,KEY3); //使能中断 while(1) [ GPIOPinWrite(GPIO_PORTB_BASE, PINS, PINS);//输出高电平 delay(20000);//延时 GPIOPinWrite(GPIO_PORTB_BASE, PINS, ~PINS);//输出低电平 delay(20000);//延时 ] ] void GPIO_Port_B_ISR(void) [ long IntStatus; IntStatus=GPIOPinIntStatus(GPIO_PORTB_BASE,true); GPIOPinIntClear(GPIO_PORTB_BASE,IntStatus); if(IntStatus&KEY3) [ GPIOPinWrite(GPIO_PORTB_BASE,LED3,LED3^GPIOPinRead(GPIO_PORTB_BASE,LED3)); ] ] // IntEnable(INT_GPIOB); //使能B端口中断 // GPIOPinIntEnable(GPIO_PORTB_BASE,KEY3); //使能中断 为什么要屏蔽这两个才能进入死循环 while(1) 如果不屏蔽的话死循环的点灯就不会执行 且中断也没反应。 不知道 是不是哪设置的不对啊! 是在proteus仿真下试验的 |
|
相关推荐
5个回答
|
|
startup_ewarm.c 的配置如下
//***************************************************************************** // // startup_ewarm.c - Startup code for use with IAR's Embedded Workbench, // version 5. // // Copyright (c) 2006-2012 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 8555 of the EK-LM3S811 Firmware Package. // //***************************************************************************** //***************************************************************************** // // Enable the IAR extensions for this source file. // //***************************************************************************** #pragma language=extended //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); void GPIO_Port_B_ISR(void); //没加 extern 关键字 //***************************************************************************** // // The entry point for the application startup code. // //***************************************************************************** extern void __iar_program_start(void); //***************************************************************************** // // Reserve space for the system stack. // //***************************************************************************** static unsigned long pulStack[64] @ ".noinit"; //***************************************************************************** // // A union that describes the entries of the vector table. The union is needed // since the first entry is the stack pointer and the remainder are function // pointers. // //***************************************************************************** typedef union [ void (*pfnHandler)(void); unsigned long ulPtr; ] uVectorEntry; //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** __root const uVectorEntry __vector_table[] @ ".intvec" = [ [ .ulPtr = (unsigned long)pulStack + sizeof(pulStack) ], // __iar_program_start, // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler IntDefaultHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A GPIO_Port_B_ISR, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 IntDefaultHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer IntDefaultHandler, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B IntDefaultHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler // FLASH Control ]; //***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) [ // // Call the application's entry point. // __iar_program_start(); ] //***************************************************************************** // // This is the code that gets called when the processor receives a NMI. This // simply enters an infinite loop, preserving the system state for examination // by a debugger. // //***************************************************************************** static void NmiSR(void) [ // // Enter an infinite loop. // while(1) [ ] ] //***************************************************************************** // // This is the code that gets called when the processor receives a fault // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void FaultISR(void) [ // // Enter an infinite loop. // while(1) [ ] ] //***************************************************************************** // // This is the code that gets called when the processor receives an unexpected // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) [ // // Go into an infinite loop. // while(1) [ ] ] |
|
|
|
|
|
|
|
楼主检查下你中断向量表中中断的位置,看看是否正确,有可能跑到别的中断里去了
可以不用startup代码,参考driverlib的例程写一个试试: int iVal; // // Register the port-level interrupt handler. This handler is the // first level interrupt handler for all the pin interrupts. // GPIOPortIntRegister(GPIO_PORTA_BASE, PortAIntHandler); // // Initialize the GPIO pin configuration. // // Set pins 2, 4, and 5 as input, SW controlled. // GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5); // // Set pins 0 and 3 as output, SW controlled. // GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_3); // // Make pins 2 and 4 rising edge triggered interrupts. // GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4, GPIO_RISING_EDGE); // // Make pin 5 high level triggered interrupts. // GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_5, GPIO_HIGH_LEVEL); // // Read some pins. // iVal = GPIOPinRead(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5)); // // Write some pins. Even though pins 2, 4, and 5 are specified, those // pins are unaffected by this write because they are configured as inputs. // At the end of this write, pin 0 will be a 0, and pin 3 will be a 1. // GPIOPinWrite(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5), 0xF8); // // Enable the pin interrupts. // GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5); |
|
|
|
vmmjuwy 发表于 2018-5-14 01:23 问题解决了,中断跟Backup of driverlib.a 也是有关系的。 我用TI函数库中的D:StellarisWaredriverlibewarm-cm3Exedriverlib-cm3.a这个文件一直进不了中断。。后来按照周立功的做法用IAR得新生成的Backup of driverlib.a 进中断可以。。 |
|
|
|
shuqingli 发表于 2018-5-14 01:34 fanhuaming : 这种软件仿真的很多东西不可信。。。 |
|
|
|
只有小组成员才能发言,加入小组>>
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
580 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1034 浏览 1 评论
685 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
503 浏览 1 评论
1028 浏览 0 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
133浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
105浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
114浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
112浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
141浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-11 05:04 , Processed in 0.789216 second(s), Total 88, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号