Answered step by step
Verified Expert Solution
Question
1 Approved Answer
TM 4 C 1 2 9 4 After clicking the button, why does the led stay on continuously, or I may not notice it because
TMC After clicking the button, why does the led stay on continuously, or I may not notice it because it flashes too fast, I need to fix this, for example, if I reduce the time the led flashes to seconds ie seconds on seconds off this will be much better
#include #include
#include "inchwgpio.h
#include "inchwints.h
#include "inchwmemmap.h
#include "inchwtypes.h
#include "driverlibdebugh
#include "driverlibfpuh
#include "driverlibgpioh
#include "driverlibinterrupth
#include "driverlibpinmap.h
#include "driverlibromh
#include "driverlibrommap.h
#include "driverlibsysctlh
#include "driverlibsystickh
#include "driverlibuarth
#include "utilsuartstdioh
#include "driversbuttonsh
#include
#include "driverlibtimerh
#define LEDPIN GPIOPIN Define LED pin mask
#define LEDPIN GPIOPIN
uintt guiSysClock;
bool gledBlinking false; Global variable to track LED blinking state
volatile uintt guiMode;
#ifdef DEBUG
void errorchar pcFilename uintt uiLine
#endif
void LedBlinkingTask
if gledBlinking
UARTprintfLED OFF
;
GPIOPORTNDATAR & ~LEDPIN;
gledBlinking false;
TimerIntClearTIMERBASE, TIMERTIMATIMEOUT;
else
UARTprintfLED ON
;
GPIOPORTNDATAR LEDPIN;
gledBlinking true;
void TimerBegin
SysCtlPeripheralEnableSYSCTLPERIPHTIMER;
TimerIntRegisterTIMERBASE, TIMERA LedBlinkingTask;
TimerLoadSetTIMERBASE, TIMERA guiSysClock ;
TimerIntEnableTIMERBASE, TIMERTIMATIMEOUT;
TimerEnableTIMERBASE, TIMERA;
void SysTickIntHandlervoid
uintt uiButtons;
uintt uiButtonsChanged;
Grab the current, debounced state of the buttons.
uiButtons ButtonsPoll&uiButtonsChanged, ;
Toggle the pin mode.
guiMode ;
ifBUTTONPRESSEDUSRSW uiButtons, uiButtonsChanged
gledBlinking true;
TimerBegin;
else gledBlinking false;
void ConfigureUARTvoid
MAPSysCtlPeripheralEnableSYSCTLPERIPHGPIOA;
MAPSysCtlPeripheralEnableSYSCTLPERIPHUART;
MAPGPIOPinConfigureGPIOPAURX;
MAPGPIOPinConfigureGPIOPAUTX;
MAPGPIOPinTypeUARTGPIOPORTABASE, GPIOPIN GPIOPIN;
UARTStdioConfig guiSysClock;
int mainvoid
MAPSysCtlClockFreqSetSYSCTLXTALMHZ SYSCTLOSCMAIN SYSCTLUSEPLL SYSCTLCFGVCO;
MAPSysCtlPeripheralEnableSYSCTLPERIPHGPION;
MAPSysCtlPeripheralEnableSYSCTLPERIPHGPIOJ;
MAPSysCtlPeripheralEnableSYSCTLPERIPHGPIOC;
MAPGPIOPinTypeGPIOOutputGPIOPORTNBASE, GPIOPIN GPIOPIN;
MAPGPIOPinTypeGPIOInputGPIOPORTJBASE, GPIOPIN GPIOPIN;
MAPGPIOPinTypeGPIOInputGPIOPORTCBASE, GPIOPIN GPIOPIN GPIOPIN GPIOPIN;
MAPGPIOPadConfigSetGPIOPORTJBASE, GPIOPIN GPIOPIN GPIOSTRENGTHMA GPIOPINTYPESTDWPU;
MAPGPIOPadConfigSetGPIOPORTCBASE, GPIOPIN GPIOPIN GPIOPIN GPIOPIN GPIOSTRENGTHMA GPIOPINTYPESTDWPU;
guiSysClock SysCtlClockGet;
guiSysClock MAPSysCtlClockFreqSetSYSCTLXTALMHZ
SYSCTLOSCMAIN
SYSCTLUSEPLL
SYSCTLCFGVCO;
MAPSysTickPeriodSetguiSysClock ;
MAPSysTickEnable;
MAPSysTickIntEnable;
ConfigureUART;
TimerBegin;
GPIOPORTNDATAR & ~LEDPIN; Birinci LED'i sndr
while
SysCtlDelay;
Please dont use ai answers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started