Liebe Community, habe ein Problem mit der Kommunikation zwischen einem Atmel Mega16 und einem TLC59116(Pwm LED Controller) per I²C. Wenn ich Daten schicke meldet der Bus keine Fehler. Im letzten Programmteil lese ich nochmal alle Register aus und die haben alle den Wert 255. Was mache ich falsch?? Hoffe Ihr könnt mir weiter helfen... Schonmal im Vorraus danke für alle Hilfe. Hier noch der Programmcode (Bascom): $regfile = "m16def.dat" $crystal = 16000000 $baud = 9600 $lib "i2c_twi.lbx" Config Twi = 400000 Twcr = &B00000100 'Tlc Adressen Const All = &HD0 Const All_reset = &HD6 Const Tlc_1 = &HC2 Const Tlc_1_read = &HC3 Const Helligkeit = 187 'Variablen Dim X As Byte Dim Eingang(32) As Byte 'Reset I2cstart I2cwbyte All_reset I2cwbyte &HA5 I2cwbyte &H5A I2cstop Print "Reset: Done" Print Err Waitms 20 'Initialisierung I2cstart I2cwbyte All I2cwbyte &B10000000 I2cwbyte &B00000001 I2cwbyte &B00000000 For X = 0 To 15 I2cwbyte 0 Next I2cwbyte 255 I2cwbyte 0 For X = 0 To 3 I2cwbyte &B11111111 Next I2cstop Waitms 20 Print "Init: Done" Print Err Do I2cstart I2cwbyte Tlc_1 I2cwbyte &B10100010 For X = 0 To 15 I2cwbyte Helligkeit Next I2cstop Print "Send" Print Err Waitms 500 I2cstart I2cwbyte Tlc_1_read I2cwbyte &B10000000 For X = 1 To 32 I2crbyte Eingang(x) , Nack Next I2cstop Print "Register: " For X = 1 To 32 Print X ; ": " ; Eingang(x) Next Wait 3 Loop End
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.