Question
All information on the microprocessor used in this problem can be found here: http://www.ti.com/lit/ds/spms376e/spms376e.pdf In this question, data received by UART 0 will be processed
All information on the microprocessor used in this problem can be found here:
http://www.ti.com/lit/ds/spms376e/spms376e.pdf
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started