Slide 1
Implementing UART Polling
By Christopher Mar
UART Interactions
Similar to switches and LEDs
UART registers are either written to using sw or read from using lw
Bits positions in command and status register are Boolean values with specific meaning/purpose
UART Addresses
Device Address
Command Register 0xF0000000
Status Register 0xF0000004
Receive Buffer 0xF0000008
In-Class Activity
For this assignment you will be implementing the UART receive process in a function, get_char
The function should use $v0 to return a character
You should only need to add between 6 and 10 instructions to the function
In-Class Activity
This assignment will be due at the end of the day on Wednesday (11:59 pm)
Wednesday will only be used to continue working in class if there are unanswered questions by the end of today.
Please make a note of your breakout room number (they will be randomly assigned)
Wait for ready bit in status register to be 1
————————10
0xF0000004: Status Register
Ready bit
Typical Receive Procedure
Wait for ready bit in status register to be 1
Read byte in receive buffer
0xF0000008: Receive Buffer
——————01001000
Typical Receive Procedure
Typical Receive Procedure
Wait for ready bit in status register to be 1
Read byte in receive buffer
Write a 1 to the clear status bit in the command register
0xF0000000: Command Register
————————10
Clear Status bit
UART get_char Pseudo-Code
do {
cur_status = STATUS_REGISTER; // Read status
cur_status = cur_status & 0b10; // Mask ready bit
}
while(cur_status == 0)
char $v0 = RECEIVE_BUFFER; // Read char from UART
COMMAND_REGISTER = 0b10; // Write clear status bit
Variables in CAPS represent memory locations (consider them dereferenced pointers).
9
Lecture Question
In the template file $s0 contains 0xf0000000. What UART register/buffer would the following instruction read from: lw $t1, 8($s0)
Command register
Status register
Receive buffer
Send buffer
None of the above
In-Class Activity:
Implement get_char
Note: A solution will not be provided for this activity because it is a part of Project 3
/docProps/thumbnail.jpeg