Question: Need help fixing this code. #include TM 4 C 1 2 9 . h #include Lab 2 _ Thu.h #include TM

Need help fixing this code. #include "TM4C129.h"
#include "Lab2_Thu.h"
#include "TM4C1294NCPDT.h"
// Function to setup GPIO for UART6
void setup_GPIO(void){
// Enable the clock for the GPIO port that UART6 uses (assuming it's port P)
SYSCTL->RCGCGPIO |=(1<<12); // Enable clock for GPIO Port P
while ((SYSCTL->PRGPIO & (1<<12))==0); // Wait for the clock to be ready
// Enable the clock for UART6
SYSCTL->RCGCUART |=(1<<6); // Enable clock for UART6
while ((SYSCTL->PRUART & (1<<6))==0); // Wait for the clock to be ready
// Configure GPIO pins for UART6
GPIOP->AFSEL |=(1<<0)|(1<<1); // Enable alternate function on PP0 and PP1
GPIOP->PCTL =(GPIOP->PCTL & ~0x000000FF)|(0x00000001<<0)|(0x00000001<<4); // Set PCTL for UART6
GPIOP->DEN |=(1<<0)|(1<<1); // Enable digital function on PP0 and PP1
}
// Function to setup UART6
void setup_UART(void){
// Disable UART6 before configuration
UART6->CTL &= ~UART_CTL_UARTEN; -ERROR
// Set baud rate
uint32_t brd =80000000/(16*115200); // Integer part of the BRD
uint32_t fbrd =(80000000%(16*115200))*64/(16*115200)+0.5; // Fractional part of the BRD
UART6->IBRD = brd;
UART6->FBRD = fbrd;
// Set UART6 configuration: 8-bit data, odd parity, 1 stop bit
UART6->LCRH = UART_LCRH_WLEN_8| UART_LCRH_PEN | UART_LCRH_EPS | UART_LCRH_STP2; -ERROR
// Enable UART6
UART6->CTL = UART_CTL_UARTEN | UART_CTL_TXE | UART_CTL_RXE; -ERROR
}
int main(void){
uint8_t c;
setSysClk80MHz(); // Do NOT remove. Set the System clock to 80MHz
RedirectOutput(); // Do NOT remove. Redirect output from U3 to the terminal via U4
setup_GPIO(); // Rewrite function for Part 1
setup_UART(); // Rewrite function for Part 2
banner("Start typing. You should see the keys echoed on the terminal");
// ECHO loop
while (1){
// Echo keys back to you
// This tests your connection
c = read_UART(); // Read from UART (rewrite function for Part 3)
write_UART(c); // Write to UART (rewrite function for Part 4)
}
return 0;
}
THIS CODE IS ON KEIL UVISION FOR TIVA BOARD, TO MEET TASK:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!