Witam,
potrzebuję do nowej aplikacji zastosować dwa przetworniki A/D microchipa MCP3221. Cytuję dokumentację:
5.2 Device Addressing
The address byte is the first byte received following the
START condition from the master device. The first part
of the control byte consists of a 4-bit device code, which
is set to 1001 for the MCP3221. The device code is followed
by three address bits: A2, A1 and A0. The default
address bits are 101. Contact the Microchip factory for
additional address bit options. The address bits allow
up to eight MCP3221 devices on the same bus and are
used to determine which device is accessed.
The eighth bit of the slave address determines if the
master device wants to read conversion data or write to
the MCP3221. When set to a ‘1’, a read operation is
selected. When set to a ‘0’, a write operation is
selected. There are no writable registers on the
MCP3221. Therefore, this bit must be set to a ’1’ in
order to initiate a conversion.
The MCP3221 is a slave device that is compatible with
the I2C 2-wire serial interface protocol. A hardware
connection diagram is shown in Figure 6-2. Communication
is initiated by the microcontroller (master
device), which sends a START bit followed by the
address byte.
On completion of the conversion(s) performed by the
MCP3221, the microcontroller must send a STOP bit to
end communication.
The last bit in the device address byte is the R/W bit.
When this bit is a logic ‘1’, a conversion will be executed.
Setting this bit to logic ‘0’ will also result in an
“acknowledge” (ACK) from the MCP3221, with the
device then releasing the bus. This can be used for
device polling. Refer to Section 6.3 “Device Polling”,
“Device Polling”, for more information.
Tak jak można wywnioskować adres urządzenia dla zapisu to: 10011010 (0x9A) natomiast dla odczytu: 10011011 (0x9B). Pierwsze 4 bity to stały adres urządzenia (1001) natomiast kolejne 3 pozwalają na adresowanie na jednej magistrali do 8 urządzeń, co by się zgadzało, 2^3 = 8. Niestety nie rozumiem za bardzo w jaki sposób to się odbywa. Domyślnie część zmienna adresu (A2A1A0) ma wartość 101. W takim razie, skoro układ nie posiada programowalnych rejestrów, właściwie żadnych rejestrów, z których coś odczytujemy jak zmienić adres urządzenia ? Tzn. może inaczej, wiadmo, że są pewnie kombinacje 000 001 010 itd., ale chodzi mi o to, skąd kilka urządzeń na jednej magistrali ma wiedzieć, że np. adres "rzucony na sztywno" dajmy na to 10010011 należy do układu nr1 natomiast jakiś tam adres 10010101 należy do układu nr2. ? Nie mogę tego pojąć, skoro nie ustawiamy nic, to oba układy (wszystkie układy) na dzień dobry mają adres 1001101x (x zapis/odczyt) więc powstanie jedna wielka kaszanka, gdy żadne urządzenie nie będzie wiedziało jak odpowiedzieć...powstanie kolizja na magistrali, bo kilka urządzeń na raz będzie chciało wysyłać bit potwierdzenia. Czy może mi to ktoś wyjaśnić ?
Z góry dzięki i miłego dnia,
Pozdrawiam
potrzebuję do nowej aplikacji zastosować dwa przetworniki A/D microchipa MCP3221. Cytuję dokumentację:
5.2 Device Addressing
The address byte is the first byte received following the
START condition from the master device. The first part
of the control byte consists of a 4-bit device code, which
is set to 1001 for the MCP3221. The device code is followed
by three address bits: A2, A1 and A0. The default
address bits are 101. Contact the Microchip factory for
additional address bit options. The address bits allow
up to eight MCP3221 devices on the same bus and are
used to determine which device is accessed.
The eighth bit of the slave address determines if the
master device wants to read conversion data or write to
the MCP3221. When set to a ‘1’, a read operation is
selected. When set to a ‘0’, a write operation is
selected. There are no writable registers on the
MCP3221. Therefore, this bit must be set to a ’1’ in
order to initiate a conversion.
The MCP3221 is a slave device that is compatible with
the I2C 2-wire serial interface protocol. A hardware
connection diagram is shown in Figure 6-2. Communication
is initiated by the microcontroller (master
device), which sends a START bit followed by the
address byte.
On completion of the conversion(s) performed by the
MCP3221, the microcontroller must send a STOP bit to
end communication.
The last bit in the device address byte is the R/W bit.
When this bit is a logic ‘1’, a conversion will be executed.
Setting this bit to logic ‘0’ will also result in an
“acknowledge” (ACK) from the MCP3221, with the
device then releasing the bus. This can be used for
device polling. Refer to Section 6.3 “Device Polling”,
“Device Polling”, for more information.
Tak jak można wywnioskować adres urządzenia dla zapisu to: 10011010 (0x9A) natomiast dla odczytu: 10011011 (0x9B). Pierwsze 4 bity to stały adres urządzenia (1001) natomiast kolejne 3 pozwalają na adresowanie na jednej magistrali do 8 urządzeń, co by się zgadzało, 2^3 = 8. Niestety nie rozumiem za bardzo w jaki sposób to się odbywa. Domyślnie część zmienna adresu (A2A1A0) ma wartość 101. W takim razie, skoro układ nie posiada programowalnych rejestrów, właściwie żadnych rejestrów, z których coś odczytujemy jak zmienić adres urządzenia ? Tzn. może inaczej, wiadmo, że są pewnie kombinacje 000 001 010 itd., ale chodzi mi o to, skąd kilka urządzeń na jednej magistrali ma wiedzieć, że np. adres "rzucony na sztywno" dajmy na to 10010011 należy do układu nr1 natomiast jakiś tam adres 10010101 należy do układu nr2. ? Nie mogę tego pojąć, skoro nie ustawiamy nic, to oba układy (wszystkie układy) na dzień dobry mają adres 1001101x (x zapis/odczyt) więc powstanie jedna wielka kaszanka, gdy żadne urządzenie nie będzie wiedziało jak odpowiedzieć...powstanie kolizja na magistrali, bo kilka urządzeń na raz będzie chciało wysyłać bit potwierdzenia. Czy może mi to ktoś wyjaśnić ?
Z góry dzięki i miłego dnia,
Pozdrawiam
