CS计算机代考程序代写 gui UART

UART

UART
By Christopher Mar

UART on PLP Board Demo
Available in Video Lecture

2

PLPTool Interface
Simulates external UART device connected to PLP UART

UART
Universal Asynchronous Receiver/Transmitter
Used for serial communication
At most one wire per direction of data
Sent sequentially one bit at a time

UART
Other common serial interfaces include:
USB
SATA
RS-232
SPI
I2C

ASCII
Computers only “understand” binary so how are characters represented?
ASCII character encodings
American Standard Code of Information Interchange

ASCII
Each character is represented by 7-bit value
Character Decimal Value Hex Value
‘A’ 65 0x41
‘Z’ 90 0x5A
‘a’ 97 0x61
‘z’ 122 0x7A
‘.’ (Period) 46 0x2E

Character Strings
Sequence of characters
Null terminated string ends with a null character (‘\0’)
Has an ASCII value of zero
Terminating character can be any character agreed upon by sender and receiver

I/O Device: UART

I/O Device: UART

I/O Device: UART

I/O Device: UART

I/O Device: UART

UART Registers
Command register (0xf0000000)
Write-only
Bit at 21 position: clear status bit
Used to indicate to UART that your program has read current byte
Status register (0xf0000004)
Read-only
Bit at 21 position: ready bit
Indicates a byte has been received by the UART

UART Buffers
Receive buffer (0xf0000008)
Read-only
Contains most recent byte received by UART
Send buffer (0xf000000c)
Not used in Project 3

Polling
Also called busy waiting
Loop waiting for an I/O device status to change to a specific condition
Exit loop when condition is met
Poll UART ready bit waiting for new character

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x00
PLP
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
PLP UART
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x00
PLP
Send buffer:
1
5
;

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x31
PLP
Send buffer:
5
;
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x31
PLP
Send buffer:
5
;
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x31
PLP
Send buffer:
5
;
0x31
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x31
PLP
Send buffer:
5
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x31
PLP
Send buffer:
5
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x31
PLP
Send buffer:
5
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x35
PLP
Send buffer:
;
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x35
PLP
Send buffer:
;
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x35
PLP
Send buffer:
;
0x35
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x35
PLP
Send buffer:
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x35
PLP
Send buffer:
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x35
PLP
Send buffer:
;
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x3B
PLP
Send buffer:
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x3B
PLP
Send buffer:
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x3B
PLP
Send buffer:
0x3B
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b11
Receive Buffer: 0x3B
PLP
Send buffer:
0b10
PLP UART

I/O Device: UART
External Device
UART
(PLPTool GUI UART)

RX
TX
TX
RX
Command Register
Status Register: 0b01
Receive Buffer: 0x3B
PLP
Send buffer:
PLP UART

Bit Masking
Used to isolate specific bits in a value
Bit masking takes advantage of AND operation
Only the bits set in your mask are the ones that will be kept

Bit Masking
Example: put the isolate the third bit of $t0 in $t2
li $t1, 0b100
Create a mask
AND value register with mask
and $t2, $t0, $t1

Bit Masking
Example: put the isolate the third bit of $t0 in $t2
If $t0 contained 0b1101
0b1101
0b0100
Value
Mask
Result
0b0100

Bit Masking
Example: put the isolate the third bit of $t0 in $t2
If $t0 contained 0b0010
0b0010
0b0100
Value
Mask
Result
0b0000

Memory Access Offset
Address Contents
0xF0000000 0x00000000
0xF0000004 0x00000001
0xF0000008 0x00000000
0xF000000C 0x00000000

li $s0, 0xf0000000
$s0

Memory Access Offset
Address Contents
0xF0000000 0x00000000
0xF0000004 0x00000001
0xF0000008 0x00000000
0xF000000C 0x00000000

$s0
li $s0, 0xf0000000
lw $t1, 4($s0) #UART Status Register
$t1
Copied
$s0 + 4

Modularity and Comparisons