Hi all,
I am trying to get a MAG3110 to work, or just to get an answer to a WHO_AM_I register query.
here's a snippet:
[code:1:1dd3cc329d]$regfile = "attiny84.dat"
$crystal = 8000000
Led Alias Porta.3
Config Sda = Porta.1
Config Scl = Porta.0
Config I2cdelay = 10
I2cinit
Dim Adr_mag_w As Byte
Adr_mag_w = &H0E 'Slave Adress MAG3110 WRITE
Dim Adr_mag_r As Byte
Adr_mag_r = &H0F 'Slave Adress MAG3110 READ
Int1mag Alias Porta.7
Dim N As Byte
Waitms 100
Do
Led = 0
Waitms 1
'Who am I
I2cstart
I2cwbyte Adr_mag_w
I2cwbyte &H07
I2cstart
I2cwbyte Adr_mag_r
I2crbyte N , Nack
I2cstop
If N = &HC4 Then
Led = 1
Wait 1
End If
Loop[/code:1:1dd3cc329d]
I'm stuck and would be glad for any suggestion
[b:1dd3cc329d][color=red:1dd3cc329d](BASCOM-AVR version : 2.0.7.6 )[/b:1dd3cc329d][/color:1dd3cc329d]
↧