关闭

关闭

关闭

封号提示

内容

首页 fm31256驱动,测试经由过程[纲要]

fm31256驱动,测试经由过程[纲要].doc

fm31256驱动,测试经由过程[纲要]

ruth红博 2017-10-13 评分 0 浏览量 0 0 0 0 暂无简介 简介 举报

简介:本文档为《fm31256驱动,测试经由过程[纲要]doc》,可适用于综合领域,主题内容包含fm驱动,测试经由过程纲要FM驱动,测试通过=============================================功能:fm测试符等。

fm驱动,测试经由过程纲要FM驱动,测试通过=============================================功能:fm测试程序时间:=============================================#include<regh>#defineuintunsignedint#defineucharunsignedchar#defineIICWRITExa#defineIICREADxa#defineREGREADXdregisterread#defineREGWRITEXdregisterwrite#defineWRITEPROTECTxb#defineYEARx#defineMOUNTHx#defineDAYx#defineDATEx#defineHOURx#defineMINUTEx#defineSECONDx#defineCONTROLx#defineFLAGSx#defineWDTFLAGx#defineWDTTIMExaucharTimeucharcounter=,asbitSDA=P^sbitSCL=P^sbitSDA=P^theSDAbitisprotbitsbitSCL=P^theSCLbitisprotbitsbitCNT=P^eventcounteroutputsbitCNT=P^enentcounteroutputsbitCAL=P^caloutputsbitRST=P^watchdogoutputucharbdatabbytesbitd=bbyte^sbitd=bbyte^sbitd=bbyte^sbitd=bbyte^sbitd=bbyte^sbitd=bbyte^sbitd=bbyte^sbitd=bbyte^voidinit(){TMOD=xTH=xfdTL=xfdTR=REN=SM=SM=EA=ES=}================================voidStart(){SDA=SCL=SDA=}=================================voidStop(){SDA=SCL=SDA=}=================================voidWriteByte(ucharWdata){bbyte=WdataSCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=SDA=dSCL=SCL=}==================================ucharReadByte(){ucharRetValueSCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=SCL=d=SDASCL=RetValue=bbytereturnRetValue}====================================voidAck(){uchariSCL=i=while((i)SDA)SCL=}====================================ucharReadFRAM(uintAddress){ucharRetValueStart()WriteByte(IICWRITE)Ack()WriteByte((uchar)(Address>>))Ack()WriteByte((uchar)(Address))Ack()Start()WriteByte(IICREAD)Ack()RetValue=ReadByte()SCL=SDA=SCL=Stop()returnRetValue}=====================================voidWriteReg(ucharRegAdd,ucharWdata){Start()WriteByte(REGWRITE)Ack()RegAdd=RegAddxfWriteByte(RegAdd)Ack()WriteByte(Wdata)Ack()Stop()}=====================================ucharReadReg(ucharRegAdd){ucharRetValueStart()WriteByte(REGWRITE)Ack()WriteByte(RegAdd)Ack()Start()WriteByte(REGREAD)Ack()RetValue=ReadByte()SCL=SDA=SCL=Stop()returnRetValue}=====================================voidWriteFRAM(uintAddress,ucharWdata){Start()WriteByte(IICWRITE)Ack()WriteByte((uchar)(Address>>))Ack()WriteByte((uchar)(Address))Ack()WriteByte(Wdata)Ack()Stop()}======================================voidInitiation(void)initialforbaudrate,useT{TMOD=xTH=xfdTL=xfdTR=REN=SM=SM=EA=ES=}=======================================voidSendData(ucharSdata){SBUF=Sdatawhile(!TI)TI=}=======================================voidmain(void){uintAdducharReadDataWriteReg(CONTROL,x)停止时钟Initiation()TR=SendData(x)*for(Add=Add<xffAdd){WriteFRAM(Add,x)}for(Add=xAdd<xffAdd){WriteFRAM(Add,x)}for(Add=Add<xffAdd){ReadData=ReadFRAM(Add)SendData(ReadData)}*软件写保护功能不能实现,,,,,,,,,,,,WriteReg(WRITEPROTECT,x)软件写保护WriteReg(WRITEPROTECT,x)软件写保护WriteReg(WRITEPROTECT,x)软件写保护全部*for(Add=Add<xffAdd){WriteFRAM(Add,x)}for(Add=Add<xffAdd){ReadData=ReadFRAM(Add)SendData(ReadData)}*WriteReg(CONTROL,x)启动时钟WriteReg(FLAGS,x)清除标志位WriteReg(FLAGS,x)允许写操作WriteReg(YEAR,x)写时间WriteReg(MOUNTH,x)WriteReg(DAY,x)WriteReg(DATE,x)WriteReg(HOUR,x)WriteReg(MINUTE,x)WriteReg(SECOND,x)WriteReg(FLAGS,x)停止写操作WriteReg(FLAGS,x)允许读操作TR=启动定时器while(){{if(counter==){ES=WriteReg(FLAGS,x)允许读操作Time=ReadReg(YEAR)SendData(Time)Time=ReadReg(MOUNTH)SendData(Time)Time=ReadReg(DAY)SendData(Time)Time=ReadReg(DATE)SendData(Time)Time=ReadReg(HOUR)SendData(Time)Time=ReadReg(MINUTE)SendData(Time)Time=ReadReg(SECOND)SendData(Time)WriteReg(FLAGS,x)ES=counter=*for(Add=Add<xffAdd){ReadData=ReadFRAM(Add)SendData(ReadData)}*}}}}=========================================定时中断读取时钟=========================================*voidTimer()interrupt{TH=xdcTL=xif(counter==){counter=WriteReg(FLAGS,x)允许读操作Time=ReadReg(YEAR)SendData(Time)Time=ReadReg(MOUNTH)SendData(Time)Time=ReadReg(DAY)SendData(Time)Time=ReadReg(DATE)SendData(Time)Time=ReadReg(HOUR)SendData(Time)Time=ReadReg(MINUTE)SendData(Time)Time=ReadReg(SECOND)SendData(Time)WriteReg(FLAGS,x)}else{counter}}*=========================================串口通讯中断读取时钟=========================================voidser()interrupt{RI=a=SBUFif(a==x)counter=}

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +1积分

资料评分:

/11
0下载券 下载 加入VIP, 送下载券

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部

举报
资料