---
# System prepended metadata

title: 單晶片系統實驗期中考試

---

# 單晶片系統實驗期中考試

#### 1. (20%) Fill out the following blanks about questions on 8051 microcontroller.  
##### a. How many I/O pins can be used concurrently?  
    At most 32 pins, at least 8 pins.  
##### b. What is the size of on-chip code memory?  
    4k bytes.
##### c. What is the size of on-chip data memory?  
    128 bytes.
##### d. Where is the on-chip general purpose byte-addressable RAM (byte address)?  
    0 - 7FH.
##### e. Where is the on-chip general purpose bit-addressable RAM (bit address)?  
    0 - 7FH.
##### f. Which port of 8051 doesn't have an internal pull up?  
    Port 0.
##### g. How many TTL loads can each pin in port 0 drive?  
    8 TTLs.
##### h. How long at least should the reset (RST) pin hold? At what voltage level?  
    2 machine cycles (2 µs), at HIGH voltage level.
#### 2. (20%) Draw an 8051 reset circuit and explain what it does?
<img src="https://hackmd.io/_uploads/HJvXa6y-C.png" alt="drawing" width="50%"/>

#### 3. (20%) Write an 8051 program segment to delay for 1.65second. Assuming conditional branches take 2 cycles and others take one cycle and the clock is 12MHz.

```=
DELAY: MOV R0, #33
L3:    MOV R1, #100
L2:    MOV R2, #250
L1:    DJNZ R2, L1
       DJNZ R1, L2
       DJNZ R0, L3
       RET
```

#### 4. (20%) Write a few lines of code to implement:

* p1.5 = (p1.2 + /p1.3 )* /p1.1 * p1.0

```=
    MOV C, P1.3
    CPL C
    ORL C, P1.2
    MOV 0, C        ; bit address 0,
    MOV C, P1.1     ; equal to byte address 20.0H
    CPL C
    ANL C, P1.0
    ANL C, 0
    MOV P1.5, C
    
; Quick Version
    MOV C, /P1.3
    ORL C, P1.2
    ANL C, /P1.1
    ANL C, P1.0
    MOV P1.5, C
```
#### 5. (20%) Draw Circuitry for I/O PORT and explain how the write, read, and read modify write work.