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