1 / 22

Chapter IV : 實作練習

Chapter IV : 實作練習. 晶 片 程 式 設 計 中華技術學院電子系. 實習一. BASIC INPUT OUTPUT PORT. ( 一 ) Specification. Hardware: J11(P2) <> J6 ( 七段顯示器 ) J12(P0) <> J13(LED) J9(P1) <> J19(DIP-SW) Software: (1) 七段顯示器由 0 到 F, 每隔 x ms 循環顯示

zoe-noble
Download Presentation

Chapter IV : 實作練習

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter IV : 實作練習 晶 片 程 式 設 計 中華技術學院電子系

  2. 實習一 BASIC INPUT OUTPUT PORT

  3. (一) Specification • Hardware: J11(P2) <> J6 (七段顯示器) J12(P0) <> J13(LED) J9(P1) <> J19(DIP-SW) • Software: (1) 七段顯示器由 0 到 F, 每隔 x ms 循環顯示 (2) 偵測 DIP-SW 的內容, 讀取後將相對應資料顯示於 LED 上, 其中 on: LED ON , off: LED OFF (3) 利用DIP-SW值來決定 x, 0000=500, 0001=600, 0010=700,… • Module Planning:

  4. (1) DELAY_01MS PUBLIC DELAY_01MS ROM SEGMENT CODE RSEG ROM DELAY_01MS: MOV R3,#48 NOP DJNZ R3,$ DJNZ R4,DELAY_01MS RET END

  5. (2) DELAY_10MS PUBLIC DELAY_10MS ROM SEGMENT CODE RSEG ROM DELAY_10MS: MOV R4,#100 DELAY1: MOV R3,#48 NOP DJNZ R3,$ DJNZ R4,DELAY1 DJNZ R5,DELAY_10MS RET END

  6. (3) FLOOK_TABLE PUBLIC FLOOK_TABLE ROM SEGMENT CODE RSEG ROM FLOOK_TABLE: MOV A,R1 MOVC A,@A+DPTR MOV R2,A RET END

  7. (4) BLOOK_TABLE PUBLIC BLOOK_TABLE ROM SEGMENT CODE RSEG ROM BLOOK_TABLE: MOV R1,#00H BL1: MOV A,R1 MOVC A,@A+DPTR XRL A,R2 JNZ BL2 JMP BL3 BL2: INC R1 DJNZ R3,BL1 MOV R1,#0FFH BL3: RET END

  8. 實習二 3X4 SCAN KEYBOARD

  9. (一) Keyboard Layout Row1 Row2 1 2 3 Scan Line Row3 4 5 6 Row4 Col1 7 8 9 Return Line Col2 * 0 # Col3 Scan Line : 1110  Trace Row1 (1 2 3)  Return Line Scan Line : 1101  Trace Row2 (4 5 6)  Return Line Scan Line : 1011  Trace Row3 (7 8 9)  Return Line Scan Line : 0111  Trace Row4 (* 0 #)  Return Line

  10. (二) Key Code 9 1 5 0 2 6 1 2 3 * 0 4 5 6 3 7 0 0 7 9 8 4 8 # 0 * 0 #

  11. (三) 程式流程 (C.1) • 檢查是否所有按鍵均被鬆開 SCAN_KEYBOARD: MOV KEY_PORT,#11110000B MOV A,KEY_PORT XRL A,#11110000B JNZ SCAN_KEYBOARD

  12. 程式流程 (C.2) (2) 設定掃描參數 SCAN_4: MOV R2,#7FH MOV R1,#04H (3) 輸出掃描參數 SCAN_3: MOV A,R2 RL A MOV KEY_PORT,A MOV R2,A

  13. 程式流程 (C.3) (4) 輸入返回線 MOV A,KEY_PORT (5) 測試是否有鍵被按? XRL A,R2 JZ SCAN_1 (6) 解彈跳 (Debounce) CALLDELAY (7) 再一次輸入返回線作 Double Check MOV A,KEY_PORT XRL A,R2 JNZ SCAN_2

  14. 程式流程 (C.4) (8) 沒鍵被按 SCAN_1: DJNZ R1,SCAN_3 JMP SCAN_4 • 有鍵被按 SCAN_2: MOV R2,KEY_PORT RET END

  15. (四) Specification • Hardware: J11(P2) <> J2 (3x4KEYBOARD) J12(P0) <> J13(LED) • Software: (1) 設計 SCAN_KEYBOARD 模組 (2) 將讀取到的鍵碼顯示在 P0 的 LED 上 (3) 將讀取到的鍵值顯示在 P0 的七段顯示器上

  16. 實習三 TEXT MODE LCD MODULE

  17. 4-1 HD44780 Feature • Display Data RAM : 80*8 Bytes • Character Generator ROM : 內建160個 5*7 字型 Table 5-5 • Character Generator RAM : 自行規劃 8 個 5*7 字型 Table 5-6 造字 • 四/八位元 MPU Interface • 內建 10 個控制命令碼 Table 5-7 LCD 指令集

  18. 4-2 LCM Pin Layout Pin 4. RS : Register Select RS=0: Instruction Register RS=1: Data Register Pin 5. R/W: Read / Write Pin 6. E : Switch

  19. 4-3 Display Principle • 假如希望在LCD某個位置顯示某個字型, 請將該字型的ASCII碼寫入相對應的DD RAM位址中 1 2 3 4 5 6 7 8 9 10 A F DD RAM (ASCII Code)

  20. 4-4 LCM Access Control • Instruction Register IR: 存取 LCM 指令碼 (only write) • Data Register DR: 存取 LCM 顯示資料 ( read & write) RS R/W Operation Mode 0 0 Command IR 0 1 U’C BF & AC 1 0 Display Data DR 1 1 U’C Display Data

  21. 4-5 LCM Access Timing RS WLCD_COMMAND R/W WLCD_DATA E Data

  22. 4-6 Example

More Related