prabhu.embedded
Member level 1
hlo....
i m doing a project on i2c with 8051...but its not write properly......plz help me
below is the code ....plz check it.................
i m doing a project on i2c with 8051...but its not write properly......plz help me
below is the code ....plz check it.................
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 org 00h ;org 30h sjmp main sda equ p1.1 scl equ p1.2 main: ;;;;;;;;;;;;;;;;;;;;;;;;wrt;;;;;;;;;;;;;;;;;;;;; k1: acall strt k2: clr c mov a,#01000001h MOV r1 ,#8 k4: rrc a ss: mov sda,c djnz r1,k4 ; cjne a,#10100000b,k2 acall ack acall k3 ;clr p1.1 ;;;;;;;;;wrt ; jc j1 ;setb sda nop nop k3: mov a,#41h jc j1 ;;;;;;if no ack mov a,45h ;;;;;mry addres ; sjmp k3 acall ack mov a,#41h acall ack ;;;;;;;;;;;data ; sjmp k3 jc j1 ;k4: ;mo j1: acall j2 ;;;;;stop ret j2: clr sda ;;;;;;;;; l 2 h fr stop nop nop setb scl nop nop setb sda clr c ret ; setb sda strt: setb sda nop nop ;;;;;;h 2 l fr strt setb scl nop nop clr sda clr c ret ; clr scl ACK: CLR SDA NOP NOP SETB SCL ; CLOCK THE ACK NOP CLR SCL ; BRING CLOCK LOW RET ret delay: nop nop nop nop nop nop ret end
Last edited by a moderator: