This documentation is out of date.

The new version of the documentation is here: https://cannylogic.com/docs

Difference between revisions of "CANNY 7, I²C Driver"

From CANNY Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Особенности работы драйвера I²C)
(Смотри также)
 
(2 intermediate revisions by 2 users not shown)
Line 239: Line 239:
 
After receiving data from the temperature sensor is performed pretreatment, then results of which are stored in the network named "sensor data".
 
After receiving data from the temperature sensor is performed pretreatment, then results of which are stored in the network named "sensor data".
  
=== Режим экономии энергии (режим пониженного энергопотребления) ===
+
== See also ==
 
+
Для экономии энергии спецификацией LIN предусмотрена возможность перехода всех узлов сети LIN в режим пониженного энегропотребления. Чаще всего, такой переход инициируется ведущим устройством путем отправки соответствующего сообщения в шину, либо осуществляется ведомыми устройствами самостоятельно, при отсутствии активности на шине в течение определенного интервала времени. Выход из режима сна может быть инициирован любым узлом шины. MASTER-узел инициирует пробуждение шины обычным началом опроса SLAVE-узлов. Пробуждение же по инициативе SLAVE-узла, осуществляется кратковременной установкой на линии потенциала GND.
+
 
+
В драйвере LIN контроллеров CANNY 7 для пробуждения шины MASTER-устройству достаточно начать передачу данных или запросов ведомым устройствам. SLAVE-узлы отправляют запрос на пробуждение шины передачей сообщения с любым идентификатором, но имеющим нулевую длину, т. е. «Регистр сообщения передачи LINх LEN» = 0.
+
 
+
== Смотри также ==
+
 
[[CANNY 7]]
 
[[CANNY 7]]
  
 
[[CANNY 7, Dallas 1-Wire Driver]]
 
[[CANNY 7, Dallas 1-Wire Driver]]

Latest revision as of 05:14, 21 March 2016

General Description

As communication lines (SDA and SCL) can be assigned to any pair of controller channels. In this case, the data channels must be pulled up to 5V with resistor of 1 k to 10 k outside of he controller. Particularity of I²C protocol implementation in CANNY7 controller is that CANNY7 can only act as a Master node. Data exchange between devices, which can be either mono- or bidirectional, occurs in separate sessions, the maximum message length I²C within one session is 16 bytes, ie opening of multiple sessions with different devices is not allowed. The rate of exchange is fixed at 100 kbit/s. The total number of slaves on the line can reach several tens.

I²C driver operates using the controller channel resources, but has a higher priority than a discrete input-output driver. Thus, upon activation I²C driver, for channels involved in to its operation, changing values in registers associated with digital input-output driver will be ignored by the controller.

I²C Driver Registers

The following are descriptions of valid register values for I²C driver control operation.

I²C Driver Configuration Registers.

Address Expected Values
I²C Address Setup register
2...254 = even number, slave-node address , which will have data exchange on the I²C bus.
I²C Enable Register
1...65535 = activate I²C driver , give it control of the controller channels, used as the SDA and SCL lines;
0 = deactivate I²C driver, return control of the channels to IO driver and allow to change their states from the functional diagram.
I²C SDA IO Channel Select Register
0...10 = set controller channel number to use as I²C driver data transmission line.
I²C SCL IO Channel Select Register
0...10 = set controller channel number to be used as I²C driver timing pulse transmission line.
Note: Individual controller channels must be assigned for SDA and SCL lines.

I²C driver diagnostic registers.

Address Return values
I²C Error Register
1 = an error occurred while sending or receiving I²C messages;
0 = the driver is operating normally.

I²C Receive Registers.

Address Return values
I²C Data Set Ready Register
1 = even number, slave-node address , which will have data exchange on the I²C bus;
0 = no relevant data present in I²C driver receive buffer.
I²C Received Length Register
0...16 = a value equal to the number of bytes that need to be received in I²C communication.
I²C Received Data Register D1:D0
...
I²C Received Data Register D15:D14
0...65535 = the values corresponding data bytes I²C receive buffer, two bytes per register.

I²C Transmit Registers.

Address Expected Values
I²C Request To Send Register
1 = load data from the transmit registers in to the transmit buffer / load data from the receive buffer in to I²C receive data registers;
0 = do not load data to the transmission buffer / do not read data from I²C receive data registers.
I²C Transmit Data Length Register
0...16 = the number of I²C message bytes that will be transmitted when receiving command to send data.
I²C Transmit Data Register D1:D0
...
I²C Transmit Data Register D15:D14
0...65535 = the value corresponding I²C message bytes for transmission, two bytes per register.


I²C Driver Operation Features

data exchange on I²C network using CANNY 7 controller is determined by the combination of transmitted and received message length register values set by user (see table).

I²C register value of transmitting message length I²C register value of receiving message length Data exchange direction
> 0 = 0 Only data transmission from CANNY7 (Master) to Slave node with the address specified in the relevant register.
> 0 > 0 data transmission from CANNY7 (Master) to Slave node with the address specified in the relevant register, and receiving response data from it.
= 0 > 0 Only data reception by CANNY7 (Master) from Slave node with the address specified in the relevant register.

Example functional diagram of the data receiving from TCN75 sensor. In operation, the controller acts as I²C bus Master node, carrying the temperature sensor interrogation 2 times per second.

6 11 3 1.png

In this example CANNY7 (Master) acts as a receiver, requesting data and temperature sensor (Slave) - as a transmitter. This data transmission direction given by the entry in I²C transmitting message length registers(I²C Transmit Data Length Register) and the length of I²C receiving message (I²C Received Data Length Register) values other than "0", corresponding to the number of transmitting (temperature request) and receiving (temperature value) data.

To connect controller to the thermal sensor, channels #8 (SCL) and #9 (SDA) used. Every 500ms transmitting a request for temperature value to the slave node with address 0x90. In response is expected to receive two data bytes.

After receiving data from the temperature sensor is performed pretreatment, then results of which are stored in the network named "sensor data".

See also

CANNY 7

CANNY 7, Dallas 1-Wire Driver