Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

i2c,,,,24c02 with 8051....plz help me....

Status
Not open for further replies.

prabhu.embedded

Member level 1
Joined
Feb 14, 2012
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,562
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.................




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:

hi maybe there is problem in your delay try using a calculated delay by for loop instead of nop instruction
 

plz tell me about the ???how it work???plz see the code?????see the line of acknowlegemnt bit...is it right or wrong???
 

try checking in 8052.com there is a sample c code of 12c using 8051 it may help you.also check this link,it has a sample asm code
**broken link removed**
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top