Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

With respect to TM4C123 In this question, data received by UART 0 will be processed by an Interrupt Service Routine. a) Write the serial_init() function

With respect to TM4C123

In this question, data received by UART 0 will be processed by an Interrupt Service Routine.

a) Write the serial_init() function to initialize UART0 as follows [7pts]:

Receive Only

9,600 baud rate

8 data bits

Even parity

2 stop bit

Disable FIFOs

Enable UART Receive interrupts only

You may initialize unrelated control bits as you wish.

// Initialize UART0

void serial_init()

{

// 1. Setup GPIO

//A. Configure GPIO module associated with UART 0

// i. Turn on clock for GPIO module Port A

// ii.Enable Alternate function and set Peripheral functionality

// iii. set digital or analog mode, and pin directions

// 2. Setup UART device

// A) Configure UART functionality, frame format and Baud speed

//Disable uart0 device while we set it up

// Set desired UART functionality

//set frame format: 8 data bits, no FIFO, 2 stop bit, Even parity

//Set baud rate (9600 Baud)

//Use system clock as UART clock source

// B) Setup UART 0 Interrupts

// 3. NVIC setup

// A) Configure NVIC to allow UART interrupts

// B) Bind UART0 interrupt requests to Users Interrupt Handler

IntRegister( ); //complete this function

//re-enable uart

}

b) Write code for UART0 ISR handler function to implement the Interrupt Service Routine (ISR) that processes the occurrence of a UART0 received data interrupt. In addition, within this ISR turn on an LED connected to GPIO Port B pin 3 when an L (for Light) is received by UART0 by writing a 1 to the LED, and turn off this LED when an O (for Off) is received by writing a 0 to the LED. [7pts]

// UART0 Sample ISR

void My_UART0_Handler()

{

// 1) Check if Handler called due to a RX event

// 2) Clear the RX Interrupt Status. Why are we doing this //step ?

// 3) Application specific functionality

// Get byte from UART

// Check if an O or L ASCII charter was received

}

c) Complete main() to print LED turned ON and LED turned OFF once each time the LED is turned on or off respectively. [6pts]

void My_UART0_Handler();

void serial_init(void);

int main()

{

init_portB(); // Assume implemented correctly in Question 2

serial_init();

IntMasterEnable();//Globally allows CPU to service interrupts

while (1)

{

//Print each time the LED is turned ON or OFF

// YOUR CODE HERE

}

return 0;

}

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

=+ How would you advise those problems be resolved?

Answered: 1 week ago