完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
#include #include "inc/hw_types.h" //定义常用的宏 #include "inc/hw_memmap.h" //定义功能存储映射 #include "inc/hw_ints.h" #include "grlib/grlib.h" #include "driverlib/debug.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/interrupt.h" //定义中断分配数 #include "driverlib/systick.h" #include "driverlib/watchdog.h" #include "driverlib/timer.h" #define LED_PERIPH SYSCTL_PERIPH_GPIOF #define LED_PORT GPIO_PORTF_BASE #define LED_PIN_RED GPIO_PIN_1 #define LED_PIN_BLUE GPIO_PIN_2 #define LED_PIN_GREEN GPIO_PIN_3 #define BUTTON_PIN GPIO_PIN_4 #define BUTTON_INT INT_GPIOF bool button_pressed = false; void gpiof_int_isr(void) { static bool is_led_on = false; uint32_t gpio_ints; uint32_t gpio_val; gpio_ints = GPIOIntStatus(LED_PORT,true); GPIOIntClear(LED_PORT,gpio_ints); gpio_val = GPIOPinRead(LED_PORT,BUTTON_PIN); if((gpio_val & BUTTON_PIN) == BUTTON_PIN) { button_pressed = false; } else { button_pressed = true; } } int main(void) { uint8_t i_times; SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN); //使能外设 SysCtlPeripheralEnable(LED_PERIPH); GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN_RED); GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN_BLUE); GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN_GREEN); //配置GPIO端口为输入,弱上拉 GPIODirModeSet(LED_PORT,BUTTON_PIN,GPIO_DIR_MODE_IN); GPIOPadConfigSet(LED_PORT,BUTTON_PIN,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //配置GPIO中断 IntMasterEnable(); IntEnable(BUTTON_INT); GPIOIntTypeSet(LED_PORT,BUTTON_PIN,GPIO_BOTH_EDGES); GPIOIntEnable(LED_PORT,BUTTON_PIN); GPIOIntRegister(LED_PORT,gpiof_int_isr); //等待系统时钟初始化 SysCtlDelay(100000); //初始化看门狗 if(WatchdogLockState(WATCHDOG0_BASE) == true) { WatchdogUnlock(WATCHDOG0_BASE); } //设置看门狗调试时暂停 WatchdogStallEnable(WATCHDOG0_BASE); //设置看门狗定时器 WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); //使能看门狗复位 WatchdogResetEnable(WATCHDOG0_BASE); //使能看门狗 WatchdogEnable(WATCHDOG0_BASE); //锁定看门狗 WatchdogLock(WATCHDOG0_BASE); for(i_times = 0;i_times < 3;i_times ++) //闪烁绿色 LED灯 { SysCtlDelay(SysCtlClockGet()/16); GPIOPinWrite(LED_PORT, LED_PIN_GREEN, LED_PIN_GREEN); SysCtlDelay(SysCtlClockGet()/16); GPIOPinWrite(LED_PORT, LED_PIN_GREEN, ~LED_PIN_GREEN); } while(true) //闪烁红色 LED灯 { SysCtlDelay(SysCtlClockGet()/16); GPIOPinWrite(LED_PORT, LED_PIN_RED, LED_PIN_RED); SysCtlDelay(SysCtlClockGet()/16); GPIOPinWrite(LED_PORT, LED_PIN_RED, ~LED_PIN_RED); } //喂狗 if(button_pressed == false) { WatchdogUnlock(WATCHDOG0_BASE); WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); WatchdogLock(WATCHDOG0_BASE); } } 为什么每次运行到 if(WatchdogLockState(WATCHDOG0_BASE) == true) { WatchdogUnlock(WATCHDOG0_BASE); } 程序就会进入死循环中。 static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } 请问谁能帮解决一下? |
|
相关推荐
1个回答
|
|
自己已经解决,凡事靠自己
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
飞凌嵌入式ElfBoard ELF 1板卡-CAN编程示例之开发板测试
852 浏览 0 评论
该问题是用APP给芯海科技的CST92F25芯片发指令是出现的
2844 浏览 1 评论
867 浏览 0 评论
1710 浏览 1 评论
2758 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 03:06 , Processed in 1.014616 second(s), Total 79, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号