Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include #include inc / hw _ ints.h #include inc / hw _ memmap.h #include inc / hw _ types.h

#include
#include
#include
#include
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.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 "driverlib/udma.h"
#include "utils/cpu_usage.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "driverlib/timer.h"
uint32_t g_ui32SysClock;
bool g_ledBlinking = false;
uint32_t g_ui32CPUUsage;
#define SYSTICKS_PER_SECOND 100
char myname[10]= "HELLO";
int currentCharIndex =0;
void TimerBegin()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_ONE_SHOT);
TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock *2);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER0_BASE, TIMER_A);
while (!TimerIntStatus(TIMER0_BASE, false))
{
}
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ledBlinking ? GPIO_PIN_0 : 0);
if (!g_ledBlinking)
{
SysCtlDelay(g_ui32SysClock /10); // Add a 100 ms delay
//ndeks artrlr ve eer dizinin sonuna gelinirse tekrar baa dnlr
currentCharIndex =(currentCharIndex +1)% sizeof(myname);
UARTwrite("New Character: ",16);
UARTwrite(&myname[currentCharIndex],1);
UARTwrite("
",1);
}
// Toggle the LED blinking state
g_ledBlinking =!g_ledBlinking;
}
void PrintAsciiCodeAndName(char character)
{
UARTprintf("%c - ASCII Code: %d
", character, character);
}
void PrintMyNameAscii(const char *name)
{
int i;
for (i =0; name[i]!='\0'; i++)
{
char asciiCodeString[5]; // Assuming ASCII codes are 3 digits + null terminator
usprintf(asciiCodeString,"%d", name[i]);
// Print ASCII code and name for the current character
UARTwrite(&name[i],1);
UARTwrite("- ASCII Code: ",15);
UARTwrite(asciiCodeString, strlen(asciiCodeString));
UARTwrite("
",1);
}
// Add a newline character to the UART data stream
UARTCharPutNonBlocking(UART6_BASE, '
');
}
void SysTickHandler(void)
{
}
void uDMAErrorHandler(void)
{
}
void uDMAIntHandler(void)
{
}
void UART1IntHandler(void)
{
}
void ConfigureUART(void)
{
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
MAP_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER0);
MAP_GPIOPinConfigure(GPIO_PP0_U6RX);
MAP_GPIOPinConfigure(GPIO_PP1_U6TX);
MAP_GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0| GPIO_PIN_1);
// Enable UART
UARTEnable(UART6_BASE);
// SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART6);
// Configure UART stdio
UARTStdioConfig(0,115200, g_ui32SysClock);
}
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet(
(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
120000000);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
ConfigureUART();
MAP_SysTickPeriodSet(g_ui32SysClock / SYSTICKS_PER_SECOND);
MAP_SysTickIntEnable();
MAP_SysTickEnable();
while (1)
{
MAP_SysCtlSleep();
}
}
The action I tried to do in the code is as follows; In timerbegin, I set it to send a new string from the char array every time the led goes out and create a 10-element array without pointers called char myname. Finally, a new string will be sent as soon as the led goes out in the TimerBegin() function and this process will be cyclic, for example, after sending all the elements of a 5-element char array, it will return to the beginning and send the first element.Please do not post artificial intelligence answers, I request

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is meant by the term student syndrome?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago