Estoy intentando conectar el sensor de latidos cardíacos max30100 a 8051 para este propósito. Debería usar el protocolo i2c. Estoy usando el siguiente código para eso, pero el sensor no funciona a pesar de que hago la inicialización
; Init i2c ports first
lcall i2cinit
; Send start condition
lcall startc
; Send slave address
mov a,#0AEH
acall send
ACALL ACK
; after send call Carry flag has ACK bit
; If you want to check if send was a
; success or failure
; Send data
mov a,#09H
acall send
ACALL ACK
; Send another data
mov a,#0FFH
acall send
ACALL ACK
; Send stop condition
acall stop
lcall startc
; Send slave address
mov a,#0AEH
acall send
ACALL ACK
; after send call Carry flag has ACK bit
; If you want to check if send was a
; success or failure
; Send data
mov a,#07H
acall send
ACALL ACK
; Send another data
mov a,#47H
acall send
ACALL ACK
; Send stop condition
acall stop
lcall startc
; Send slave address
mov a,#0AEH
acall send
ACALL ACK
; after send call Carry flag has ACK bit
; If you want to check if send was a
; success or failure
; Send data
mov a,#01H
acall send
ACALL ACK
; Send another data
mov a,#0A0H
acall send
ACALL ACK
; Send stop condition
acall stop
SJMP $
sda equ P0.0
scl equ P0.1
i2cinit:
setb sda
setb scl
ret
rstart:
clr scl
setb sda
setb scl
clr sda
ret
startc:
setb scl
clr sda
clr scl
ret
stop:
clr scl
clr sda
setb scl
setb sda
ret
send:
mov r7,#08
back:
clr scl
rlc a
mov sda,c
setb scl
djnz r7,back
clr scl
setb sda
setb scl
mov c, sda
clr scl
ret
ack:
clr sda
setb scl
clr scl
setb sda
ret
nak:
setb sda
setb scl
clr scl
setb scl
ret
recv:
mov r7,#08
back2:
clr scl
setb scl
mov c,sda
rlc a
djnz r7,back2
clr scl
setb sda
ret
'