專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開發(fā)工具、應用測試 完善的開發(fā)代碼案例庫分享
從全面的產(chǎn)品導入到強大技術支援服務 全程貼心伴隨服務,創(chuàng)造無限潛能!
十年專注單片機方案開發(fā)的方案公司英銳恩,分享軟件模擬用24c02。英銳恩現(xiàn)提供服務產(chǎn)品涉及主控芯片:8位單片機、16位單片機、32位單片機及各類運算放大器等。
INCLUDE STATUS EQU 3H PORTB EQU 6H PORTC EQU 7H EEPROM EQU 08H ADDR EQU 09H BUFIN EQU 0AH BUFOUT EQU 0BH SLAVE EQU 0CH TXBUF EQU 0DH BIT EQU 0EH DLY1 EQU 0FH DLY2 EQU 10H DI EQU 7 DO EQU 6 SDA EQU 7 SCL EQU 6 ACKF EQU 0 ;********************** ORG 7FFH GOTO MAIN ORG 000H ;********************** BSTART BSF PORTB,SDA BSF PORTB,SCL MOVLW B'00111111' TRIS PORTB NOP NOP NOP NOP NOP NOP BCF PORTB,SDA NOP NOP NOP NOP NOP BCF PORTB,SCL NOP NOP RETLW 0 ;********************** BSTOP BCF PORTB,SDA MOVLW B'00111111' TRIS PORTB BCF PORTB,SDA NOP NOP NOP BSF PORTB,SCL NOP NOP NOP BSF PORTB,SDA NOP NOP BCF PORTB,SCL NOP NOP RETLW 0 ;********************** TX MOVLW D'8' MOVWF BIT TXLP BCF
EEPROM,DO BTFSC TXBUF,7 BSF EEPROM,DO CALL BITOUT RLF TXBUF DECFSZ BIT GOTO TXLP CALL BITIN BTFSC EEPROM,DI BSF PORTC,ACKF RETLW 0 ;************************ RX CLRF BUFIN MOVLW D'8' MOVWF BIT BCF STATUS,0 RXLP RLF BUFIN BCF BUFIN,0 CALL BITIN BTFSC EEPROM,DI BSF BUFIN,0 DECFSZ BIT GOTO RXLP BSF EEPROM,DO CALL BITOUT RETLW 0 ;********************** BITOUT MOVLW B'00111111' tris PORTB BTFSS EEPROM,DO GOTO BITLOW BSF PORTB,SDA GOTO CLKOUT BITLOW BCF PORTB,SDA CLKOUT BSF PORTB,SCL NOP NOP NOP NOP BCF PORTB,SCL RETLW
0
;********************** BITIN BSF EEPROM,DI MOVLW B'10111111' TRIS
PORTB BSF PORTB,SCL NOP NOP NOP NOP NOP BTFSS PORTB,SDA BCF EEPROM,DI
BCF PORTB,SCL RETLW 0 ;*********************** MAIN MOVLW B'00000000'
TRIS PORTC CLRF PORTC WRITE CLRF PORTC MOVLW B'10100000' MOVWF SLAVE
MOVLW B'10101010' MOVWF BUFOUT CLRF ADDR LOOP0 CALL BSTART MOVF SLAVE,0
MOVWF TXBUF CALL TX MOVF ADDR,0 MOVWF TXBUF CALL TX MOVF BUFOUT,0 MOVWF
TXBUF CALL TX CALL BSTOP DELAY10MS MOVLW D'13' MOVLW DLY1 MOVLW 0FFH
MOVWF DLY2 LP0 DECFSZ DLY2 GOTO $-1 DECFSZ DLY1 GOTO $-5 READ CLRF PORTC
MOVLW B'10100000' MOVWF SLAVE CLRF ADDR LOOP1 CALL BSTART MOVF SLAVE,0
MOVWF TXBUF CALL TX MOVF ADDR,0 MOVWF TXBUF CALL TX CALL BSTART MOVLW
B'10100001' MOVWF TXBUF CALL TX CALL RX CALL BSTOP NOP NOP NOP NOP NOP
NOP MOVF BUFIN,0 MOVWF PORTC LOOP2 NOP GOTO $-1
;************************ END