ich werde aus dem Datenblatt nicht schlau. kann mir keiner Helfen? Da muss es doch auch etwas deutschsprachiges geben. Ich habe die Programme nun ein bisschen gekürzt und schon einiges ausprobiert. Ich bekomm aber immer noch Error 1 und kann nichts senden und nichts empfangen.

Master:
Code:
$regfile = "M32def.dat"                           ' the used chip
$crystal = 16000000                               ' frequency used
$baud = 9600                                      ' baud rate

$lib "i2c_twi.lbx"                                ' we do not use software emulated I2C but the TWI

Config Scl = Portc.0                              ' we need to provide the SCL pin name
Config Sda = Portc.1                              ' we need to provide the SDA pin name
'the M8 slave uses a simple protocol
'WRITE -> Start-address-B1-B2-STOP
'READ  -> start-address-B1-B2-STOP
'start -> I2CSTART
'address-the slave address
'B1 and B2 are 2 bytes that when written, write to B1
'                           when read , return A/D converter value
Dim B1 As Byte , B2 As Byte
Dim W As Word At B1 Overlay

I2cinit                                           ' we need to set the pins in the proper state

Twbr = 12                                         'bit rate register
Twsr = 0                                          'pre scaler bits

Dim B As Byte , X As Byte
Print "Mega32 TWI master demo"

Do
  I2cstart
  I2cwbyte &H70                                   ' slave address write
  I2cwbyte &B10101010                             ' write command
  I2cwbyte 2
  I2cstop
  Print "Error : " ; Err                          ' show error status

  I2cstart
  I2cwbyte &H71
  I2crbyte B1 , Ack
  I2crbyte B2 , Nack
  I2cstop
  Print "Error : " ; Err                          ' show error
  Print "received A/D : " ; W
  Waitms 500                                      'wait a bit
Loop
End
Slave:

Code:
$regfile = "M32def.dat"                           ' the chip we use
$crystal = 16000000                               ' crystal oscillator value
$baud = 9600                                      ' baud rate

Config Scl = Portc.0                              ' we need to provide the SCL pin name
Config Sda = Portc.1                              ' we need to provide the SDA pin name

Config Adc = Single , Prescaler = Auto
'Now give power to the chip
Start Adc

Print "MCS Electronics M8 TWI-slave demo"
Print "Use with M32-TWI master demo"

Dim W As Word
Config Porta = Output
W = 123

Dim Twi_status As Byte
Dim Twi_data As Byte
'Dim Status As Byte
'Print Hex(status)

    Twsr = 0                                      ' status und Prescaler auf 0
    Twdr = &HFF                                   ' default
    Twcr = &B00000100                             ' erstmal nur TWI aktivieren
    Twar = &H40                                   ' Slaveadresse setzen
    Twcr = &B01000100                             ' dann ACK einschalten

'The variables  Twi , Twi_btr and Twi_btw are created by the compiler. These are all bytes
'The TWI interrupt is enabled but you need to enabled the global interrupt
Dim Twi As Byte , Twi_btr As Byte , Twi_btw As Byte

Enable Twi
Enable Interrupts
'this is just an empty loop but you could perform other tasks there
Do
Twi_gotdata:
   Print "received : " ; Twi ; " byte no : " ;
   Select Case Twi_btw
     Case 1 : Porta = Twi                         ' first byte
     Case 2:                                      'you go figure
   End Select


Loop
End
'The following labels are called from the library. You need to insert code in these subroutines

'A master can send or receive bytes.
'A master protocol can also send some bytes, then receive some bytes
'The master and slave must match.

'the following labels are called from the library  when master send stop or start
Twi_stop_rstart_received:
  Print "Master sent stop or repeated start"
Return
'master sent our slave address and will not send data
Twi_addressed_goread:
  Print "We were addressed and master will send data"
Return


Twi_addressed_gowrite:
  Print "We were addressed and master will read data"
Return

'this label is called when the master sends data and the slave has received the byte
'the variable TWI holds the received value

Return
'this label is called when the master receives data and needs a byte
'the variable twi_btr is a byte variable that holds the index of the needed byte
'so when sending multiple bytes from an array, twi_btr can be used for the index
Twi_master_needs_byte:
  Print "Master needs byte : " ; Twi_btr
  Select Case Twi_btr
    Case 1:                                       ' first byte
              W = Getadc(0)
              Twi = Low(w)
    Case 2                                        ' send second byte
              Twi = High(w)
  End Select
Return


'when the mast has all bytes received this label will be called
Twi_master_need_nomore_byte:
  Print "Master does not need anymore bytes"
Return
Das sind die Programme doch was soll das ganze im Slave bedeuten? Muss ich im Master nun noch etwas verändern oder passt das und wie sieht das im Slave aus, gehört da noch etwas gemacht?
Danke für jede Hilfe