【正文】
武漢科技大學(xué)本科畢業(yè)設(shè)計(jì)摘 要長期以來,以Flash Memory為存儲(chǔ)體的SD卡因具備體積小、功耗低、可擦寫以及非易失性等特點(diǎn)而被廣泛應(yīng)用于消費(fèi)類電子產(chǎn)品中。特別是近年來,隨著價(jià)格不斷下降且存儲(chǔ)容量不斷提高,它的應(yīng)用范圍日益增廣。當(dāng)數(shù)據(jù)采集系統(tǒng)需要長時(shí)間地采集、記錄海量數(shù)據(jù)時(shí),選擇SD卡作為存儲(chǔ)媒質(zhì)是開發(fā)者們一個(gè)很好的選擇。在電能監(jiān)測以及無功補(bǔ)償系統(tǒng)中,要連續(xù)記錄大量的電壓、電流、有功功率、無功功率以及時(shí)間等參數(shù),當(dāng)單片機(jī)采集到這些數(shù)據(jù)時(shí)可以利用SD作為存儲(chǔ)媒質(zhì)。本文主要介紹了SD卡在電能監(jiān)測及無功補(bǔ)償數(shù)據(jù)采集系統(tǒng)中的應(yīng)用方案。AT89C52是51系列單片機(jī)的一個(gè)型號(hào),它是ATMEL公司生產(chǎn)的。AT89C52是一個(gè)低電壓,高性能CMOS 8位單片機(jī),片內(nèi)含8k bytes的可反復(fù)擦寫的Flash只讀程序存儲(chǔ)器和256 bytes的隨機(jī)存取數(shù)據(jù)存儲(chǔ)器(RAM),器件采用ATMEL公司的高密度、非易失性存儲(chǔ)技術(shù)生產(chǎn),兼容標(biāo)準(zhǔn)MCS51指令系統(tǒng),片內(nèi)置通用8位中央處理器和Flash存儲(chǔ)單元,功能強(qiáng)大的AT89C52單片機(jī)可為您提供許多較復(fù)雜系統(tǒng)控制應(yīng)用場合。AT89C52有40個(gè)引腳,32個(gè)外部雙向輸入/輸出(I/O)端口,同時(shí)內(nèi)含2個(gè)外中斷口,3個(gè)16位可編程定時(shí)計(jì)數(shù)器,2個(gè)全雙工串行通信口,2個(gè)讀寫口線,AT89C52可以按照常規(guī)方法進(jìn)行編程,但不可以在線編程(S系列的才支持在線編程)。其將通用的微處理器和Flash存儲(chǔ)器結(jié)合在一起,特別是可反復(fù)擦寫的Flash存儲(chǔ)器可有效地降低開發(fā)成本。AT89C52有PDIP、PQFP/TQFP及PLCC等三種封裝形式,以適應(yīng)不同產(chǎn)品的需求。關(guān)鍵詞:SD卡;AT89C52單片機(jī); AbstractFor a long time to Flash Memory for storage of SD Cayenne body with small size, low power consumption, rewritable and nonvolatile memory is widely used in consumer electronics products. Especially in recent years, as prices continue to decline and storage capacity continue to increase, growing by its wide range of applications. When the data acquisition system takes a long time to collect, record huge amounts of data, select the SD card as the storage medium is the developers a good choice. In power monitoring and reactive power pensation system, to continuously record a lot of voltage, current, active power, reactive power and time parameters, the data collected when the MCU can use SD as a storage medium. This paper introduces the SD card in the power monitoring and data acquisition system reactive power pensation in the applications.AT89C52 is a model 51 puters, which is produced by ATMEL.AT89C52 is a low voltage, highperformance CMOS 8 bit microcontroller includes 8k bytes of readonly can be repeated erase the Flash program memory and 256 bytes of random access data memory (RAM), the device using ATMEL39。s high density, production of nonvolatile memory technologies, patible with the standard MCS51 instruction set, generalpurpose 8bit CPU chip and builtin Flash memory cells, powerful AT89C52 microcontroller can provide you with many of the more plex system control applications.AT89C52 40 pins, 32 external bidirectional input / output (I / O) ports, and includes two external interrupt ports, three 16bit programmable timer counters, two full duplex serial port, 2 a readwrite port line, AT89C52 can be programmed according to conventional methods, but not online programming (S series is supported online programming). The generic microprocessor and Flash memory together, particularly when repeated erase the Flash memory can effectively reduce the development costs.AT89C52 have PDIP, PQFP / TQFP and PLCC three kinds of packages to suit different products. Keywords: SD card。 AT89C52 MCU。目 錄1 SD卡的基本信息 6 SD卡的簡介 6 SD卡的使用 6 SD卡的辨別 7 SD卡覆寫保護(hù)開關(guān) 7 SD卡開放標(biāo)準(zhǔn) 7 SD卡技術(shù)說明 8 SD卡發(fā)展歷程 82 單片機(jī)的基本信息 單片機(jī)介紹 9 單片機(jī)歷史 112.3單片機(jī)的應(yīng)用領(lǐng)域 112.4 單片機(jī)的特點(diǎn) 112.5 單片機(jī)的基本組成 112.5 單片機(jī)的應(yīng)用 123 本設(shè)計(jì)的工作 134 SPI總線通訊協(xié)議 13 SPI模式的介紹 13 SPI總線組成 13 SPI總線協(xié)定 144.4總線傳輸保護(hù) 14 讀數(shù)據(jù) 15 寫數(shù)據(jù) 15 擦除和寫保護(hù) 16 讀CID/CSD寄存器 164.9 復(fù)位序列 164.10錯(cuò)誤條件 164.11命令格式 164.12響應(yīng) 164.13數(shù)據(jù)令牌 174.14數(shù)據(jù)錯(cuò)誤令 18 184.16SPI總路線時(shí)序表 18 5.SD總線協(xié)議模式 186.TTL電平與CMOS電平 19 19 19 19 19 CMOS器件的互連器件的互連總則 207.電平匹配 21 217.2 設(shè)計(jì)方案 218.硬件接口設(shè)計(jì) 228.1.1硬件設(shè)計(jì) 228.1.2接口電路設(shè)計(jì) 228.2軟件設(shè)計(jì) 229 軟件設(shè)計(jì) 259.1 SPI在AT89C52單片機(jī)中的實(shí)現(xiàn)方法 259. MCU 串行輸入子程序SPIIN 25 MCU 串行輸出子程序SPIOUT 26 MCU串行輸入/輸出子程序SPIIO 269.2 SD卡的初始化 29 數(shù)據(jù)塊的讀寫 3111 結(jié)束語 37參考文獻(xiàn) 1致謝 3732SD卡的基本信息1.1 SD卡簡介SD卡在24mm32mm(Multilevel Cell)技術(shù)和Toshiba(東芝),通過9針的接口界面與專門的驅(qū)動(dòng)器相連接,不需要額外的電源來保持其上記憶的信息。而且它是一體化固體介質(zhì),沒有任何移動(dòng)部分,所以不用擔(dān)心機(jī)械運(yùn)動(dòng)的損壞。SD卡的技術(shù)建是基于MultiMedia卡(MMC)格式上發(fā)展而來,大小和MMC差不多,尺寸為32mm x 24mm x 。長寬和MMC一樣,以容納更大容量的存貯單元。SD卡與MMC卡保持著向上兼容,也就是說,MMC可以被新的SD設(shè)備存取,兼容性則取決于應(yīng)用軟件,但SD卡卻不可以被MMC設(shè)備存取。(SD卡外型采用了與MMC厚度一樣的導(dǎo)軌式設(shè)計(jì),以使SD設(shè)備可以適合MMC)。SD接口除了保留MMC的7針外,還在兩邊加多了2針,作為數(shù)據(jù)線。采用了NAND型F