请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TM4C123GH6PM 工具/软件:Code Composer Studio
您好!
我是一个新手、开始了解计时器和按钮。
我的问题是、我想实施一个敏感的 BUTON。 如果按下时间为 Bellew 1s、则打开 LED。 但我总是以 FaultISR()结束。
可以帮助我解决这个问题吗?
此致。
#include #include #include "inc/hw_ints.h"//定义断路器(ej. int_TIMER0A) #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_timer.h" #include "driverlib/sysctm/funiciter.h" (#include)/truniciterlib./funchem.h"(#include)。 //存储脉冲长度 volatile uint32_t puls=0; //告知主代码 在 volatile uint8_t echowait=0时是否正在读取 A 脉冲; // sistama principal int (void) { uint8_t ui8LEDS=0; uint32_t ui32Period; // sistama principal int (void )= 200mctrl (sple_sysctl = 40mctrl) // Peripheracion de Puerto GPIOF (LED) // Habitilia Puerto F SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF); // Configura pines PF1、PF2、y PF3 COMO SALIDAS (控制 LED) GPIOPINTypeGPIOOutput (GPIO_PORLOS_BASE、GPIO_PIN_0_GPIO_PIN_0 ) ;/TOP0_PIN_0_TOP0_GPIO_PERIP_PIN_0_PIN_PIN_0;/TOP0_PIN_TOP0_TOP0_GPIO0_PIN_TOP0_PIN_TOP0_TOP0_TOP0_PIN_TOP0_TOP0_PIN_PIN_PIN_PIN_TOP0_TOP0_TOP0_TOP0_TOP0_TOP0_TOP0_TOP0_PIN_PIN_PIN_ // Configura el Timer0 para cuenta periodica de 32位(no lo separa en TIMER0A y TIMER0B) TimerConfigure (TIMER0_BASE、TIMER_CFG_PERIODIC_UP); // Periodo de cuenta de 0.05s。 SysCtlClockGet () tardara 1 segundo、0.5*SysClockGet ()、0.5*SysClockGet ()、0.5*SysClockGet ()、0.5seg 等。 ui32Period =(SysCtlClockGet ()/10)/2; // Carga la cuenta en el Timer0A TimerLoadSet (TIMER0_BASE、TIMER_A、ui32Period-1); // Habitila interruption del modulo timer//InterLoadSet (INT_TIMER0_BASE、TIMER0A/INBIM0 ) perituituituituituatilita_pertisituer0;// tifruption timeridempertinuere0a timere/ tinuerepertinuere0a timeridempertinuere/ tinuerepertinaturtinuere0a timere/ interruption ButtonInit(); GPIOIntClear (GPIO_PORTF_BASE、GPIO_PIN_4|GPIO_PIN_0); GPIOIntEnable (GPIO_PORTF_BASE、GPIO_PIN_4|GPIO_PIN_0); GPIOIntTypeSet (GPIO_PORTA_BASE、GPIO_PIN_0|GPIO_PEN);GPIO_INT_ENTRS (GPIO_INT_4);GPIO_INT_INT_INT_ENTRS) IntMasterEnable(); // Activa el Timer0A (empezara a funcionar) TimerEnable (TIMER0_BASE、TIMER_A); while (1) { if (echowait!= 1){ if (pulse < 1000000){ GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_1、~GPIO_PIN_1); } while (echowait!= 0); PULSE =(uint32_t)(temp * PULSE); } SysCtlDelay (400000); } }void RutinaISR (void) { uint32_t status; STATUS=GPIOIntStatus (GPIO_PORTF_BASE、TRUE); if (STATUS&GPIO_PIN_4){ TimerEnable (TIMER0_BASE、TIMER_A); echowait=1; } 否则{ 脉冲= TimerValueGet (TIMER0_BASE、TIMER_A); TimerDisable (TIMER0_BASE、TIMER_A); echowait=0; } GPIOIntClear (GPIO_PORTF_BASE、GPIO_PIN_4|GPIO_PIN_0); TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT); }