Adresse I2C ADC

Gast #2028060
Lesenswert?

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);
Gast #2028120
Lesenswert?

#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?
Gast #2028170
Lesenswert?

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.
Gast #2028260
Lesenswert?

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)

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren