# Lab4 Note ###### tags: `NCTU` `MPSL` **Question 1: What’s the functions of DIN, CLK, CS pins on MAX7219 7-Seg LED? MAX7219 7-Seg LED 上的 DIN, CLK, CS 腳位分別有什麼作用?** - DIN - CLK - CS 讀完up **Question 2 : Each time we send a command to MAX7219, we need to encode our command into 2-bytes, Address, and Data. What are the functions of Address(D8~D15) and Data(D0~D7)? 每次向MAX7219發送命令時,都需要將命令編碼為2個字節,地址和數據。 地址(D8〜D15)和數據(D0〜D7)的功能是什麼?** | 暫存器名稱 | 位址 | 說明 | | ------------ | -------- | -------- | | Data | 0x01~0x08| 控制位數 | | Decode Mode | 0x09 | 開啟/關閉decode模式 | | Intensity | 0x0A | 調整顯示器亮度 | | Scan Limit | 0x0B | 設定欲啟動的顯示器數目(1~8) | Shutdown | 0x0C | 0開啟/1關閉顯示模組 | Display Test | 0x0F | 0開啟/1關閉測是模組 (顯示器的所有筆畫皆會亮起) 發送指令的方式為: 拉低 LOAD 訊號、在 CLK 訊號打 16 個時脈的過程中,透過 DIN 腳位依序把 16-bit 的指令送進 MAX7219,送完後拉高 LOAD 訊號即完成一筆指令的傳輸。對應的時序圖示意為: ### Demo Question **4-1 Question** 1. Code B decode mode 並沒有 **d** 的符號。因此必需要自己手刻 pattern。說說 pattern 是如何決定的。即 D0~D7 要如何設定? | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | | -- | -- | -- | -- | -- | -- | -- | -- | | DP | A | B | C | D | E | F | G | A F B G E C F DP **4-2 Question** 1. 請說明 code B decode mode 的 pattenr 是如何決定的?即 D0~D7 如何設置? Ans. 可以分別設定每個digit的Decode-Mode - 0 = No decode - 1 = Code B decode 2. (**Coding**) 請說明是如何將沒用到的digits 設成空白?如果使用 Scan Limit 請改用 code B decode Mode 的 Blank。反之請換成 code b decode mode blank。其他方法請說明之。 我用Scan Limit 設為6,開啟0~6Digit,所以第七位為空白。 若要使用code b decode mode blank,在要空白的Digit給 0xF 值即可。 **4-3 Question** 1. 請逐行說明 GPIO_init 做了哪些設定 a) AHB2 開啟 Port A、C (設為0x5) b) 設定PA5~7output mode、speed c) 設定PC13 input mode、Pull-up 2. 請說明怎麼做到動態調整顯示的位數? 即左邊空白的部分如何動態做調整? 3. 如何將我們的結果轉換成 digits,並依序顯示在 7-seg LED 的不同位置上?