Question: In this question data received by UART 0 will be processed by an Interrupt Service Routine. a ) Write the serial _ init ( )

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:
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()
{
//Binds UART0 interrupt requests to My_UART0_RX_Handler
IntRegister(INT_UART1, My_UART0_Handler);
IntMasterEnable();//Globally allows CPU to service interrupts
}
b) Write code for My_UART0_Handler 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.
// UART0 ISR
void My_UART0_Handler()
{
}
c) Complete main() to print LED turned ON and LED turned OFF once each time the LED is turned on or off respectively.
void My_UART0_Handler();
void serial_init(void);
volatile int flag =0; // Helper variable
int main()
{
init_portB(); // Assume implemented correctly in Question 2
serial_init();
while (1)
{
//Print each time the LED is turned ON or OFF
//Hint: make use the helper variable flag declared above.
// YOUR CODE HERE
}
return 0;
}

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!