sd卡读写程序(sd card read and write program)

sd卡读写程序(sd card read and write program)

ID:12763415

大小:21.58 KB

页数:19页

时间:2018-07-18

sd卡读写程序(sd card read and write program)_第1页
sd卡读写程序(sd card read and write program)_第2页
sd卡读写程序(sd card read and write program)_第3页
sd卡读写程序(sd card read and write program)_第4页
sd卡读写程序(sd card read and write program)_第5页
资源描述:

《sd卡读写程序(sd card read and write program)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、sd卡读写程序(SDcardreadandwriteprogram)SDcardreadandwriteprogramObjective:TostudytheSDcard//operationDesign/software1,usingSPIcommunication//SDcard2,gotoSD//inorderto0-255atotalof256data,andthenreadbackLCD1602display//hardwarerequirements:S11ON//dialswitchJumperJ18//allconnected#include

2、4.h>//dsPIC30F6014standardheaderfile_FOSC(CSW_FSCM_OFF&XT_PLL4);//4doublercrystaloscillator,Failsafeclockclosed_FWDT(WDT_OFF);//closethewatchdogtimer_FBORPOR(PBOR_OFF&MCLR_EN);//resetprohibitedMCLRresetenable._FGS(CODE_PROT_OFF);//codeprotectionagainst#defineCSPORTGbits.RG9//SDcardselectio

3、npindefinition#defineRSLATBbits.LATB4//definitionLCDcontrolbits(noteherecanonlyregisterwithLATB,youcannotdirectlyusethePORTBregister)#defineRWLATBbits.LATB5#defineeLATBbits.LATB6Unsignedchar__attribute__((address(0x900)))lcd[3]={0,0,0};Void(spi_init);//declarationsysteminitialfunctionVoid(

4、spi_low);//thatproduceslowbaudrate(usingtheSDcardinitializationfunction)Void(spi_high);//thatproducehighbaudratefunction(SDcardinitializationafteruse)Unsignedchar(sd_reset);//thattheSDcardinitializationfunctionUnsignedcharSD_SendCommand(unsignedcharCMDunsigned,longARG);//writeSDcardcommand

5、functionstatementUnsignedcharSPI_WriteByte(unsignedcharVAL);//writeabytefunctionstatementUnsignedcharSPI_ReadByte(void);//thatreceiveabytefunctionUnsignedcharSD_WriteSingleBlock(unsignedlongsector);//thatsingleBLOCKdatawriteSDcardfunctionUnsignedcharSD_ReadSingleBlock(unsignedlongsector);/

6、/readSDcarddatafunctionsingleBLOCKstatementVoid(lcd_display);//stateresultsdisplayfunctionVoid(delay);//statedelayfunction(shownby)//systeminitializationfunctionVoidspi_init(){TRISG=0x00d0;//settheSDIoutput,CoutputportfortheotherTRISB=0X0000;//setfortheoutputportBTRISD=0X0000;//setfortheou

7、tputportDSPI2CON=0x0278;//idlebusishigh,fosc/64SPI2STAT=0x8000;//theendofsamplingtheoutputdataofinputdata,therisingedgeofdatatransmission}WriteaLCDprogram****************************************//*************************//writeabyteofdatafunctionAfterchanging

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。