


如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
spi四种模式SPI的相位(CPHA)和极性(CPOL)分别可以为0或1,对应的4种组合构成了SPI的4种模式(mode)Mode0CPOL=0,CPHA=0Mode1CPOL=0,CPHA=1Mode2CPOL=1,CPHA=0Mode3CPOL=1,CPHA=1时钟极性CPOL:即SPI空闲时,时钟信号SCLK的电平(1:空闲时高电平;0:空闲时低电平)时钟相位CPHA:即SPI在SCLK第几个边沿开始采样(0:第一个边沿开始;1:第二个边沿开始)sd卡地spi常用的是mode0和mode3,这两种模式的相同的地方是都在时钟上升沿采样传输数据,区别这两种方式的简单方法就是看空闲时,时钟的电平状态,低电平为mode0,高电平为mode3。 Overview TheSPIstandardincludesfourmodes,definedbythepolarityofSCLKandthephaserelationshipbetweendataandSCLK.Theclockpolarity(CPOL)isdeterminedbytheidlestateofSCLK.Iftheidlestateislow,CPOLis0.Iftheidlestateishigh,CPOLis1.Theclockphase(CPHA)isdeterminedbywhichedgethatdataisvalid.IfthedataisvalidonthefirstedgeofSCLK,CPHAis0.IfthedataisvalidonthesecondedgeofSCLK,CPHAis1.IndustryhastwocommonformatstodefinethefourSPImodes.Thefirstformatdefinesthefourpossiblecombinationsofphaseandpolarityasmode0,mode1,mode2,andmode3.Thesecondformatdefinesthecombinationsasmode0,0,mode0,1,mode1,0,andmode1,1.TheSPImastermustuseamodesupportedbytheslavedevicetoallowpropercommunications.DallasSemiconductor/Maxim'sSPI-interfaceRTCssupportbothSCLKpolarities.TheRTCautomaticallydeterminesthepolaritybydetectingtheidlestateofSCLKwhenCEisasserted.Themastermust,therefore,placeSCLKintheproperidlestatebeforeCEisasserted.Onlyonephaseissupported.SincetwoSCLKpolaritiesaresupported,twoofthefourSPImodesaresupportedbytheRTCs:modes1and3(mode0,1andmode1,1).Onmicrocontrollerswithbuilt-inSPIinterfaces,anSPIcontrolorconfigurationregisterwillhavebitsthatcontrolthepolarityandphase.BecausetheRTCsupportseitherpolarity,thepolaritycanbesetasdesired.Thephasebit,however,mustbesetproperly,ortheRTCwillnotoperatecorrectly.Figure1showsatypicalsingle-bytereadandFigure2showsatypicalsingle-bytewrite.EachtimeCEisasserted,thefirsteightSCLKpulsesareusedtoclockinacommandbyte.Thecommandbyteconsistsofseveralbitsthatdefinearegisteraddress,andonebitthatdefinesthedatadirection:awriteifthenexteightSCLKpulseswillclockdataintothepart,orareadifdataisclockedoutofthepart.AdditionalgroupsofeightSCLKpulsescontinuetotransferda

快乐****蜜蜂
实名认证
内容提供者


最近下载