Im Datenblatt, auf seite 15, steht Folgendes: The first byte after the START bit is always the address byte of the device, which includes the device code (4 bits), address bits (3 bits), and R/W bit. The device code of the MCP is 1101, which is programmed at the factory. The device code is followed by three address bits (A2, A1, A0) which are also programmed at the factory. The three address bits allow up to eight MCP devices on the same data bus line. http://ww1.microchip.com/downloads/en/DeviceDoc/22072b.pdf Also die ersten 4 sind der Device code, danach die adress bits und am ende das R/W bit. Woher kenne ich die 3 Adress bits?! #define Adr_ADC 0b11010000 i2c_start_wait(Adr_ADC+I2C_READ);
Hi, schau auf die Seite: 16 FIGURE 5-1: MCP3425 Address Byte. Wenn du den Chip nicht bei der Factory bestellt hast, ist der '000'!!! Stephan
#define Adr_MCP_ADC 0b11010000 i2c_start_wait(Adr_MCP_ADC+I2C_READ); for (uint8_t i=0; i<=4; i++){ hig = i2c_read(1); myuart_putc( hig ); } gibt mir folgende werte: 0b00000000 0b00101010 (auch mal 0b00101101 oder 0b00101011 oder 0b00101010) 0b00010000 0b00010000 standardmäßig sollte er mir doch den ADC wert zurückliefern oder?
Das tut er auch, ich vollidiot hab den ADC nicht angeschlossen Vielen Dank für die Tips mit der Addresse!
ein kleines Problem bleibt allerdings.. nachdem ich einen Wert ausgelesen habe und die Funktion void i2c_stop(void) aufrufe, bleibt er bei der Fleury lib bei // wait until stop condition is executed and bus released while(TWCR & (1<<TWSTO)); stehen.
wie ist bei dir das letzte Byte terminiert? Siehe DB: S.18 FIGURE 5-3: Timing Diagram For Reading From The MCP3425 Stephan
Ich habe das mal abgeändert hig = i2c_read(1); low = i2c_read(0); der wählt anhand dem 0 oder 1 die funktion Ack oder Nack aus. scheinbar war es das Ack was fehlte. Soweit so gut, nun nur noch raus bekommen wie ich nicht nur den wert auslese sondern auch das config Register. (also nur auslesen um es anzusehen)
hi Simon, kannstu mal deine Code hier komplett nochmal posten? ich brauche paar Abschnitte für eine Beispielcode! Vilen Dank im Voraus!! MFG
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.