Question 4: UART Receiving a byte Interrupt Hardware
The figure below shows a simplified hardware architecture for the UART interrupts sub-system. It is composed of software programmable registers (IM, RIS, MIS, ICR), along with logic gates. In this question you will design a circuit to complete the UART interrupt sub-system hardware. You will then complete software to make use of this simplified UART interrupt sub-system.
a) Design a CPRE 281 style digital circuit to place in the “Falling Edge Detector” box of the UART Interrupt sub-system. This will be used to detect when a new UART frame begins to arrive. Recall the start symbol of a UART frame is indicated by the UART RX wire transitioning from high to low (i.e. a falling or negative edge occurs). To keep your circuit simple, use to following assumptions:
· Your circuit should pulse the “detect” signal for 1 clock cycle whenever a falling edge on the RX wire occurs. In other words, “detect” should become ‘1’ for exactly one clock cycle.
· You are limited to using the following types of components: AND, OR, NOT, XOR, D Flip-Flops
· Your circuit should use at least 1 D Flip-Flop, but not more than 2. And you can use at most 4 total components.
· Assume anytime the RX wire goes low it will stay low for at least one clock cycle.
· Falling Edge Detector
o Inputs: UART RX wire, and a clock
o Output: detect signal
b) Provide code to complete init_UART() and My_UART_Handler().
volatile int flag = 0; // Helper variable
int main()
{
init_UART(); // Initializes the GPIO and UART
while (1)
{
//Print each time a new UART Frame begins
if(flag == 1)
{
printf(“Starting to Receive a new UART Frame \n”);
flag = 0; reset flag.
}
}
return 0;
}
void init_UART()
{
// Assume GPIO has already been initialized for you.
// Assume all aspects of the UART except interrupts have been
// configured for you
// Assume the register size of IM, RIS, MIS, and ICR are 1 bit
// Assume these register names have been memory mapped so you
// can directly assign values to these names.
// Place YOUR CODE HERE to enable the Start of Frame Interrupt
// Assume the NVIC has been configured for you
//Binds UART interrupt requests to My_UART_Handler
IntRegister(INT_UART, My_UART_Handler);
}
// UART ISR (Give code for the ISR)
void My_UART_Handler()
{
// Check if an Interrupt has really occurred
// Set flag so main() knows interrupt occurred
// clear the Interrupt.
}