【正文】
址也可以按字節(jié)尋址的 SFR。為數(shù)字外設(shè)分配端口引腳的優(yōu)先權(quán)順序列于圖 , UART0 具有最高優(yōu)先權(quán),而 CNVSTR 具有最低優(yōu)先權(quán)。 C8051F020/1/2/3 器件有大量的數(shù)字資源需要通過(guò) 4 個(gè)低端 I/O 端口 P0、P P2 和 P3 才能使用。 thus the values of the Port Data registers and the PnMDOUT registers have no effect on the states of these pins. The output drivers on Ports 0 through 3 remain disabled until the Crossbar is enabled by setting XBARE () to a logic 1. The output mode of each port pin can be configured as either OpenDrain or PushPull。低端口( P0、 P P2 和 P3)既可以按位尋址也可以按字節(jié)尋址。端口 1 的引腳可以用做 ADC1 的模擬輸入。注意:當(dāng)選擇了串行通信外設(shè)(即 SMBus、 SPI 或 UART)時(shí),交叉開(kāi)關(guān)將為所有相關(guān)功能分配引腳。在讀 修改 寫(xiě)指令的讀周期,所讀的值是端口數(shù)據(jù)寄存器的內(nèi)容,而不是端口引腳本身的狀態(tài)。在推挽方式,向端口數(shù)據(jù)寄存器中的相應(yīng)位寫(xiě)邏輯‘ 0’將使端口引腳被驅(qū)動(dòng)到 GND,寫(xiě)邏輯‘ 1’將使端口引腳被驅(qū)動(dòng)到 VDD。 通過(guò)設(shè)置輸出方式為“漏極開(kāi)路”并向端口數(shù)據(jù)寄存器中的相應(yīng)位寫(xiě)‘ 1’將端口引腳配置 為數(shù)字輸入。當(dāng)任何引腳被驅(qū)動(dòng)為邏輯‘ 0’時(shí),弱上拉自動(dòng)取消;即輸出引腳不能與其自身的上拉部件沖突。 2. 禁止引腳的弱上拉部件。配置步驟如下: 1. 按 UART0EN = UART1E = SMB0EN = INT0E = INT1E = 1 和EMIFLE =1設(shè)置 XBR0、 XBR1 和 XBR2,則有: XBR0 = 0x05, XBR1 = 0x14,XBR2 = 0x06。又因?yàn)橥獠看鎯?chǔ)器接口被配置為復(fù)用方式,所以交叉開(kāi)關(guān)也跳過(guò) (ALE)。 。 接下來(lái)是 /INT0,被分配到引腳 。 3. 將作為模擬輸入的端口 1 引腳配置為模擬輸入方式:設(shè)置 P1MDIN 為 0xE3( 、 和 為模擬輸入,所以它們的對(duì)應(yīng) P1MDIN 被設(shè)置為邏輯‘ 0’)。 如果外部存儲(chǔ)器接口( EMIF)被設(shè)置在低端口(端口 03), EMIFLE( )位應(yīng)被設(shè)置為邏輯‘ 1’,以使交叉開(kāi)關(guān)不將 (/WR)、 (/RD)和 (/ALE)(如果外部存儲(chǔ)器接口使用復(fù)用方式)分配給外設(shè)。 端口 1 的引腳可以用作 ADC1 模擬多路開(kāi)關(guān)的模擬輸入。 如果一個(gè)端口引腳被交叉開(kāi)關(guān)分配給某個(gè)數(shù)字外設(shè),并且該引腳的功能為輸入(例如 UART0 的接收引腳 RX0),則該引腳的輸出驅(qū)動(dòng)器被自動(dòng)禁止。當(dāng)系統(tǒng)中不同器件的端口引腳有共享連接,即多個(gè)輸出連接到同一個(gè)物理線時(shí)(例如 SMBus 連接中的 SDA 信號(hào)),使用漏極開(kāi)路方式可以防止不同器件之間的爭(zhēng)用。一旦配置完畢,將不再對(duì)其重新編程。被使能的外設(shè)的每種組合導(dǎo)致唯一的器件引腳分配。端口引腳的分配順序是從 開(kāi)始,可以一直分配到 。所有引腳都耐 5V 電壓,都可以被配置為漏極開(kāi)路或推挽輸出方式和弱上拉。附錄 附錄 1 外文文獻(xiàn) C8051F020 ( PORT INPUT/OUTPUT) The C8051F020/1/2/3 are fully integrated mixedsignal System on a Chip MCUs with 64 digital I/O pins (C8051F020/2) or 32 digital I/O pins (C8051F021/3), anized as 8bit Ports. The lower ports: P0, P1, P2, and P3, are both bit and byteaddressable through their corresponding Port Data registers. The upper ports: P4, P5, P6, and P7 are byteaddressable. All Port pins are 5 Vtolerant, and all support configurable OpenDrain or PushPull output modes and weak pullups. The C8051F020/1/2/3 devices have a wide array of digital resources which are available through the four lower I/O Ports: P0, P1, P2, and P3. Each of the pins on P0, P1, P2, and P3, can be defined as a GeneralPurpose I/O (GPIO) pin or can be controlled by a digital peripheral or function (like UART0 or /INT1 for example), as shown in Figure . The system designer controls which digital functions are assigned pins, limited only by the number of pins available. This resource assignment flexibility is achieved through the use of a Priority Crossbar Decoder. Note that the state of a Port I/O pin can always be read from its associated Data register regardless of whether that pin has been assigned to a digital peripheral or behaves as GPIO. The Port pins on Port1 can be used as Analog Inputs to ADC1. The Priority Crossbar Decoder, or “Crossbar”, allocates and assigns Port pins on Port 0 through Port 3 to the digital peripherals (UARTs, SMBus, PCA, Timers, etc.) on the device using a priority order. The Port pins are allocated in order starting with and continue through if necessary. The digital peripherals are assigned Port pins in a priority ord