• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Whenever you search in PBworks, Dokkio Sidebar (from the makers of PBworks) will run the same search in your Drive, Dropbox, OneDrive, Gmail, and Slack. Now you can find what you're looking for wherever it lives. Try Dokkio Sidebar for free.



Page history last edited by alexcp 1 year, 9 months ago

Интерфейс I2C на базе PCF8584, который можно воткнуть вместо ВВ55

(провод на фото исправляет ошибку, которую я допустил в первом варианте платы)

Gerber файлы для изготовления печатной платы (ошибка исправлена):pcf8584.zip

Пример программирования:

; PCF8584 use example

; Created by @alexcp on 20 Dec 2018

; Define PCF8584 ports

PCF_BASE    EQU     0A000h

DATA_REG    EQU     0

CTRL_REG    EQU     1




; Define PCF8584 status bit masks

PCF_BBN     EQU     01h             ; bus busy, active low

PCF_PIN     EQU     80h             ; pending interrupt, active low

PCF_LRB     EQU     08h             ; last received bit (typically the ACK bit)


; Define slave address


; Byte to send to the slave



            ORG     0

; initialize PCF8584


; program own slave address (this is required even if the address is not used)

            MVI     A, 80h          ; serial interface off; next byte will be loaded into register own address register

            STA     PCF_CTRL

            MVI     A, 55h          ; effective own address becomes 0AAh (55h<<1)

            STA     PCF_DATA

; program clock and I2C bus speed

            MVI     A, 0A0h         ; next byte will be loaded into the clock control register S2

            STA     PCF_CTRL

            MVI     A, 1Ch          ; system clock is 12 MHz; SCL = 90 kHz

            STA     PCF_DATA

; enable serial interface

            MVI     A, 0C1h         ; enable serial interface, set I2C-bus into idle mode

            STA     PCF_CTRL


; now actually send something to a slave


; wait for bus availability

            LDA     PCF_CTRL        ; load status byte

            ANI     PCF_BBN         ; is bus available?

            JZ      PCF_MASTER_TX   ; JIF not available

; form the slave address with the R/W bit (R=1, W=0) at LSB

            XRA     A               ; Carry = 0

            MVI     A, SLAVE_ADDR   ; load slave address

            RAL                     ; shift address left, set R/W bit to 0 (write)

            STA     PCF_DATA

; generate START condition on the I2C bus and clock out the address byte

            MVI     A, 0C5h          

            STA     PCF_CTRL        ; transmit address + R/W bit


; wait for the transmission to finish

            LDA     PCF_CTRL        ; poll for transmission finished

            MOV     B, A            ; store status byte for the later chack for acknowledgement

            ANI     PCF_PIN         ; is transmission complete?

            JNZ     TX10            ; not complete, keep waiting

            MOV     A, B

; check if the slave acknowledged the address

            ANI     PCF_LRB         ; slave acknowledged?

            JNZ     TXSTOP          ; JIF not acknowledged - maybe the slave is busy or not present at that address

; slave acknowledged the address, so send the data

            MVI     A, DATA_BYTE    ; byte to be transferred

            STA     PCF_DATA        ; send the data byte to the slave


; wait for the transmission to finish

            LDA     PCF_CTRL        ; poll for transmission finished

            ANI     PCF_PIN

            JNZ     TX20            ; JIF not finished

; here one can check for acknowledgement and send the next byte, etc.


; generate STOP condition on the I2C bus

            MVI     A, 0C3h          

            STA     PCF_CTRL        ; generate STOP condition


            JMP     PCF_MASTER_TX   ; repeat sending sequence


Comments (0)

You don't have permission to comment on this page.