Click here to load reader

第五章 单片机系统的扩展及接口技术

  • View
    109

  • Download
    0

Embed Size (px)

DESCRIPTION

第五章 单片机系统的扩展及接口技术. 5 .0 系统扩展概述 5 .1 串行扩展总线接口技术 5 .2 并行扩展三总线的产生 5 . 3 存储器扩展 5 . 4 I/O 口的扩展 5 . 5 键盘与显示器接口技术 5 . 6 数/模与模/数转换接口技术. 第五章 单片机系统的扩展及接口技术. XLAT1 P0. 30PF. 8051 8751 89 C51. 6 MHZ. P1. 30PF. XLAT2 P2. RESET P3. V CC. V C. 5 .0 系统扩展概述. 最小应用系统 - PowerPoint PPT Presentation

Text of 第五章 单片机系统的扩展及接口技术

  • 5.0 5.1 5.2 5.3 5.4 I/O5.5 5.6 //

  • 8051 8751 89C51 EPROM8031 5.0

  • 2. ROM RAMI/O / I/O() I/O(8155/8255/8253/8250/8251) E2PROM / EPROM RAM E2PROMEPROMRAM. SPII2CE2PROMA/DD/AMCUI/O

  • SPI 5.1 SPISerial Peripheral Interface MCU8 SPI SCK /MISO /MOSI CS(SS 89C51UARTI/O034I/OSPII2C

  • SPI LCDA/D SPI1. SPISPI SPI SPII/O

  • SPI1.05 Mb/sMSB(LSB SPISCK SPI 3CLK8-2 SPI

  • 2. 89C51SPI1 I/OSPI P1.11P1.108-389C51MCM2814E2PROM P1.0MCUMOSIP1.1SPISCKP1.2SPIP1.3SPIMISO

  • 89C51SPI/3A/D741/

  • 1. MCUSPIIN 2814SPISO1R0SPIINSETB P1.1P1.11CLRP1.2MOVR1#08HSPIN1CLRP1.1P1.10 NOPNOPMOVCP1.3SPISOCRLCAACCSETBP1.1P1.11DJNZR1SPIN181MOVR0A1R0RET

  • 2. MCUSPIOUT 89C51R02814SPISISPIOUTSETBP1.1P1.11CLRP1.2MOVR1#08HMOVAR01ACCSPIOT1CLRP1.1P1.10NOPNOPRLCAACCCMOVP1.0CCSPISISETBP1.1P1.11DJNZR1SPIOT181RET

  • 3. MCU/SPIIO 89C51R02814SPISI2814SPISO1R0SPIIOSETBP1.1P1.11CLRP1,2MOVR1#08HMOVAR01ACCSPIO1CLR P1.1P1.10 NOPNOPMOVCP1.3SPISOCRLCAACCC CACCMOVP1.0CCSETBP1.1P1.11 DJNZR1SPIO18MOVR0ARET

  • 2 89C510SPI I/OA/DD/A HT13808-4 HT1380 I/O RSTPIN RST / I/O

  • LEDMAX7219 MAX72198LED89C518-5 MAX7219 0MAX7219 TXD RXDI/O Load Load7219/LoadDIN 721989C51

  • E2PROMA/DD/A I/O 0 / 8-78-7

  • 8-8 I/O

  • I2C I2CPHILIPSI2CI2C1. I2C I2C SDASCL 100 kb/s400 kb/s400pF I2CI2CI2CI2CSDASCLSDASCL SDASCL

  • 8-9 I2C I2CI2C I2C

  • 7(D7D1)1(D00 /1 ) 7/ SDA SDA

  • 2. I2CI2CI2C SRAME2PROMADC/DACRTCI/ODTMF LEDLCD LCD

  • I2C I2C N/1 I2C I2CI2C

  • 3. I2C1I2C I2C8-11I2CSDASCLSDASCLI2CSCL

  • 8-12 I2C2I2C SCL=0SDASCL=0SDA SDASTARTSTOPSCL1 SCL=1 SDA SCL=1SDA10

  • I2C I2C I2CSDA4. I2CI2C8-13

  • SDASCL1I2CSCLI2C8I2C0

  • SCLSCLSDA SCLSCLSCL=0SDASCLSCL=1SDA AASCLSCL

  • 0SCLSDASDA1SDA SDASDA1,StopSDA 1SDAStop

  • 5. I2C1 7 0 1 SLA

  • 74384I2C I2CE2PROM AT24C10104LEDSAA10640111 3A2A1A0I2CA2A1A0P206 8-1

  • 8-1 I2C

  • 2I2CI2C815 I2CACK(1)STOP(Sr)

  • nn

  • /Srdata 1data nDATA 1DATA n

  • 6. 51I2C1 I2C 51I2CI2CI/OSCLSDA8-16251I2C I2CSDASCLNN

  • 7. I2C 89C51I2C 8-16P1.6P1.7SCLSDA6 MHz STASTOPMACKMNACKCACKWRBYTRDBYTNWRNBYTNRDNBYT91

  • 6 MHz2s STASTOPMACKMNACK4I2CSTASETBSDASETBSCL4.7sNOPNOPCLRSDANOP4sNOPCLRSCLRET

  • I2CSTOP CLRSDASETBSCLNOP4sNOPSETBSDANOPNOPCLRSDACLRSCLRETMACKCLRSDASETBSCLNOPSCL4sNOPCLRSCLSETBSDARET

  • MNACK SETBSDASETBSCLNOPSCL4.0 sNOPCLRSCLCLRSDARET6 MHzNOP2I2C CACKWRBYTRBYTNWRNBYTNRDNBYT 5

  • CACKF0F0=0F0=1 CACKSETB SDASDA SETB SCLSDA CLR F0F0=0 MOV CSDASDA JNC CENDSDA0CENDF0=0 SETB F0F0=1CEND CLR SCLSCL=0 RETWRBYTA R0C RDBYTSDAR2A: R0R2C

  • WRBYTMOVR0#08H8 R0WLP RLCACJCWR110AJMPWR00WR0WLP1DJNZR0WLP8RET8WR1SETBSDA1SETBSCLNOPNOPCLRSCLCLR SDAAJMPWLP1WR0CLRSDA0SETBSCLNOPNOPCLRSCLAJMPWLP1

  • RDBYTMOVR0#08H8R0RLPSETBSDASDASETBSCLSDAMOVCSDASDAMOVAR2bitCR2RLCAMOVR2ACLRSCLDJNZR0RLP8RLPRETNWRNBYTI2CN SLAW

  • WRNBYTMOVR3NUMBYTLCALLSTAI2CMOVASLASLAWLCALLWRBYTLCALLCACKJBF0WRNBYTMOVR1#[email protected] JBF0WRDA INCR1DJNZR3WRDALCALLSTOPRETNMTD

  • NRDNBYT N NSLAR

  • RDNBYTMOVR3NUMBYTLCALL STAMOVASLALCALL WRBYTLCALL CACKJB F0RDNBYTRDNMOVR1#MRDMRDR1RDN1LCALL [email protected] MNACKNLCALL STOPRETACKLCALL MACKINCR1SJMPRDN1

  • 3SDABITP1.7SCLBITP1.6MTDEQU30HMTDMRDEQU40HMRD SLAEQU60HSLA SLAR/WNUMBYTEQU61HNUMBYT

  • 1WireDallas/PC1I/O/Dallas DS18S20DQDQRP

  • 1. DS18S20 DS18S20 DS18S20DS18S2020 m10 1 DS18S20 DS18S203PR358SOICDQ/VDD MCU ()9 -551250.5(-1085) 750 ms DS18S20

  • 2 DS18S20 64ROMRAMTHTL8CRC 8 DS18S205V DS18S20DS18S20

  • 98168-23VDDDS18S20MOSFETI/OP1.0P1.1TxP1.2RxDS18S2050 m

  • 4 89C51DS18S20 DS18S20 89C51ROM33H DS18S20DS18S20DS18S2064RAM

  • DS18S20 ROMROM564ROM56CRC

  • DS18S20DS18S206 RAMEEROMTHTL RAMEEROM RAM912THTL3478CRC956

  • DS18S20 480s ROM DS18S20I/O0011DS18S2064RAMDS18S20

  • 2. 11-Wire KE E80060 420mA

  • / I/O() 373273 244245DRS CPU I/O(8155/8255/8253/8250/8251) E2PROM / EPROM E2PROM2816(2K8), 2864(8K8) EPROM2716(2K8), 2732(4K8), 2764(8K8) RAM RAM6116(2K8), 6264(8K8)E2PROMEPROMRAM.

  • 3 5.2

  • 89C51432P1P3 89432 KBMCU

  • ROM 5.3 CPU P0P2. 2764 0000H1FFFH 271280000H3FFFH

  • ROM MOVC [email protected]+PC MOVC [email protected]+DPTR 89C51RAM12864K 89C516116 .

  • 89C5132KB EPROM32KB RAM E2PROM (MM) E2PROM ROMRAM 1.2816 2816A 2K82817 2817A 2K8 A21V 2864A 8K8 A5V

  • 2817A2864ARDY/BUSYCPU 200250nsEPROM 10ms(RAM

  • 16(1). CPU2864A 16 20nsE2PROM 2864 1111000001110000()11110000 CPU I/O 7

  • 89C512864A 2864AROMRAM0000H~1FFFH

  • 16E2PROMMOV R110H16WR1MOVX [email protected] MOV R4AMOVX @R0A2864(P2R0)INC DPTRINC R0 CJNE R0#00NEXTR000FFH INC P200H~FFH1NEXTDJNZ R1WR1 DEC R016CHECKMOVX [email protected] XRL AR4 E2PROM JB ACC.7CHECK ACC.71,, RET 1

  • 1. 64KBRAM EPROM RAMEPROMRAMEPROMCPU 74LS138 74LS139 5174LS139 P2.70 74LS139 P2.6P2.5

  • IC00000H~1FFFHY0 IC12000H~3FFFHY1 IC20000H~1FFFHY0 IC34000H~5FFFHY2 Y3 6000H~7FFFH

  • 2. 64KB RAM 8 KB EPROM 1,32KB RAM 7224KRAMRAM > 64K,P1.P1.0 A16 P1.1 A17 P1.2 A18 381EPROM 32KRAM15P0P2.0P2.6 CPUP2.7P1.0P1.174LS13886225671I/O(64K),P1P1.0 P1.1.

  • 1. I/O/ 51 P0~P3 LEDBCD LOOPMOV A#0FH ORL P1A MOV AP1 SWAP A MOV P1A AJM LOOP 5.4 I/OI/O

  • 2. I/OLOOP MOV DPTR#0FEFFH MOVX [email protected] MOVX @DPTRA SJMP LOOP 74LS273 373 ) 244/245 LED 244273P2.0FEFFH51RAMRAMMOVXRDWRRDWR/

  • 244/273P2

  • ()()I/O P266 TTLJ 1. P1.00JP1.11J

  • a R20 1b J0 J1

  • TTLHTLCMOS P1.00SSR P1.01SSR SSRSSR

  • P1.0=0OC110V P1.0=1OC0 10VVcP1.0OC2.

  • 4N2514N25 Pin 6 2

  • 3 MOC3041 (), 4N40 SSR 1530mA

  • 51I/O MCS-51RAMI/ORAM 64KBI/O825518255 8255PAPBPC7FFCH7FFDH7FFEH7FFFHI/O 8255PAPB89C51R289C51A

  • R8255: MOV DPTR#7FFFH MOV A#98H ; MOVX @DPTRA MOV DPTR#7FFDH MOV AR2 ; R2 PB MOVX @DPTRA MOV DPTR#7FFCH MOVX [email protected] ; PA A RET PAPBPC7FFCH7FFDH7FFEH7FFFHRAM 20H50

  • BCDASCII R-S 510ms,1. 1 , I/OP2312 () 5.5

  • STARTMOVA#0FFH P11MOVP1AMOVAP1 JNBACC.0P0F 0P0FJNBACC.1P1F 1P1FJNBACC.2P2F 2P2FJNBACC.3P3F 3P3FJNBACC.4P4F JNBACC.5P5FJNBACC.6P6FJNBACC.7P7F 7P7FJMPSTART P0FLJMP PROM0 P7F LJMP PROM7PROM0 0 JMPSTART 0PROM7 JMPSTARTP231

  • 2. (1) 1 2CTC 3CPU CPU3P1FEH P1(20ms) N=+()A

  • N=+4P235 P23744048C0123

  • 3.

    P239

    32 0F 1631

  • 1LED LEDLED2LED 3. LED89C51 P243 9-14

  • TABDB3FH06H5BH4FH66H6DHDB7DH07H7FH6FH77H7CHDB39H5EH79H71H40H00H

    D1MSMOVR7#02H1 msDLMOVR6#0FFHDL1DJNZR6DL1DJNZR7DLRET

  • DISMOVR0#7EHR0MOVR2#01HMOVAR2MOVDPTR#[email protected]@A+DPTRMOVP0AACALL D1MSDECR01MOVAR2JBACC.5LP1?RLA1MOVR2AAJMPLP0LP1RET

  • /LEDP245

  • A/DD/A1.D/A TLC5615 5.6 //DAC89C51TLC56153SPID/A10bit12.5 s0

  • TLC5615

    I/ODIN1ISCLK2I/CS3IDOUT4OAGND5REFIN6IOUT7ODACVDD84.55.5V

  • MSBLSB1216

  • 89C51 R0R112D/ACLR P3.0MOV R2#44MOV AR044SWAP AA444LCALL WrdataDIN4MOV R2#88MOV AR18ALCALL WrdataDIN8CLR P3.1SETB P3.012RETWRdata NOPLOOPCLR P3.1RLC ACYMOV P3.2CTLC5615SETB P3.1DJNZ R2LOOPRET

  • DAC08322.D/A 0832 LE11LE10 ILECSWR1LE11WR1 XFERWR2LE21WR2DAC

  • 0832 P276 DACRegDAC Reg P2.700832 MOV DPTR#2FFFH MOV A#3FH) MOVX @DPTRA P276 DACP276277

  • ADC 89C511.A / D A/DSPITLC1549TLC1543TLC2543MAX1872I2CMAX127PCF8591A / D TCL154910ADC21s1 LSB+5 V2.5 mA-55+125

  • TLC15491324280 kHz280 kHzI/O CLOCK 5364

  • CSDATA1.3 sA/D119192.1 MHzA/D26 s

  • 154989C51SPITLC154910ORG 0050HR1549CLRP3.0TLC1549MOVR0#2LCALLRDATAMOVR1AR1MOVR0#88LCALLRDATAMOVR2A8R2SETBP3.0CLRP3.1RETRDATACLRP3.1MOVCP3.2CYRLCAASETBP3.1DJNZR0RDATARET

  • ADC 0809(640Khz)100us CPU 0809ADC 080989C512.A / D STARTALEEOCOECLK640 kHz

  • 0809 ADCP262

  • P262MAIN:MOV R0#0A0H MOVX [email protected] 080989C51ALE0809RAMMOVXALE A/DA/D

  • EEPROMI2C ATMEL AT24CXX AT93CXX

    AT24C02256B AT24C04 256B2

    I2C

  • IIC1.SCLSDASCLSDA

  • 2.24C0241010B301 3.1ACK4.

  • 5.

  • EEPROMW_EPR R3=101000001010+3000 +/ R4= R1= R7=n

    SCLBITP3.6;24C02 SDABITP3.7;24C02

  • W_EPR: MOV P3#0FFH CLR SDA MOV AR3 ACALL SUBS MOV AR4 ACALL SUBS AIN: MOV [email protected] ACALL SUBS INC R1 DJNZ R7,AINn CLR SDA SDA0, ACALL DELAY SETB SCL ACALL DELAY SETB SDA RET

  • SUBS: MOV R0#08H ; LOOP: CLR SCL RLC A MOV SDAC; NOP SETB SCL ACALL DELAY DJNZ R0LOOP ;88bit CLR SCL ACALL DELAY SETB SCL REP: MOV CSDA JC REP; CLR SCL RET

  • E2PROMR_EPR R1= R3=101000011010+3000 +/ R4= R7=

  • R_EPR: MOV P3 #0FFH CLR SDA ; MOV A R3 ; ACALL SUBS ; MOV A R4 ; ACALL SUBS MOV P3#0FFH CLR SDA ; MOV A R3 SETB ACC.0 ; ACALL SUBS MORE: ACALL SUBR MOV @R1A INC R1 DJNZ R7MORE CLR SDA ACALL DELAY SETB SCL ACALL DELAY SETB SDA ; RET

  • SUBR: MOV R0#08H ; LOOP2: SETB SCL ACALL DELAY MOV CSDA RLC A CLR SCL ACALL DELAY DJNZ R0LOOP2 CJNE R7#01HLOW SETB SDA;SDA=1 AJMP SETOK LOW: CLR SDA;SDA=0 SETOK: ACALL DELAY SETB SCL ACALL DELAY CLR SCL ACALL DELAY SETB SDA ;SDA1 RET