Development Introduction SD Card Device Driver Development Introduction Team4: 490415046 許弘達 694415016 曹啟訓
Outline SD Card簡介 開發環境介紹 SPI傳輸模式 SPI 模式的指令、資料和回傳訊號簡介
SD Card 簡介 SD(Secure Digital Card):前身為 MMC(MultiMedia Card)。尺寸只有郵票般大小,重量也只有 1.5 克,傳輸速度可達每秒 10MB,可以很方便、快速地複製和下載檔案,以及高儲存容量和低耗電性,並提供防寫切換選擇,防止意外刪除;防震、且可適應各種天氣條件,具有異常耐用的持久性能
SD Card 簡介 驅動程式:SD Card屬大量資料傳輸的裝置,故驅動程式為區塊裝置驅動程式(Block Device Driver)每次可傳輸一整塊固定大小的資料,並且可以隨機存取 介面:9 pins,其中7 pins相容於MMC 6 communication lines:DAT1~3、CMD、CLK 3 supply lines:VDD、Vss1、Vss2
開發環境介紹 硬體:MicroLinks I-0101嵌入式開發版 嵌入式OS: 核心時脈200MHz,4k I cache、4k D cache 208 pins 73 multiplexed GPIOs 20 external interrupts 嵌入式OS: uClinux based on Linux kernel 2.4 介面:SPI(Serial Peripheral Interface)同步序列傳輸模式,作為控制、讀、寫的介面
架構 SD card net UART Command line (SPI) ML-I0101
腳位圖 I0101腳位 SD card腳位 66 SPIM1_SS 1 CS 65 SPIM1_TxD 2 DIN 59 3 Ground 60 4 Voltage 63 SPIM1_CLK 5 SCLK 73 6 VSS2 64 SPIM1_RxD 7 DOUT 8 IRQ
SPI(Serial Peripheral Interface) Four signal Chip Select (/CS):Host to card Chip Select signal Serial Clock (SC):Host to card clock signal DataIn:Host to card data signal DataOut:Card to host data signal
SPI Timing Diagram Data Output TRI-STATE
SPI Timing Diagram Data Input
SPI 模式的指令 SD card 分為二種傳輸模式,為SD mode 和SPI mode ;在collie上使用SPI mode 當成傳輸資料的協定 。 SPI mode 包含二種傳輸協定,讀出和寫入的協定,SPI 傳輸的模式如同於SD mode 有 command , response 和 data-block tokens。 SPI傳輸使用CRC做為安全的保護,以確保資料的正確性。 其傳輸的順序如下圖。
資料和回傳訊號簡介 Data Read Data Write command response Data block CRC Data In Data Out Data response busy
指令訊號格式 SD Memory card 指令訊號有6 bytes的長度,分別為6 bits長度的指令位元,32 bits的參數位元和7 bits的錯誤檢查碼。 Bit position 47 46 [45:40] [39:8] [7:1] Width (bit) 1 6 32 7 Value ‘0’ ‘1’ or ’0’ X ‘1’ Description Start bit RD/WR bit ‘1’: transmission ‘0’: receive Command index Argument CRC7 End bit
驅動程式使用指令 CMD Argument Resp Command Description Cmd0 None R1 resets the SD Memory Card Cmd1 Activates the card initialization process Cmd9 Asks the selected card to send its CSD Cmd17 [31:0] reads a block data address Cmd24 write a block data address
指令回傳訊號格式 當指令訊號送出之後,會回傳一個8 bits 的回傳訊號,其bit 7為 0 ,其他的bits為錯誤訊息,如下圖示 in idle state erase reset Illegal command Com crc error Erase sequence error Address error Parameter error
第一個資料傳送位元 當第一筆資料送出時,會先送出一個8 bits的起始資料,其格式如下圖示。 7 1 1 1 1 1 1 1 0
資料回傳訊號格式 當SD卡接收完資料之後,會回傳一個8 bits 的回傳訊號,其bit 3 ~ bit 1為其狀態,如下圖示 7 6 X X X X X status 1 ‘010’ Data accepted ‘101’ Data rejected due to a CRC error ‘110’ Data rejected due to a Write Error
The End Thanks for your attention !