This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

24C32

HI
I NEED ASSEMBLY CODE FOR AT24C32 FOR MY PROJECT
THANKYOU

Parents Reply Children
  • i am trying but no response
    i am using 89c52 and the given code.

    ; Pin Definations
    eeprom_scl_pin reg p2.1
    eeprom_sda_pin reg p2.2
    ; Main Program starts from here
    mov memory_address1,#00h
    mov memory_address2,#00h
    mov eeprom_data,#05
    call write_data
    mov memory_address1,#00h
    mov memory_address2,#00h
    call read_data
    mov 5dh,3ch
    loop:
    jmp loop
    ; Sub routines starts from here
    write_data call eeprom_start
    mov a,#a0h
    call send_data
    mov a,memory_address1 ;locati ddress
    call send_data
    mov a,memory_address2 ;locion address
    call send_data
    mov a,eeprom_data ;data to be send
    call send_data
    call eeprom_stop
    ret
    ;======
    read_data:
    call eeprom_start
    mov a,#a0h
    call send_data
    mov a,memory_address1 ;location address
    call send_data
    mov a,memory_address2 ;location address
    call send_data
    call eeprom_start
    mov a,#a1h
    call send_data
    call get_data
    call eeprom_stop
    ret
    ;================================
    eeprom_start:
    setb eeprom_sda_pin
    nop
    setb eeprom_scl_pin
    nop
    nop
    clr eeprom_sda_pin
    nop
    clr eeprom_scl_pin
    ret
    ;==================================
    eeprom_stop clr eeprom_sda_pin
    nop
    setb eeprom_scl_pin
    nop
    nop
    setb eeprom_sda_pin
    nop
    clr eeprom_scl_pin
    ret
    ;======================================
    send_data mov r7,#00h
    send rlc a
    mov eeprom_sda_pin,c
    call clock
    inc r7
    cjne r7,#08,send
    setb eeprom_sda_pin
    jb eeprom_sda_pin,$
    ; call eeprom_delay
    call clock
    ret
    ;=========================================
    get_data
    mov r7,#00h
    setb eeprom_sda_pin
    get mov c,eeprom_sda_pin
    call clock
    rlc a
    inc r7
    cjne r7,#08,get
    setb eeprom_sda_pin
    call clock
    mov 3ch,a
    ret
    ;==========================================
    clock setb eeprom_scl_pin
    nop
    nop
    clr eeprom_scl_pin
    ret
    ;===========================================
    eeprom_delay mov 33h,#11 ;delay of 3 msec
    eeprom_delay_1 mov 32h,#ffh
    djnz 32h,$
    djnz 33h,eeprom_delay_1
    ret
    ;============================================
    ; Program END