12/13 DSD Project Presentation 第四組 SD IO Interface World Real Time Clock / Alarm with C-LCM SD / SDIO Card SD Card Introduction SD Card,全名Security Digital Card,是小型記憶卡 的一種,它被廣泛地於攜帶型裝置上使用,是由日本 松下(Panasonic)公司、東芝(TOSHIBA)公司與 美國San Disk公司共同開發研製的。 SD卡可以看作是由MMC卡衍生出來的。SD卡投影面 積與MMC卡相同,只是略微厚一點,但是SD卡的容 量大得多,且讀寫速度也比MMC卡快 4倍。同時, SD卡的介面與MMC卡是相容的,支援SD卡的介面大 多支援MMC卡。在2006年,SD卡容量有 8、16、32、 64、128、256、512 MB,或 1、2 、4、6、8 GB。 SD Card Introduction 用戶可以使用一個USB的讀卡器,在個人電腦上使用 SD卡。某些新型電腦上已經內置了讀卡裝置。 最新的發展是SD內建了USB插口,省略了讀卡器。 San Disk的設計是使用一個可摺疊的護套來保護USB 插口。 SD Card Application SD卡多應用於 MP3隨身聽 數位相機:儲存相片及短片 數位攝影機:儲存相片及短片 個人數位助理(PDA):儲存各類資料 手機:儲存相片、鈴聲、音樂、短片等資料 SDIO Card Introduction SDIO,意即Secure Digital Input/Output,所謂 「支援SDIO」的機種,其SD擴充槽除了能使用 SD記憶卡外,也可支援SD介面的輸出入設備, 例如無線網路卡、藍芽卡、GPS接收器、數位相 機卡、FM廣播卡、電視接收器、數據機、指紋辨 識器等。 SDIO Card Introduction 比起使用USB插槽,使用SDIO卡耗電量低, 並且適用於各種行動式的平台。 同樣是數位裝置,支援SDIO的 機種只要插入SDIO擴充卡,就 能增加各種不同的功能,例如 NB搭配無線網卡以及PDA搭配 GPS接收器,就是目前極受使 用者青睞的實用方案。 Technology Explanation 所有SD和SDIO卡都必須支援較老的SPI/MMC模式。 這個模式支援慢速的四線序列介面(時鐘、序列輸入, 序列輸出,晶片選擇),相容於序列終端介面(SPI) 和許多微控制器。 SD卡共支援三種傳輸模式: - SPI模式(獨立序列輸入和序列輸出), - 1位元SD模式 (獨立指令和資料通道,獨有的傳輸格式) - 4位元SD模式 (使用額外的針腳以及某些重新設置的針腳。 支持四位寬的平行傳輸)。 Technology Explanation 大部分數位相機,數位音頻播放器和其他便攜設備僅 能使用MMC模式。有關這一模式的詳細文檔可以從 MMCA購買,價格是500美元。但是部分有關SDIO的 文檔是免費的。有些還可以從存儲卡廠商處獲得。 MMC模式不支持SD卡的加密特性。從免費的文檔裏 也找不到這些細節。但對於大多數消費者來講,這無 關痛癢,用戶制式用來儲存不受保護的數據。 Other MMC / SD Card SD Card 不是Secure Digital Card Association (安全數字卡聯盟)批准的唯一一種記憶卡。其他批 准的格式包括miniSD、 microSD(在聯盟未通過標 準前稱為TransFlash)和SDHC。 這些更小的卡加上一個適配器也能用在全尺寸的 MMC/SD/SDIO 插槽上。要知道開發出SD尺寸的輸 入輸出設備標準已經很難了,再想開發更小尺寸的簡 直就不太現實了。 Other MMC / SD Card SD插槽支持MMC卡,更小尺寸的MMC卡變種也能相 容於支援SD卡的設備。與miniSD 和 microSD不同的 是, RS-MMC 插槽可以相容全尺寸的MMC卡。因為 RS-MMC卡只是縮短了的MMC卡。 因應SD卡的標準容量上限只有4GB,不足以應付日 益上升的容量需求,聯盟制定了新的SDHC標準。 SDHC卡的外型跟普通的SD卡完全相同,而容量的下 限為4GB,預料年內可推出高達32GB的SDHC卡。 Standard 與其它存儲卡格式一樣,SD卡也有眾多的專利和註冊商標保護, 授權只能由安全數字卡聯盟進行。安全數字卡聯盟現在的授權協 議並不允許開放原始碼的SD驅動程序,這種狀況產生了很多關於 開放原始碼和免費軟件的爭論。通行的做法是開發一個開放原始 碼的外殼,但核心是針對特定平臺的封閉原始碼SD驅動程序,這 種做法與期望的開放標準差異太大。另一種通行的做法是採用較 老的MMC模式,因為根據SD卡標準,所有的SD卡都必須支持 MMC模式。 這說明SD卡的開放度比CF卡或閃存低,上述兩種格式幾乎免費, 僅需要使用聯盟標誌和註冊商標的授權費。但比xD卡或記憶棒的 開放度高得多,這兩種格式根本不提供公開文件支援。 Comparison With Other Memory Card 類型 MMC RSMMC MMC Plus Secure MMC SD SDIO miniSD microSD SD插槽 是 機械適 配器 是 是 是 是 電子-機械 適配器 電子-機械 適配器 針腳 7 7 13 7 9 9 11 8 外形規格 薄 薄/短 薄 薄 厚 厚 窄/短/薄 窄/短/超薄 SPI模式 可選 可選 可選 支持 支持 支持 支持 支持 1位元模式 是 是 是 是 是 是 是 是 4位元模式 否 否 是 ? 可選 可選 可選 可選 8位元模式 否 否 是 ? 否 否 否 否 支持DRM* 否 否 否 是 是 N/A 是 是 *DRM:數位著作權管理 State Diagram Card Initialization SD Memory Card Functional Description Command Command Types Four kinds of commands defined to control the SD Memory Card: Broadcast commands (bc), no response - The broadcast feature is only if all the CMD lines are connected together in the host. If they are separated, then each card will accept it separately in its turn. Broadcast commands with response (bcr) response from all cards simultaneously - Since there is no Open Drain mode in SD Memory Card, this type of command shall be used only if all the CMD lines are separated - the command will be accepted and responded by every card separately. Addressed (point-to-point) commands (ac) no data transfer on DAT Addressed (point-to-point) data transfer commands (adtc) data transfer on DAT Command Types All commands have a fixed code length of 48 bits Command Format A command always starts with a start bit (always 0), followed by the bit indicating the direction of transmission (host = 1). The next 6 bits indicate the index of the command, this value being interpreted as a binary coded number (between 0 and 63). Some commands need an argument (e.g. an address), which is coded by 32 bits. Command Format A value denoted by ‘x’ in the table above indicates this variable is dependent on the command. All commands are protected by a CRC Every command codeword is terminated by the end bit (always 1). All commands and their arguments are listed in Table 4-18-Table 4-27.(Reference: SD Spec. p.49) SD Memory Card Functional Description Cyclic Redundancy Code (CRC) CRC7 The CRC7 check is used for all commands, for all responses except type R3, and for the CSD and CID registers. The CRC7 is a 7-bit value and is computed as follows: Generator polynomial: G(x) = x7 + x3 + 1. M(x) = (first bit) * xn + (second bit) * xn-1 +...+ (last bit) * x0 CRC[6...0] = Remainder [(M(x) * x7)/G(x)] The first bit is the most left bit of the corresponding bit string (of the command, response, CID or CSD). The degree n of the polynomial is the number of CRC protected bits decreased by one. The number of bits to be protected is 40 for commands and responses (n = 39), and 120 for the CSD and CID (n = 119). CRC7 CRC7 Examples The CRC section of the command/response is bolded. SPI Mode SPI Mode Transaction Packets -Command Tokens Command Format All the SD Memory Card commands are 6 bytes long. The command transmission always starts with the left most bit of the bit string corresponding to the command codeword. Command Format All commands are protected by a CRC The commands and arguments are listed in Table 7-3. (Reference: SD Spec. p.102) CMD0 SD Memory commands and the equivalent SDIO commands SD Memory Command CMD0 SDIO Command CMD52 (write to I/O reset in CCCR) Comment The reset command (CMD0) is only used for memory or the memory portion of Combo cards. In order to reset an I/O only card or the I/O portion of a combo card, use CMD52 to write a 1 to the RES bit in the CCCR (bit 3 of register 6). Note that in the SD mode, CMD0 is only used to indicate entry into SPI mode and shall be supported. An I/O only card or the I/O portion of a combo card is not reset with CMD0 Reset for SDIO(CMD0) In order to reset all functions within an SDIO card or the SDIO portion of a combo card, a method different than that used for SD memory is defined. The reset command (CMD0) is only used for memory or the memory portion of Combo cards. In order to reset an I/O only card or the I/O portion of a combo card, use CMD52 to write a 1 to the RES bit in the CCCR (bit 3 of register 6). Note that in the SD mode, CMD0 is only used to indicate entry into SPI mode and shall be supported. An I/O only card or the I/O portion of a combo card is not reset by CMD0 SPI Mode SPI Mode Transaction Packets Command and Argument (SPI bus commands) (SD Memory Card) Command Index CMD0 SPI Mode Yes Argument [31:0] stuff bits Response R1 Abbreviation GO_IDLE_STATE Command Description Resets the SD Memory Card Example: the content of the command index field is (binary) ‘000000’ for CMD0 CMD 0 Bit position 47 46 [45:40] [39:8] [7:1] 0 Width (bits) 1 1 6 32 7 1 Value ‘0’ ‘1’ ‘000000’ ignore X ‘1’ Command index Stuff bits CRC7 End bit Description Start bit Transmission bit Format of Response R1 This response token is sent by the card after every command with the exception of SEND_STATUS commands. It is one byte long, and the MSB is always set to zero. The other bits are error indications, an error being signaled by a 1. Format of Response R1 The structure of the R1 format is given in Figure 7-9. The meaning of the flags is defined as following: Format of Response R1 In idle state: The card is in idle state and running the initializing process. Erase reset: An erase sequence was cleared before executing because an out of erase sequence command was received. Format of Response R1 Illegal command: An illegal command code was detected. Communication CRC error: The CRC check of the last command failed. Erase sequence error: An error in the sequence of erase commands occurred. Format of Response R1 Address error: A misaligned address that did not match the block length was used in the command. Parameter error: The command’s argument (e.g. address, block length) was outside the allowed range for this card. SPI Mode Status Bits (In Idle state) Identifier In Idle state Type SR Value 0 = Card is ready 1 = Card is in idle state Description Clear Condition The card enters the idle state after power up or reset command. It will exit this state and become ready upon completion of its initialization procedures. A SPI Mode Status Bits (Erase reset) Identifier Erase reset Type SR Value ’0’= cleared ’1’= set Description Clear Condition An erase sequence was cleared before executing because an out of erase sequence command was Received C SPI Mode Status Bits (Illegal command) Identifier Illegal command Type ER Value ’0’= no error ’1’= error Description Command not legal for the card state Clear Condition C SPI Mode Status Bits (Com CRC error) Identifier Com CRC error Type ER Value ’0’= no error ’1’= error Description The CRC check of the command failed. Clear Condition C SPI Mode Status Bits (Erase sequence error) Identifier Erase sequence error Type ER Value ’0’= no error ’1’= error Description Clear Condition An error in the sequence of erase commands occurred. C SPI Mode Status Bits (Address error) Identifier Address error Type ERX Value ’0’= no error ’1’= error Description Clear Condition A misaligned address which did not match the block length was used in the command. C SPI Mode Status Bits (Parameter error) Identifier Parameter error Type ERX Value ’0’= no error ’1’= error Description Clear Condition An error in the parameters of the command. C SPI Mode Status Bits 1) Type: E: Error bit. S: State bit. R: Detected and set for the actual command response. X: Detected and set during command execution. The host can get the status by issuing a command with R1 response. 2) Clear Condition: A: According to the current state of the card. C: Clear by read CMD5 Format of CMD5 The IO_SEND_OP_COND Command contains the following fields: S (start bit) Start bit. Always 0 D (direction) Direction. Always1 indicates transfer from host to card. Command Index Identifies the CMD5 command with a value of 000101b Format of CMD5 The IO_SEND_OP_COND Command contains the following fields: Stuff Bits Not used, shall be set to 0. I/O OCR Operation Conditions Register. The supported minimum and maximum values for VDD. Format of CMD5 The IO_SEND_OP_COND Command contains the following fields: CRC7 7 bits of CRC data E (end bit) End bit, always 1 Value of CMD5 Bit position 47 46 [45:40] [39:32] [31:8] [7:1] 0 Width(bits) 1 1 6 8 24 7 1 Value ‘0’ ‘1’ ‘000101b’ ‘00000000’ ‘11111111 10000000 00000000’ X ‘1’ Description Start bit Transmission bit Command index Stuff bits I/O OCR CRC7 End bit Value of CMD5 1*: OCR Values for CMD5 I/O OCR bit Position VDD Voltage Window (in Volts) 15 2.7 – 2.8 16 2.8 – 2.9 17 2.9 – 3.0 19 3.1 – 3.2 18 3.0 – 3.1 20 3.2 – 3.3 21 3.3 – 3.4 22 3.4 – 3.5 23 3.5 – 3.6 The IO_SEND_OP_COND Response (R4) An SDIO card receiving CMD5 shall respond with a SDIO unique response, R4. The format of R4 for both the SD and SPI modes is: The IO_SEND_OP_COND Response (R4) The Response, R4 contains the following data: S (start bit) Start bit. Always 0 D (direction): Direction. Always 0. Indicates transfer from card to host. Reserved: Bits reserved for future use. These bits shall be set to 1. The IO_SEND_OP_COND Response (R4) The Response, R4 contains the following data: C Set to 1 if Card is ready to operate after initialization I/O OCR Operation Conditions Register. The supported minimum and maximum values for VDD. Memory Present Set to 1 if the card also contains SD memory. Set to 0 if the card is I/O only. The IO_SEND_OP_COND Response (R4) The Response, R4 contains the following data: Number of I/O Functions Indicates the total number of I/O functions supported by this card. The range is 0-7. (Note that the common area present on all I/O cards at Function 0 is not included in this count. The I/O functions shall be implemented sequentially beginning at function 1.) The IO_SEND_OP_COND Response (R4) Modified R1: The SPI R1 response byte as described in the SD Physical Specification modified for I/O as follows: • Stuff Bits: Not used, shall be set to 0. Value of R4 (SPI Mode) Bit position [39:32] 31 [30:28] 27 [26:24] [23:0] Width (bits) 8 1 3 1 3 24 Value *a ‘0?0???0?’ ‘1’ ‘101’ ‘0’ ‘000’ ‘011111111 100000000 000000’ Description Modified R1 C Number of I/O functions Memory present Stuff bits I/O OCR CMD8 Introduction to CMD8 SEND_IF_COND (CMD8) is used to verify SD Memory Card interface operating condition. The card checks the validity of operating condition by analyzing the argument of CMD8 and the host checks the validity by analyzing the response of CMD8 (See Chapter 4.3.13). Send Interface Condition Command (CMD8) CMD8 (Send Interface Condition Command) is defined to initialize SD Memory Cards compliant to the Physical Specification Version 2.00. CMD8 is valid when the card is in Idle state. This command has two functions. Voltage check: Checks whether the card can operate on the host supply voltage. Enabling expansion of existing command and response: Reviving CMD8 enables to expand new functionality to some existing commands by redefining previously reserved bits. Format of CMD8 Application Note: It is recommended to use ‘10101010b’ for the ‘check pattern’. Basic Command of SD Memory Card bus Commands Command Index CMD8 Type bcr Argument [31:12]reserved bits [11:8]supply voltage(VHS) [7:0]check pattern Resp R7 Abbreviation SEND_IF_COND Command Description Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage. Reserved bits shall be set to '0'. Card Operation for CMD8 in SPI mode In SPI mode, the card always returns response. Table 7-5 shows the card operation for CMD8. Format of Response R7 This response token is sent by the card when a SEND_IF_COND command (CMD8) is received. The response length is 5 bytes. The structure of the first (MSB) byte is identical to response type R1. The other four bytes contain the card operating voltage information and echo back of check pattern in argument and are specified by the same definition as R7 response in SD mode. Value of R7 (CMD8) Bit position [39:32] [31:28] [27:12] [11:8] [7:0] Width (bits) 8 4 16 4 8 Value ’01h’ ‘0000’ ‘0000h’ ‘0001b’ ‘10101010b’ Description R1(assu me in idle state) Command version Reserved bits Voltage accepted Check pattern CMD52 Format of CMD52 Bit posit ion 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Widt 1 h (bits) 1 6 1 3 1 1 17 1 8 7 1 Valu e ‘0’ ‘1’ ‘110100 b’ *a *e *b ‘0’ *c ‘0’ *d x ‘1’ Desc riptio n Sta rt bit Dir ecti on Comma nd index R/ W Fla g Function number RA W fla g Stu ff Registe r address Stu ff Write data or stuff bits CRC 7 En d bit 缺 register address (17 bits) Value of CMD52 *a: 0 => read data data address = specified by the Function Number & the Register Address to the host 1 => write data, to address = I/O location (by the Function Number) & the Register Address Value of CMD52 *b: 1 => then R/W=1, write then read 0 => read then write *c: This is the address of the byte of data inside of the selected function to read or write. Value of CMD52 *d: For a direct write command (R/W=1) this is the byte that is written to the selected address. For a direct read (R/W=0) this field is not used and shall be set to 0. Value of CMD52 *e: (Our definition) Value Function 功能 ‘001’ Fuction1 設定時間 ‘010’ Function2 切換時區 ‘011’ Function3 設定鬧鐘 ‘100’ Function4 顯示鬧鐘/時間 ‘101’ Function5 關掉鬧鐘 Format of R5(CMD52) Bit position [15:8] [7:0] Width (bits) 8 8 Value *a ( ‘0?0???00’ ) *b Description Modified R1 (in ready state) R/W Data ( data been read ) Value of R5(CMD52) *a : The SPI R1 response byte as described in the SD Physical Specification modified for I/O as follows: Value of R5(CMD52) R/W=1, RAW=1: R/W=1, RAW=0: The value read from the addressed register. In this case, the read-back data may not be the same as the data written to the register, depending on the design of the hardware. the data in this field shall be identical to the data byte in the write command. R/W=0: the actual value read from that I/O location is returned in this field. Common I/O Area Structure Common I/O Area Card Common Control Register(CCCR) allow quick host checking and (Function 0) enable/disable interrupt/function Function Basic Register(FBR) Each function has 256 bytes area that allow host determine the abilities and requirements of each function Card Information Structure (CIS) Provides more Complete information about the card and each function 主要有三個Register structure Support function 0 -- Card Command Control Register CCCR Overall Register Map Address 0X00: SD Revision Bit R/W Represent Value 3~0 Read only These 4 bits contain the version of the CCCR and FBR format that this card supports. 0000 -- CCCR/FBR Version 1.00 0001 -- CCCR/FBR Version 1.10 0010 -- CCCR/FBR Version 1.20 0011 to 1111 -- Reserved for Future Use 7~4 Read only These 4 bits contain the version of the SDIO Specification that this card supports. 0000 SDIO Specification Version 1.00 0001 SDIO Specification Version 1.10 0010 SDIO Specification Version 1.20 (unreleased) 0011 SDIO Specification Version 2.00 0100-1111 Reserved for Future Use Address 0X01: SD Specification Revision Bit R/W Represent Value 3~0 Read only These 4 bits contain the version of the SD Physical Specification that this card supports. 0000 SD Physical Specification Version 1.01 (March 2000) 0001 SD Physical Specification Version 1.10 (October 2004) 0010 SD Physical Specification Version 2.00 (May 2006) 0011-1111 Reserved for Future Use 7~4 Reserved for Future Use Address 0X02: I/O Enable Bit R/W 0 7~1 Represent Value Reserved for Future Use R/W The completion of initialization is indicated in IORx. On power up or after a reset, the card shall reset this bit to 0. The host can also use IOEx as a per function reset for error recovery. The host sequence for a per function reset is to reset IOEx to 0, wait until IORx becomes 0 and then set IOEx to 1 again. If the bit is reset to 0, the function is disabled. If the bit is set to 1, the function is enabled to start its initialization. Address 0X03: I/O Ready Bit R/W 0 7~1 Represent Value Reserved for Future Use Read only (Supplement) The functions shall set this bit to 1 within the timeout value defined in the TPLFE_ENABLE_TIMEOUT_VAL tuple. On power up or after a reset, this bit shall be set to 0. For any function that is not implemented on an SDIO card, this bit shall always be 0 If this bit is reset to 0, the function is not ready to operate. If this bit is set to 1, the function is ready to operate. Address 0X04: Interrupt Enable Bit R/W Represent Value 0 R/W Interrupt Enable Master. If this bit is cleared to 0, no interrupts from this card shall be sent to the host. If this bit is set to 1, then any function’s interrupt shall be sent to the host 7~1 R/W Interrupt Enable for function(1-7) If the bit is cleared to 0, any interrupt from this function shall not be sent to the host. If this bit is set to 1, then this function’s interrupt shall be sent to the host if the master Interrupt Enable (bit 0) is also set to 1. Address 0X05: Interrupt Pending Bit R/W 0 7~1 Represent Value Reserved for Future Use Read Only Interrupt Pending for function (1-7) If this bit is cleared to 0, this indicates Note that if the IENx or IENM bits that no are not set, the host cannot interrupts are pending from this function. receive this pending interrupt. If this bit is set to 1, then this function has interrupt pending. Address 0X06: I/O Abort Bit R/W Represent Value 2~0 Write only Abort Select In order to abort an I/O read or write and free the SD bus. (Note) the function that is currently transferring data must be addressed. These 3 bits define which function’s transfer to stop. (Example) the abort the transfer to function number 3, the value of 0x03 would be written to these bits using CMD52 only. If the abort is addressed to a suspended function, it does not affect current data transaction. 3 Write only I/O CARD RESET Setting the RES to 1 shall cause all I/O functions in an SDIO or Combo card to perform a soft reset. 7~4 Reserved for Future Use Address 0X07: Bus Interface Bit R/W Represent 1~0 R/W Defines the data bus width to be ’00’=1-bit or’10’=4-bit bus used for data transfer. All FullSpeed SDIO cards support both 1 and 4-bit bus. 4~2 Value Reserved for Future Use 5 R/W Enable Continuous SPI Interrupt. “1”, then this R/W bit is used to allow the SDIO card to assert the interrupt line in the SPI mode at any time. This bit is cleared to “0” on reset or powerup. 6 Read only Support Continuous SPI interrupt. “1” to indicate that this SDIO card supports the assertion of interrupts in the SPI mode at any time. “0” , then this SDIO card can only assert the interrupt line in the SPI mode when the CS line is asserted 7 R/W CD Disable Connect[0]/Disconnect[1] the 10K-90K Address 0X08: Card Capability (2 of 2) Bit R/W Represent Value 4 Read only Supports interrupt between blocks of data in 4-bit SD mode. This flag bit reports the SDIO card’s ability to generate interrupts during a 4bit multi-block data transfer If this bit is 0, then the SDIO card is not able to signal an interrupt during a multiblock data transfer in 4-bit mode If this bit is 1, then the SDIO card is able to signal an interrupt between blocks while data transfer is in progress. 5 R/W Enable interrupt between blocks of data in 4-bit SD mode. Enable the multi-block IRQ during 4-bit transfer for the SDIO card. 0, the card shall not signal interrupts during a 4-bit multi-block data transfer 1, the card shall generate interrupts during 4 bit multi-block data transfers 6 Read only Card is a Low-Speed card or not 1 – low-speed card 0 – full-speed card 7 Read only 4-bit support for Low-Speed cards 1 – LSC = 1 & supports 4-bit data transfer 0 – otherwise Address 0X08: Card Capability (1 of 2) Bit R/W Represent 0 Read only Card Supports Direct Commands during data transfer. This bit applies only to the SD modes, it does not apply to SPI mode. 1 Read only ICard Supports Multi-Block. This flag bit reports the SDIO card’s ability to execute the IO_RW_EXTENDED command (CMD53) in the block mode. 2 Read only Card Supports Read Wait. This bit applies only to the SD modes, it does not apply to SPI mode 3 Read only Card supports Suspend/Resume. This bit applies only to the SD modes, it does not apply to SPI Value If this bit is set, all I/O functions (0-7) shall accept and execute CMD53 with the optional block mode bit set. Address 0X09 ~ 0X0B: Common CIS Pointer Bit R/W Represent Value 7~0 Read only This 3-byte pointer points to the start of the card’s common CIS. A card common CIS is mandatory for all SDIO cards. This pointer is stored in little-endian format (LSB first). The common CIS contains information relation to the entire card. The card common CIS shall be located within the CIS space of function 0 (0x0010000x017FFF) Address 0X0C: Bus Suspend Bit R/W Represent Value 0 Read only Bus status 1, then the currently addressed function is currently executing a command which transfers data on the DAT[x] line(s). 0, then the addressed function is not using the data bus. 1 R/W Bus Release Request/Status 1, the addressed function shall temporarily halt data transfer on the DAT[x] lines and suspend the command that is in process. 7~2 Reserved for future use Address 0X0D: Function Select Bit R/W Represent Value 3~0 R/W Select Function bits 3:0 0000 : Transaction of function 0 (CIA) 0001-0111: Transaction to functions 1-7 1000: Transaction of memory in combo card 1001-1111: Not defined, reserved for future use 6~4 7 Reserved for future use Read only Resume Data Flag If DF is set to 1, then there is more data to transfer that will begin after the function or memory in resumed. If DF=0, the function or memory was suspended at end of data transfer (during busy) Address 0X0E: Exec Flags Bit R/W Represent Value 7~0 Read only Execution Flag. These bits are used by the host to determine the current execution status of all functions (1-7) and memory (0). The bit is set to 1 for each function or memory that is currently executing a command. These bits are only defined if SBS=1 If SBS=0 these bits shall be read as zero. Address 0X0F: Ready Flags Bit R/W Represent Value 7~0 Read only Ready Flag bits. These bits tell the host the read or write busy status for functions (1-7) and memory (0). If the RFx bit is set to 1, then the function/memory can accept write data. if the RFx bit is cleared to 0, it indicates that read data is NOT available. Address 0X10 ~ 0X11: Function 0 block size Bit R/W 10[7..0] R/W 11[7..0] Represent Value This 16-bit register sets the block size for I/O block operations for Function 0 only. The maximum block size is 2048 (0x0800) and the minimum is 1. Address 0X12: Power Control Bit R/W Represent Value 0 Read only Support Master Power Control These bits tell the host if the card supports Master Power Control 0 : The total card current is less than 200mA 1 :The total card current may exceed 200mA. 1 R/W Enable Master Power Control 0(default): The total card current shall be less than 200mA. 1: The total card current may exceed 200mA and SPS and EPS are available 7~2 Reserved for Future Use Address 0X13: High-Speed Bit R/W Represent Value 0 Read only Support High-Speed 0: The card does not support High-Speed mode 1: The card supports High-Speed mode. 1 R/W Enable High-Speed 0 (default): The card operates in default timing mode with a clock rate up to 25MHz. 1 : High-Speed Mode 7~2 Reserved for Future Use Address 0X14 ~ 0XEF: RFU Address 0XF0~ 0XFF: Reserved for Vendors These 16 registers are reserved for the maker of the I/O card to be used for any operations that are defined by and specific to any vendor unique operation. Common I/O Area Structure Common I/O Area Card Common Control Register(CCCR) allow quick host checking and (Function 0) enable/disable interrupt/function Function Basic Register(FBR) Each function has 256 bytes area that allow host determine the abilities and requirements of each function Card Information Structure (CIS) Provides more Complete information about the card and each function 主要有三個Register structure Support function 0 -- Function Basic Register (FBR) Function 1-7 Register Mapping FBR (Function 1-7) Function 1-7 有著相同的Structure, 在此舉其中Function1 作為例子 Function 1: 0X100 to OX1FF 共256 bytes Function 2-7 Address = 0X(2..7)00 Function 1: Address 0X100 Bit R/W Represent Value 3~0 Read only SDIO Function Interface code 顯示此Function 有Support的I/O Interface 0000: No supported function 0001: Support Standard UART 0010: Type-A Bluetooth 0011: Type-B Bluetooth 0100: Support GPS 0101: Support Camera 0110: Support PHS 0111: Support WLAN 1000: Embedded SDIO-ATA 1111: Support other interface(Specified in 0x101) 4&5 RFU 6 Read Only Whether this function support Code Storage Area(CSA) 1: Yes 0: No 7 R/W Enable function CSA 1: Enable 0: Disable (R/W CSA will be blocked)(initial value) Function 2-7 Address = 0X(2..7)01 Function 1: Address 0X101 Bit R/W Represent Value 7~0 Read only Extended SDIO Function Interface code 當address 0X100的[3..0]為1111, 則此8 bits 有意義 Undefined, if 0X100[3..0] != 1111 => 預 設為00000000 Function 2-7 Address = 0X(2..7)02 Function 1: Address 0X102 Bit R/W Represent Value 0 Read only Support Power Selection(SPS) 0: no power selection (EPS=0) 1: has 2 power mode that could be selected by EPS 1 R/W Enable Power Selection(EPS) 0(Default) : Higher Current Mode(Maximum current = TPLFE_HP_MAX_PWR_3.3V) 1: Lower Current Mode(Maximum current = TPLFE_LP_MAX_PWR_3.3V) 7~2 RFU Function 2-7 Address = 0X(2..7)03 – 0X(2..7)08 Function 1: Address 0X103-0X108 Bit 7~0 R/W Represent RFU Value Function 2-7 Address = 0X(2..7)09 – 0X(2..7)0B Function 1: Address 0X109-0X10B Bit R/W Represent 0X10B[7.. 0] + 0X10A[7.. 0] + 0X109[7.. 0] 共24bits Read Address pointer to function CIS Only (只有最後17bits有作用,其中0X10B[7..1] always zero) 1. CIS為每個Function皆有的Structure 2. Store in liitle-endian format(LSB first) 3. If the card doesn’t support CIS, then pointer value = End of Chain tuple Value Address to CIS Function 2-7 Address = 0X(2..7)0C – 0X(2..7)0E Function 1: Address 0X10C-0X10E Bit R/W Represent Value 0X10E[7.. 0] + 0X10D[7.. 0] + 0X10C[7.. 0] 共24bits R/W Address pointer to function CSA 1. After any R/W to CSA access window, this pointer will be increased 1 automatically 2. If this function does not support CSA(0x100 bit 6 = 0), then this 24 bits shall read as 0X000000 3. . Store in liitle-endian format(LSB first) Address to CSA Function 2-7 Address = 0X(2..7)0F Function 1: Address 0X10F Bit R/W Represent Value 7~0 R/W Data access window to CSA Any R/W to this address when CSA is enable ,shall pass data to/from the address by CSA address pointer(0X10C~0X10E) When 0x100[7] = 1 Contain data written to CSA imminently When 0X100[7] = 0 =>Always 00000000 Function 2-7 Address = 0X(2..7)10 ~ 0X(2..7)11 Function 1: Address 0X110-0X111 Bit R/W 0X111[7..0] R/W + 0X110[7.. 0] 共16 bits Represent Value Function 1 I/O Block SIZE 1. Before use it, user should set appropriate value 2. Store in little-endian format Maximum Value is 2048(0X0800) Minimum Value is 1 (0X0001) Initial value = 0X0000 When the card doesn’t support I/O operation Read only and always 0X0000 Function 2-7 Address = 0X(2..7)12 ~ 0X(2..7)FF Function 1: Address 0X112-0X1FF Bit 0X112 – 0X1FF R/W Represent RFU Value Common I/O Area(Function Card Common Control Register(CCCR) allow quick host checking and 0) enable/disable interrupt/function Function Basic Register(FBR) Each function has 256 bytes area that allow host determine the abilities and requirements of each function Card Information Structure (CIS) Provides more Complete information about the card and each function 主要有三個Register structure Support function 0 -- Function 用法 Function 1 Function 1 : 設定時間 Address 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 reset_rtc TH H TM M TS S Function 2 Function 2 :切換時區 Address 0x0000 change_city 0x0001 city0 0x0002 city1 Function 3 Function 3 :設定鬧鐘 Address 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 set_alarm TH H TM M TS S Function 4 & 5 Function 4 :顯示鬧鐘時間 Address 0x0000 show_sel Function 5 :取消在響的鬧鐘 Address 0x0000 cancel_pending 0x0001 alarm_pending Data Trasmission Method 這是我們所有有用到的傳輸方式 Operation Between Command read_ command 讀command 是每8bit讀一次的 CMD0 Bit position 47 46 [45:40] [39:8] [7:1] 0 Description Start bit Transmis sion bit Command index Stuff bits CRC7 End bit R1 (CMD0) Bit position 7 6 5 4 3 2 1 0 Description MSB Parameter error Address error Erase sequen ce error Com crc error Illegal comman d Erase reset(by cmd8) In idle state CMD8 Bit position 47 46 [45:40] [39:20] [19:16] [15:8] [7:1] 0 Description Start bit Transmi ssion bit Command index Reserved bits Voltage supplied(V HS) (2.73.6V) Check pattern CRC 7 End bit R7 (CMD8) Bit position [39:32] [31:28] [27:12] [11:8] [7:0] Description R1(assum e in idle state) Command version Reserved bits Voltage accepted Check pattern CMD5(1) Bit position 47 46 [45:40] [39:32] [31:8] [7:1] 0 Description Start bit Transmission bit Command index Stuff bits I/O OCR CRC7 End bit R4 (CMD5(1)) Bit position [39:32] 31 [30:28] 27 [26:24] [23:0] Description Modified R1 C Number of I/O functions Memory present Stuff bits I/O OCR CMD5(2) Bit position 47 46 [45:40] [39:32] [31:8] [7:1] 0 Description Start bit Transmission bit Command index Stuff bits I/O OCR CRC7 End bit R4 (CMD5(2)) Bit position [39:32] 31 [30:28] 27 [26:24] [23:0] Description Modified R1 C Number of I/O functions Memory present Stuff bits I/O OCR illegal command Bit position 47 46 [45:40] [39:32] [31:8] [7:1] 0 Description Start bit Transmission bit Command index Stuff bits I/O OCR CRC7 End bit illegal command address error Bit position 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descripti on Star t bit Direct ion Command index R/W Flag Function number RA W flag Stuff Register address Stuff Write data or stuff bits CRC7 End bit address error SDIO Card Implementation RTC Real Time Clock (RTC) Main Functionality 由輸入的clock隨時計算現在的時間 設定時間之後,讀進控制元件的時間資料,輸 出每一秒的正確時間 rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz Clock rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz Clock rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz • RTC register 記住TH, H, TM, M, TS, S 的資訊 • 做進位判斷 TH H TM M TS S [01] [1001] [101] [1000] [011] [0000] →19:58:30 19 17 13 10 6 3 0 Frequency Divider Clock rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz Frequency Divider rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz • 將input clock除頻成1Hz Frequency Divider rtc_in[19:0] reset Frequency Divider clk_50KHz Clock rtc_out[19:0] clk_1Hz • 在reset的時候,重新計算1Hz的計數器 RESET 23:59:59 00:00:00 00:00:01 alarm Alarm Design idea Input: 1. rtc_data (現在時間) 2. alarm_data (鬧鐘設定時間) 3. control Control(0) => rtc_enable Control(1) => set Control(2) => cancel Design idea Output: 1. alarm_pending (“1”表示鬧鈴在響;”0”表示鬧鈴沒有在響) 2. alarm_data_o (把接收到的鬧鐘設定時間送出去) Main Functionality 這個architecture最主要就是判斷線在鬧鈴是否在響。 。不使用鬧鐘功能(set = 0)=> 不會響。 。rtc沒有在工作(rtc_enable = 0)=>不會響。 。取消鬧鈴鍵是被按下的(cancel = 1)=>不會響。 。set = 1,rtc_enable = 1, cancel = 0 => 若現在時間和鬧鐘設定的時間相同=>開始響。 => set變成0,rtc_enable變成0, cancel變成1 => 停止。 State Diagram of Alarm At pending 1) [match = 1 or 0,set = 1,rtc_enable = 1,cancel = 0] => pending 2) other situation => not_pending At not_pending 1) [match = 1 ,set = 1,rtc_enable = 1,cancel = 0] => pending 2) other situation => not_pending Testbench of Alarm 當現在時間和鬧鐘設定時間一樣時, control各種情況的simulation cancel Set Rtc_enable Testbench of Alarm 在60ns時,現在時間和鬧鐘設定時間變不同,但是沒有取消,所以鬧鈴 繼續響。在70ns時,取消鈕被按下(control[2]變成1),所以鬧鈴停止。 cancel Set Rtc_enable change change 切換時區 Main Functionality 提供切換時區的功能,將RTC和alarm output 的時間做時區處理 將經過時區處理的time data加上欲顯示的時區 代碼後傳送給LCD Design Idea 先挑選出一定數量的時區代表城市作為對換資 料,判斷現在時間的城市時區,與要變換的城 市時區做比較,將其作時差的加減對應而換算 到新城市的時間 留意進位、退位和前後天(如超過24小時)的時 間換算顯示 Flow of Change City Input time data Reset time reset New time data no reset Change city change New city time data no change Original city time data Testbench of Change City Input time data:UTC+4 Baku 7:49:38 Case 1:change to UTC-4:30 Venezuela Output time data1: 23:19:38 ----時區大換時區小(+ 24小時制變換) Case 2:change to UTC+12:45 Chathamlsl Output time data2: 16:34:38 ----時區小換時區大(+ 時、分的進退位) Reset:city0 20 010100 UTC+4 Baku Output: City TH H TM M TS S [010100][000000] [00] [0111] [100] [1001] [011] [1000] 31 25 19 17 13 10 6 3 0 Reset 32’b0 Case 1:UTC+4 Baku UTC-4:30 Venezuela 7:49:38 23:19:38 Output: city1 TH H TM M TS S [001001] [000000] [10] [0011] [001] [1001] [011] [1000] 31 25 19 17 13 10 6 3 0 New hour New minute Case 2:UTC+4 Baku UTC-4:30 Chathamlsl 7:49:38 16:34:38 Output: city1 TH H TM M TS S [100101] [000000] [01] [0110] [011] [0100] [011] [1000] 31 25 19 17 13 10 6 3 0 New hour New minute Testbench of SDIO Card (在此以80 us當成1 sec測試SDIO card) City0:001000 in_data_rtc [01] [1001] [101] [1000] [011] [0000] 19 : 58 : 30 in_data_alarm [01] [1001] [101] [1000] [100] [0000] 19 : 58 : 40 Reset 19:58:30 Set alarm 19:58:31 Case 1: 001000 UTC-5 New York 000011 UTC-9:30 POM 19:58:32 15:28:32 15:28:32 Change Unchange 15:28:33 19:58:34 19:58:35 Case 2: 001000 UTC-5 New York 000000 UTC+8 Taiwan (dedault) 19:58:36 08:58:36 08:58:36 Change Unchange 08:58:37 19:58:38 19:58:39 in_data_alarm [01] [1001] [101] [1000] [100] [0000] 19 : 58 : 40 R_data_out [01] [1001] [101] [1000] [100] [0000] 19 : 58 : 40 → alarm pending show alarm alarm 19:58:40 19:58:40 Change city + show alarm time: 001000 UTC-5 New York 000000 UTC+8 Taiwan (dedault) 19:58:40 08:58:40 Change city Show alarm time 08:58:40 Cancel pending Rtc time : 19:58:43 show rtc time 19:58:43 在連接上 Host 或 Host reset SDIO card 之前 <sol> 加入內部軟體的reset模擬 在連接上host或host reset之前 RTC仍可以照常運作 reset 00:00:00 00:00:01 00:00:02 19:58:30 19:58:31 LCD TESTBENCH All Project Function List 起始時間(ms) 功能 內容 0 wait Wait for starting! 4.2 初始化 CMD0→CMD8 →CMD5 →CMD5 13.16 設定時間 CMD52(TH=1) → CMD52(H=9) → CMD52(TM=5) → CMD52(M=8) → CMD52(TS=3) → CMD52(S=0) → CMD52(reset_rtc=1) 26.6 設定鬧鐘 CMD52(TH=1) → CMD52(H=9) → CMD52(TM=5) → CMD52(M=8) → CMD52(TS=3) → CMD52(S=2) → CMD52(set_alarm=1) 40.04 顯示鬧鐘 CMD52(show_sel=1) 41.96 等待鬧鐘響 Waiting! 1042.44 顯示時鐘 CMD52(show_sel=0) 2042.76 關掉鬧鐘 CMD52(cancel_pending=1) 2046.6 切換時區 CMD52(city=Paris) → CMD52(change_city=1) 3042.76 關掉鬧鐘 CMD52(cancel_pending=1) TESTBENCH RESET_RTC CMD52(TH=1) Bit position 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descrip tion Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52(TH=1) R5(CMD52) Bit position [15:8] [7:0] Description Modified R1 (in ready state) R/W Data ( data been read ) CMD52(H=9) Bit position 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descrip tion Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52(H=9) CMD52(TM=5) Bit position 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descrip tion Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52(TM=5) CMD52(M=8) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52(M=8) CMD52(TS=3) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52(TS=3) CMD52(S=0) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E n d bit CMD52 (reset_rtc=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stu ff Register address Stu ff Write data or stuff bits CRC 7 E nd bit CMD52 (reset_rtc=1) TESTBENCH 設定鬧鐘 CMD52(TH=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(TH=1) CMD52(H=9) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(H=9) CMD52(TM=5) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(TM=5) CMD52(M=8) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(M=8) CMD52(TS=3) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(TS=3) CMD52(S=2) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(S=2) CMD52 (set_alarm=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52 (set_alarm=1) Set Alarm TESTBENCH 顯示鬧鐘 CMD52 (show_sel=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52 (show_sel=1) Show Alarm TESTBENCH 顯示時鐘 CMD52 (show_sel=0) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52 (show_sel=0) Show Clock TESTBENCH 關掉鬧鐘 ringing Match! CMD52(cancel_ pending=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52(cancel_ pending=1) Stop alarm Stop ringing TESTBENCH CHANGE_CITY CMD52 (city=Paris) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52 (city=Paris) CMD52 (change_city=1) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC 7 E nd bit CMD52 (change_city=1) TESTBENCH 關掉鬧鐘 CMD52(cancel_ pending=0) Bit positio n 47 46 [45:40] 39 [38:36] 35 34 [33:17] 16 [15:8] [7:1] 0 Descri ption Start bit Dir ecti on Comma nd index R/W Flag Function number R A W fla g Stuf f Register address Stuf f Write data or stuff bits CRC7 E nd bit CMD52(cancel_ pending=0) Project Finish LCD SDIO Card Time Display Command Response 1. Initialization 2. Data Transfer (Support 4 I/O Function) - 設定時間 - 設定鬧鐘 - 取消鬧鐘 - 切換時區 Thank You!