Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tiva TM 4 C 1 2 9 4 #include #include #include inc / hw _ gpio.h #include inc / hw _ ints.h #include

Tiva TM4C1294
#include
#include
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "drivers/buttons.h"
#include
#include "driverlib/timer.h"
#define LED_PIN2 GPIO_PIN_2
#define LED_PIN GPIO_PIN_0
uint32_t g_ui32SysClock;
bool g_ledBlinking = true; // Global variable to track LED blinking state
volatile uint32_t g_ui32Mode;
#ifdef DEBUG
void __error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
/*void Timer(uint32_t duration_seconds){
uint32_t delayCycles = duration_seconds *(SysCtlClockGet()/1);
while (delayCycles >0){
GPIO_PORTN_DATA_R ^= LED_PIN; // Toggle LED state
SysCtlDelay((SysCtlClockGet()/1/1000)); // Delay for 1 millisecond
delayCycles--;
}
}
*/
void LedBlinkingTask(){
// If the LED is on, turn it off. Turn it on if it is off.
if (GPIO_PORTN_DATA_R & LED_PIN){
GPIO_PORTN_DATA_R &= ~LED_PIN; // LED'i sndr
} else {
GPIO_PORTN_DATA_R |= LED_PIN; // LED'i yak
}
}
uint32_t g_ui32SysClock;
volatile uint32_t g_ui32Mode;
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void
SysTickIntHandler(void)
{
}
void TimerBegin(){
uint32_t Period;
Period =2000; //2 saniyelik gecikme salayc
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5);
SysCtlDelay(3);
TimerConfigure(TIMER5_BASE, TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER5_BASE, TIMER_A, Period -1);
TimerIntRegister(TIMER5_BASE, TIMER_A, LedBlinkingTask);
TimerIntEnable(TIMER5_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER5_BASE, TIMER_A);
}
void ConfigureUART(void){
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0| GPIO_PIN_1);
UARTStdioConfig(0,115200, g_ui32SysClock);
}
int main(void){
MAP_SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480,120000000);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0| GPIO_PIN_1);
MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0| GPIO_PIN_1);
MAP_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_0| GPIO_PIN_1| GPIO_PIN_2| GPIO_PIN_3);
MAP_GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0| GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
MAP_GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_0| GPIO_PIN_1| GPIO_PIN_2| GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
g_ui32SysClock = SysCtlClockGet();
MAP_SysTickPeriodSet(g_ui32SysClock /1000);
MAP_SysTickEnable();
MAP_SysTickIntEnable();
ConfigureUART();
TimerBegin();
while (1){
SysCtlDelay(100000);
}
}
I just want the led to light up at 2 second intervals by calling the TimerBegin function in the main, and the button (USR_SW1) should trigger the TimerBegin() function, in summary, after clicking the button, TimerBegin() will run and the led will turn on and off at 2 second intervals.
Please don't share AI codes, they don't work

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago