How to Use MMCSDCChaN.docx
- 文档编号:13695870
- 上传时间:2023-06-16
- 格式:DOCX
- 页数:15
- 大小:125.89KB
How to Use MMCSDCChaN.docx
《How to Use MMCSDCChaN.docx》由会员分享,可在线阅读,更多相关《How to Use MMCSDCChaN.docx(15页珍藏版)》请在冰点文库上搜索。
HowtoUseMMCSDCChaN
HowtoUseMMC/SDC
Update:
February18,2013
The SecureDigitalMemoryCard (SDCbelow)isthedefactostandardmemorycardformobileequipments.TheSDCwasdeveloppedasupper-compatibletoMultiMediaCard (MMCbelow).SDCcompleantequipmentscanalsouseMMCsinmostcase.Therearealsoreducedsizeversions,suchas RS-MMC, miniSD andmicroSD,withthesamefunction.TheMMC/SDChasamicrocontrollerinit.Theflashmemorycontrols(blocksizeconversion,errorcorrectionandwearleveling-knownas FTL)arecompletedinsideofthememorycard.Thedataistransferredbetweenthememorycardandthehostcontrollerasdatablocksinunitof512bytes,sothatitcanbeseenasablockdevicelikeagenericharddiskdrivefromviewpointofupperlevellayers.
ThispagedescribesthebasicknowledgeandmiscellaneousthingsthatIbecomeaware,onusingMMC/SDCwithsmallembeddedsystem.IbelievethatthisinformationmustbeausefulgettingstartednotesforthepeoplewhoisgoingtouseMMC/SDContheelectronicshandiworkprojects.
Pinout
miniSD | microSD
RightphotoshowsthecontactsurfaceoftheSDC/MMC.TheMMChassevencontactpads.TheSDChasninecontactpadsthattwoadditionalcontactstotheMMC.Thethreeofthecontactsareassignedforpowersupplysothatthenumberofeffectivesignalsarefour(MMC)andsix(SDC).Therforethedatatransferbetweenthehostandthecardisdoneviaasynchronousserialinterface.
Theworkingsupplyvoltagerangeisindicatedintheoperationconditionsregister(OCR)anditshouldbereadandcomfirmedtheoperatingvoltagerange.However,thesupplyvoltagecanbefixedto3.0/3.3voltsbecausetheallMMC/SDCsworkatsupplyvoltageof 2.7to3.6volts atleast.Donotsupply5.0voltstothecard,orthecardisdamagedinstantly.Thecurrentconsumptiononwriteoperationcanreachuptosometenmiliamperes,sothatthehostsystemshouldconsidertosupply100miliamperestothacard.
SPIMode
Thisdocumentdescribesthe SPImode tocontroltheMMC/SDCs.TheSPImodeisanalternativeoperatingmodethatdefinedtousetheMMC/SDCswithoutnativehostinterface.ThecommunicationprotocoloftheSPImodeisalittlesimplecomparedtoitsnativeoperatingmode.TheMMC/SDCcanbeattachedtothemostmicrocontrollersviaagenericSPIinterfaceorGPIOports.ThereforetheSPImodeissuitableforlowcostembeddedapplicationswithnonativehostinterfaceisavailable.TherearefourdifferentSPImodes,0to3,dependsonclockphaseandpolarity.Mode0isdefinedforSDC.FortheMMC,itisnottheSPItiming,bothlatchandshiftactionsaredefinedwithrisingedgeoftheSCLK,butitseemstoworkatmode0intheSPImode.Thusthe Mode0 (CPHA=0,CPOL=0)isthepropersettingtocontrolMMC/SDC,butmode3(CPHA=1,CPOL=1)alsoworksaswellinmostcase.
CommandandResponse
InSPImode,thedatadirectiononthesignallinesarefixedandthedataistransferredin byteoriented serialcommunication.Thecommandframefromhosttocardisafixedlengthpacketthatshownbelow.ThecardisreadytoreceiveacommandframewhenitdrivesDOhigh.Afteracommandframeissenttothecard,aresponsetothecommand(R1,R2,R3orR7)issentbackfromthecard.Becausethedatatransferisdrivenbyserialclockgeneratedbyhostcontroller,thehostcontrollermustcontinuetoreaddata,senda0xFFandgetreceivedbyte,untilavalidresponseisdetected.TheDIsignalmustbekepthighduringreadtransfer(senda0xFFandgetthereceiveddata).Theresponseissentbackwithincommandresponsetime(NCR),0to8bytesforSDC,1to8bytesforMMC.TheCSsignalmustbedrivenhightolowpriortosendacommandframeandhelditlowduringthetransaction(command,responseanddatatransferifexist).TheCRCfeatureisoptionalinSPImode.CRCfieldinthecommandframeisnotcheckedbythecard.
SPICommandSet
EachcommandisexpressedinabbreviationlikeGO_IDLE_STATEorCMD
Command
Index
Argument
Response
Data
Abbreviation
Description
CMD0
None(0)
R1
No
GO_IDLE_STATE
Softwarereset.
CMD1
None(0)
R1
No
SEND_OP_COND
Initiateinitializationprocess.
ACMD41(*1)
*2
R1
No
APP_SEND_OP_COND
ForonlySDC.Initiateinitializationprocess.
CMD8
*3
R7
No
SEND_IF_COND
ForonlySDCV2.Checkvoltagerange.
CMD9
None(0)
R1
Yes
SEND_CSD
ReadCSDregister.
CMD10
None(0)
R1
Yes
SEND_CID
ReadCIDregister.
CMD12
None(0)
R1b
No
STOP_TRANSMISSION
Stoptoreaddata.
CMD16
Block
length[31:
0]
R1
No
SET_BLOCKLEN
ChangeR/Wblocksize.
CMD17
Address[31:
0]
R1
Yes
READ_SINGLE_BLOCK
Readablock.
CMD18
Address[31:
0]
R1
Yes
READ_MULTIPLE_BLOCK
Readmultipleblocks.
CMD23
Numberof
blocks[15:
0]
R1
No
SET_BLOCK_COUNT
ForonlyMMC.Definenumberofblockstotransfer
withnextmulti-blockread/writecommand.
ACMD23(*1)
Numberof
blocks[22:
0]
R1
No
SET_WR_BLOCK_ERASE_COUNT
ForonlySDC.Definenumberofblockstopre-erase
withnextmulti-blockwritecommand.
CMD24
Address[31:
0]
R1
Yes
WRITE_BLOCK
Writeablock.
CMD25
Address[31:
0]
R1
Yes
WRITE_MULTIPLE_BLOCK
Writemultipleblocks.
CMD55(*1)
None(0)
R1
No
APP_CMD
LeadingcommandofACMD
CMD58
None(0)
R3
No
READ_OCR
ReadOCR.
*1:
ACMD
*2:
Rsv(0)[31],HCS[30],Rsv(0)[29:
0]
*3:
Rsv(0)[31:
12],SupplyVoltage
(1)[11:
8],CheckPattern(0xAA)[7:
0]
SPIResponse
Therearesomecommandresponseformats,R1,R2,R3andR7,dependsonthecommandindex.Abyteofresponse,R1,isreturnedformostcommands.ThebitfieldoftheR1responseisshowninrightimage,thevalue0x00meanssuccessful.Whenanyerroroccured,correspondingstatusbitintheresponsewillbeset.TheR3/R7response(R1+trailing32-bitdata)isforonlyCMD58andCMD8.
SomecommandstakeatimelongerthanNCR anditrespondsR1b.ItisanR1responsefollowedbybusyflag(DOisdriventolowaslongasinternalprocessisinprogress).ThehostcontrollershouldwaitforendoftheprocessuntilDOgoeshigh(a0xFFisreceived).
InitializationProcedureforSPIMode
Afterpoweronreset,MMC/SDCentersitsnativeoperatingmode.ToputitSPImode,follwingproceduremustbeperformedlike thisflow.
PowerONorcardinsersion
Aftersupplyvoltagereached2.2volts,waitforonemillisecondatleast.SetSPIclockratebetween100kHzand400kHz.SetDIandCShighandapply74ormoreclockpulsestoSCLK.Thecardwillenteritsnativeoperatingmodeandgoreadytoacceptnativecommand.
Softwarereset
Senda CMD0withCSlow toresetthecard.ThecardsamplesCSsignalonaCMD0isreceivedsuccessfully.IftheCSsignalislow,thecardentersSPImodeandrespondsR1withInIdleStatebit(0x01).SincetheCMD0mustbesentasanativecommand,theCRCfieldmusthaveavalidvalue.WhenoncethecardentersSPImode,theCRCfeatureisdisabledandtheCRCisnotcheckedbythecard,sothatcommandtransmissionroutinecanbewrittenwiththehardcordedCRCvaluethatvalidforonlyCMD0andCMD8withtheargumentofzero.TheCRCfeaturecanalsobeswitchedwithCMD59.
Initialization
Inidlestate,thecardacceptsonlyCMD0,CMD1,ACMD41,CMD58andCMD59.Anyothercommandswillberejected.Inthistime,readOCRregisterandcheckworkingvoltagerangeofthecard.Incaseofthesystemsypplyvoltageisoutofworkingvoltagerange,thecardmustberejected.Notethatallcardsworkatsupplyvoltagerangeof2.7to3.6voltsatleast,sothatthehostcontollerneedsnotchecktheOCRifsupplyvoltageisinthisrange.Thecardinitiatestheinitializationprocesswhena CMD1 isreceived.Todetectendoftheinitializationprocess,thehostcontrollermustsendCMD1andchecktheresponseuntilendoftheinitialization.Whenthecardisinitializedsuccessfuly,InIdleStatebitintheR1responseiscleared(R1respchanges0x01to0x00).Theinitializationprocesscantake hundredsofmilliseconds (largecardstendtolonger),sothatthisisaconsiderationtodeterminthetimeoutvalue.AftertheInIdleStatebitcleared,genericread/writecommandswillabletobeaccepted.
Because ACMD41 insteadofCMD1isrecommendedforSDC,tryingACMD41firstandretrywithCMD1ifrejected,isidealtosupportbothtypeofthecards.
TheSCLKrateshouldbechangedtofastaspossibletomaximizetheread/writeperformance.TheTRAN_SPEEDfieldintheCSDregisterindicatesthemaximumclockrateofthecard.Themaximumclockrateis20MHzforMMC,25MHzforSDCinmostcase.Notethattheclockratewillabletobefixedto20/25MHzinSPImodebecausethereisnoopen-drainconditionthatrestrictstheclockrate.
Theinitialread/writeblocklengthcanbeset1024on2GBcards,sothattheblocksizeshouldbere-initializedto512withCMD16toworkwithFATfilesystem.
HowtosupportSDCversion2andhighcapacitycards
AfterthecardentersidlestatewithaCMD0,senda CMD8 withargumentof0x000001AAandcorrectCRCpriortoinitializationprocess.IftheCMD8isrejectedwithilligalcommanderror(0x05),thecardisSDCversion1orMMCversion3.Ifaccepted,R7response(R1(0x01)+32-bitreturnvalue)willbereturned.Thelower12bitsinthereturnvalue0x1AAmeansthatthecardisSDCversion2anditcanworkatvoltagerangeof2.7to3.6volts.Ifnotthecase,thecardshouldberejected.AndtheninitiateinitializationwithACMD41withHCSflag(bit30).Aftertheinitializationcompleted,r
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- How to Use MMCSDCChaN