This documentation is out of date.

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

Difference between revisions of "CANNY 7, LIN Driver"

From CANNY Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Created page with "=== Общее описание === Два из одиннадцати каналов ввода-вывода CANNY 7, которые могут быть переданы п...")
 
(Driver registers)
 
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
=== Общее описание ===
+
=== General description ===
  
 +
Two of eleven input-output channels of CANNY 7, which can be placed under control of UART/RS-232 driver (Channel №9 and №10), can be used to organize data reception and transmission as two independent '''[https://en.wikipedia.org/wiki/Local_Interconnect_Network LIN]''' driver channels.
  
Два из одиннадцати каналов ввода-вывода CANNY 7, которые могут быть переданы под управление драйвера UART/RS-232 (Канал №9 и Канал №10), могут быть использованы для организации приема-передачи данных как два независимых канала драйвера '''[https://en.wikipedia.org/wiki/Local_Interconnect_Network LIN]'''.
+
LIN driver channels can be connect both together and individually, have individual baud rate settings , pull-up line and bus node type- MASTER or SLAVE.
  
Каналы драйвера LIN могут подключаться как вместе так и по отдельности, иметь индивидуальные настройки скорости передачи данных, подтяжки линии и типа узла сети MASTER или SLAVE.
+
LIN driver in its operation uses the resources of controller channels, but has a higher priority than  discrete input-output driver. Thus, upon LIN driver activation, for the involved channels in its operation, changing values in registers associated controllers' discrete input-output driver will be ignored.
  
Драйвер LIN в своей работе использует ресурсы каналов контроллера, но имеет более высокий приоритет чем драйвер дискретного ввода-вывода. Таким образом, при активации драйвера LIN, для задействованных в его работе каналов, изменение значений в связанных с ними регистрах драйвера дискретного ввода-вывода будет проигнорировано контроллером.
+
=== Driver registers ===
  
=== Регистры драйвера ===
+
The following describes the acceptable LIN driver operation control registers values.
  
Ниже приведено описание допустимых значений регистров управления работой драйвера LIN.
+
LIN driver configuration Registers allows to set up the controller as a LIN bus node:
 
+
Регистры конфигурации драйвера LIN.
+
Регистры конфигурации драйвера CAN позволяют установить параметры работы контроллера в качестве узла шины CAN:
+
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
|- align="center" valign="top"
 
|- align="center" valign="top"
!width="250px"|Адрес
+
!width="250px"|Address
!Ожидаемые значения
+
!Expected values
 
|- valign="top"
 
|- valign="top"
 
|
 
|
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр конфигурации LIN1
+
|style="padding-left:0.5em;"|LIN1 Mode Setup Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр конфигурации LIN2
+
|style="padding-left:0.5em;"|LIN2 Mode Setup Register
 
|}
 
|}
 
|valign="top"|
 
|valign="top"|
Line 31: Line 29:
 
|width="70px" style="padding-left:0.5em;"|1...65535
 
|width="70px" style="padding-left:0.5em;"|1...65535
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|установить конфигурацию канала драйвера LIN контроллера, определяющую текущий режим и параметры его работы (задается специальной константой из справочника констант);
+
|style="padding-left:0.5em;"|setup a LIN driver channel configuration, determines the current operation mode and parameters (determined by special constant from the constants directory);
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|отключить канал от драйвера LIN, вернуть управление каналом драйверу каналов ввода-вывода и разрешить изменения его состояния из функциональной диаграммы.
+
|style="padding-left:0.5em;"|disconnect the channel from the LIN driver, return channel control to  input-output channels driver and allow its status changes from the functional diagram.
 
|}
 
|}
 
|}
 
|}
  
Конфигурация канала для работы в данном режиме, определяется константой, представляющей собой комбинацию параметров: версии протокола, скорости передачи данных, режима работы и наличия внутренней «подтяжки» контакта контроллера.
+
Channel configuration for operation in this mode is determined by a constant, which is a combination of parameters: protocol version , baud rate, operation mode and the availability of internal channel pull-up.
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
|- align="center" valign="top"
 
|- align="center" valign="top"
!width="250px"|Параметр
+
!width="250px"|Parameter
!Перечень допустимых значений
+
!The list of acceptable values
 
|- valign="top"
 
|- valign="top"
|Версия протокола LIN
+
|LIN protocol version
 
|1.3; 2.0
 
|1.3; 2.0
 
|- valign="top"
 
|- valign="top"
|Скорость передачи данных, бод
+
|baud rate
 
|2400; 9600; 19200
 
|2400; 9600; 19200
 
|- valign="top"
 
|- valign="top"
|Режим работы
+
|Operation mode
 
|MASTER; SLAVE
 
|MASTER; SLAVE
 
|- valign="top"
 
|- valign="top"
|Подтяжка
+
|Pull-up
|[[плюс]]; [[воздух]]
+
|[[plus]]; [[float]]
 
|}
 
|}
  
Именованные константы, представляющие доступные пользователю комбинации параметров конфигурации LIN, содержатся в разделе «Конфигурация LIN» справочника констант CannyLab, доступ к которому осуществляется через контекстное меню входа функционального блока, имеющего тип «Константа».
+
Named constants that represent LIN configuration parameters combination, available to the user in the "LIN Modes" CannyLab constants directory, which can be accessed via function block entry context menu having "constant" type.
  
Регистры диагностики драйвера LIN.
+
LIN driver diagnostic registers.
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
|- align="center" valign="top"
 
|- align="center" valign="top"
!width="250px"|Адрес
+
!width="250px"|Address
!Возвращаемые значения
+
!Return Values
 
|- valign="top"
 
|- valign="top"
 
|
 
|
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр переполнения буфера LIN1
+
|style="padding-left:0.5em;"|LIN1 Overflow Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр переполнения буфера LIN2
+
|style="padding-left:0.5em;"|LIN2 Overflow Register
 
|}
 
|}
 
|valign="top"|
 
|valign="top"|
Line 78: Line 76:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|буфер соответствующего канала драйвера LIN переполнен;
+
|style="padding-left:0.5em;"|corresponding channel LIN buffer is full;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|переполнения соответствующего канала драйвера LIN не зафиксировано.
+
|style="padding-left:0.5em;"|corresponding channel LIN no buffer overflow detected.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 88: Line 86:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр ошибки приема LIN1
+
|style="padding-left:0.5em;"|LIN1 Error Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр ошибки приема LIN2
+
|style="padding-left:0.5em;"|LIN2 Error Register
 
|}
 
|}
 
|
 
|
Line 97: Line 95:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|во время приема сообщения по соответствующему каналу драйвера LIN произошла ошибка;
+
|style="padding-left:0.5em;"|during LIN data reception an error occurred;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|драйвер работает в нормальном режиме.
+
|style="padding-left:0.5em;"|the driver is operating normally.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 107: Line 105:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр готовности буфера передачи данных LIN1
+
|style="padding-left:0.5em;"|LIN1 Ready to Send Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр готовности буфера передачи данных LIN2
+
|style="padding-left:0.5em;"|LIN2 Ready to Send Register
 
|}
 
|}
 
|
 
|
Line 116: Line 114:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|буфер передачи данных соответствующего канала драйвера LIN свободен и готов к работе;
+
|style="padding-left:0.5em;"|corresponding channel LIN data transmit buffer is free and ready;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|буфер передачи данных драйвера LIN занят.
+
|style="padding-left:0.5em;"|LIN driver data transmission buffer is busy.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 126: Line 124:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр успешной отправки данных драйвера LIN1
+
|style="padding-left:0.5em;"|LIN1 Data Delivered Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр успешной отправки данных драйвера LIN2
+
|style="padding-left:0.5em;"|LIN2 Data Delivered Register
 
|}
 
|}
 
|
 
|
Line 135: Line 133:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|при работе в режиме SLAVE, признак успешной отправки данных из буфера передачи соответствующего канала драйвера LIN в ответ на запрос MASTER-узла;
+
|style="padding-left:0.5em;"|in SLAVE mode, successful data transfer indication from the buffer of corresponding channel LIN, in response to MASTER node request;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|при работе соответствующего канала драйвера LIN в режиме SLAVE, запроса от MASTER-узла не поступало.
+
|style="padding-left:0.5em;"|when the corresponding LIN channel is in a SLAVE mode, there were no MASTER node request received.
 
|}
 
|}
 
|}
 
|}
  
Регистры приема драйвера LIN.
+
LIN Receive Registers.
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
|- align="center" valign="top"
 
|- align="center" valign="top"
!width="250px"|Адрес
+
!width="250px"|Address
!Возвращаемые значения
+
!Return Values
 
|- valign="top"
 
|- valign="top"
 
|
 
|
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр наличия принятых данных LIN1
+
|style="padding-left:0.5em;"|LIN1 Data Set Ready Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр наличия принятых данных LIN2
+
|style="padding-left:0.5em;"|LIN2 Data Set Ready Register
 
|}
 
|}
 
|valign="top"|
 
|valign="top"|
Line 161: Line 159:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|сообщение успешно получено и доступно в регистрах буфера приема соответствующего канала драйвера LIN;
+
|style="padding-left:0.5em;"|the message is received and placed into corresponding LIN channel receive buffer;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|в буфере приема соответствующего канала драйвера LIN отсутствуют актуальные данные.
+
|style="padding-left:0.5em;"|in the corresponding LIN channel receive buffer no actual data present.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 171: Line 169:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр отсутствия активности драйвера LIN1
+
|style="padding-left:0.5em;"|LIN1 Idle Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр отсутствия активности драйвера LIN2
+
|style="padding-left:0.5em;"|LIN2 Idle Register
 
|}
 
|}
 
|
 
|
Line 180: Line 178:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|активность соответствующего канала драйвера LIN отсутствует, линия находится в пассивном режиме;
+
|style="padding-left:0.5em;"|no activity on the corresponding channel LIN drivers, the line is in a passive mode;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|зафиксирована активность на линии соответствующего канала драйвера LIN.
+
|style="padding-left:0.5em;"|fixed activity on the line of corresponding LIN driver channel.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 190: Line 188:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN1 LEN
+
|style="padding-left:0.5em;"|LIN1 Received Data Register LEN
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN2 LEN
+
|style="padding-left:0.5em;"|LIN2 Received Data Register LEN
 
|}
 
|}
 
|
 
|
Line 199: Line 197:
 
|width="70px" style="padding-left:0.5em;"|0...8
 
|width="70px" style="padding-left:0.5em;"|0...8
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|значение, равное количеству байт данных в пакете, принятом по соответствующему каналу драйвера LIN.
+
|style="padding-left:0.5em;"|a value, equal to the number of data bytes in the packet received via respective LIN channel.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 205: Line 203:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN1 ID
+
|style="padding-left:0.5em;"|LIN1 Received Data Register ID
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN2 ID
+
|style="padding-left:0.5em;"|LIN2 Received Data Register ID
 
|}
 
|}
 
|
 
|
Line 214: Line 212:
 
|width="70px" style="padding-left:0.5em;"|0...63
 
|width="70px" style="padding-left:0.5em;"|0...63
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|значение идентификатора полученного по соответствующему каналу драйвера LIN сообщения. (см. примечание)
+
|style="padding-left:0.5em;"|message ID, obtained via respective channel LIN . (See note.)
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 220: Line 218:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN1 b1:b0
+
|style="padding-left:0.5em;"|LIN1 Received Data Register b1:b0
 
|- valign="top"
 
|- valign="top"
 
|style="padding-left:0.5em;"|...
 
|style="padding-left:0.5em;"|...
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN1 b7:b6
+
|style="padding-left:0.5em;"|LIN1 Received Data Register b7:b6
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN2 b1:b0
+
|style="padding-left:0.5em;"|LIN2 Received Data Register b1:b0
 
|- valign="top"
 
|- valign="top"
 
|style="padding-left:0.5em;"|...
 
|style="padding-left:0.5em;"|...
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр принятого сообщения LIN2 b7:b6
+
|style="padding-left:0.5em;"|LIN2 Received Data Register b7:b6
 
|}
 
|}
 
|
 
|
Line 237: Line 235:
 
|width="70px" style="padding-left:0.5em;"|0...65535
 
|width="70px" style="padding-left:0.5em;"|0...65535
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|значения соответствующих байт данных приемных буферов LIN каждого канала, по два байта на регистр.
+
|style="padding-left:0.5em;"|respective data byte values, LIN reception buffers of each channel by two bytes to the register.
 
|}
 
|}
 
|}
 
|}
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''В регистре идентификатора принятого сообщения LIN отображаются только младшие 6 бит идентификатора: 4 бита адреса устройства и 2 два бита использовавшихся в LIN версии 1.1 для кодирования длины сообщения, а в более поздних версиях расширяющие адрес. 10 старших бит регистра идентификатора принятого сообщения LIN всегда равны нулю.''
+
|valign="top" style="padding-left:0.5em;"|''LIN Received Data Register ID displays only the lower 6 bits of the identifier: 4-bit address of the device and the 2- bits used in the LIN 1.1 to encode the message length, and later to expand the address. 10 higher bits of LIN received message ID register always zero.''
 
|}
 
|}
  
Регистры передачи драйвера LIN.
+
LIN transmit registers.
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
{|border="1" style="border-collapse:collapse;" align="left" width="100%"
 
|- align="center" valign="top"
 
|- align="center" valign="top"
!width="250px"|Адрес
+
!width="250px"|Address
!Ожидаемые значения
+
!Expected Values
 
|- valign="top"
 
|- valign="top"
 
|
 
|
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр начала передачи LIN1
+
|style="padding-left:0.5em;"|LIN1 Request to Send Register
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр начала передачи LIN2
+
|style="padding-left:0.5em;"|LIN2 Request to Send Register
 
|}
 
|}
 
|valign="top"|
 
|valign="top"|
Line 264: Line 262:
 
|width="70px" style="padding-left:0.5em;"|1
 
|width="70px" style="padding-left:0.5em;"|1
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|загрузить данные из регистров передачи в буфер передачи соответствующего канала драйвера LIN;
+
|style="padding-left:0.5em;"|to load data from the transfer registers in the respective channel LIN transmit buffer;
 
|- valign="top"
 
|- valign="top"
 
|width="70px" style="padding-left:0.5em;"|0
 
|width="70px" style="padding-left:0.5em;"|0
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|не загружать данные в буфер передачи соответствующего канала драйвера LIN.
+
|style="padding-left:0.5em;"|do not load data to the respective channel LIN transmit buffer.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 274: Line 272:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN1 LEN
+
|style="padding-left:0.5em;"|LIN1 Transmit Data Register LEN
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN2 LEN
+
|style="padding-left:0.5em;"|LIN2 Transmit Data Register LEN
 
|}
 
|}
 
|
 
|
Line 283: Line 281:
 
|width="70px" style="padding-left:0.5em;"|0...8
 
|width="70px" style="padding-left:0.5em;"|0...8
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"количество байт данных, которое будет необходимо передать в линию, при получении команды на отправку соответствующего канала драйвера LIN.
+
|style="padding-left:0.5em;|"the number of data bytes that will be transmitted to the line when receiving a command to send on the corresponding LIN channel.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 289: Line 287:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN1 ID
+
|style="padding-left:0.5em;"|LIN1 Transmit Data Register ID
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN2 ID
+
|style="padding-left:0.5em;"|LIN2 Transmit Data Register ID
 
|}
 
|}
 
|
 
|
Line 298: Line 296:
 
|width="70px" style="padding-left:0.5em;"|0...63
 
|width="70px" style="padding-left:0.5em;"|0...63
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|значение идентификатора LIN-сообщения для передачи по соответствующему каналу драйвера LIN.
+
|style="padding-left:0.5em;"|LIN ID value for message transmission via respective LIN channel.
 
|}
 
|}
 
|- valign="top"
 
|- valign="top"
Line 304: Line 302:
 
{|border="0" align="left"
 
{|border="0" align="left"
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN1 b1:b0
+
|style="padding-left:0.5em;"|LIN1 Transmit Data Register b1:b0
 
|- valign="top"
 
|- valign="top"
 
|style="padding-left:0.5em;"|...
 
|style="padding-left:0.5em;"|...
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN1 b7:b6
+
|style="padding-left:0.5em;"|LIN1 Transmit Data Register b7:b6
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN2 b1:b0
+
|style="padding-left:0.5em;"|LIN2 Transmit Data Register b1:b0
 
|- valign="top"
 
|- valign="top"
 
|style="padding-left:0.5em;"|...
 
|style="padding-left:0.5em;"|...
 
|- valign="top"
 
|- valign="top"
|style="padding-left:0.5em;"|Регистр сообщения передачи LIN2 b7:b6
+
|style="padding-left:0.5em;"|LIN2 Transmit Data Register b7:b6
 
|}
 
|}
 
|
 
|
Line 321: Line 319:
 
|width="70px" style="padding-left:0.5em;"|0...65535
 
|width="70px" style="padding-left:0.5em;"|0...65535
 
|style="padding-left:0.5em;"|=
 
|style="padding-left:0.5em;"|=
|style="padding-left:0.5em;"|значения соответствующих байт данных для передачи по соответствующему каналу драйвера LIN, по два байта на регистр.
+
|style="padding-left:0.5em;"|data byte values to transmit on respective LIN channel by two bytes to the register.
 
|}
 
|}
 
|}
 
|}
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''При передаче LIN-сообщения, драйвер отбрасывает все кроме младших 6 бит значения установленного в регистре идентификатора LIN-сообщения, автоматически генерирует два бита четности и дополняет ими идентификатор, в соответствие с требованиями стандарта.''
+
|valign="top" style="padding-left:0.5em;"|''When sending LIN-messages, the driver discards all but the lower 6 bits of LIN ID register, automatically generates two parity bits and complements them ID, according to requirements of the standard.''
 
|}
 
|}
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''При работе в сетях LIN версии ниже 1.3, будьте внимательны при формировании исходящих сообщений. Драйвер позволяет использовать комбинации значений длины и идентификатора передаваемого сообщения недопустимые в этом стандарте.''
+
|valign="top" style="padding-left:0.5em;"|''When working with LIN networks versions below 1.3, be careful in the formation of outgoing messages. The driver allows the use of combinations of length and identifier transmitting message unacceptable in this standard.''
 
|}
 
|}
  
=== Работа контроллера в режиме MASTER ===
+
=== Canny7 in MASTER mode ===
  
Для перевода канала драйвера LIN в режим MASTER, необходимо в соответствующий каналу драйвера адрес «Регистр конфигурации LINx» скопировать значение константы, соответствующей выбранному режиму работы.
+
To switch LIN driver channel in to MASTER mode, it is necessary to copy the constant value corresponding to the selected mode in to appropriate driver channel  address: "LINx mode setup register».
  
Для получения MASTERом данных от SLAVE-узла, необходимо передать в шину LIN соответствующий запрос: отправить заголовок сообщения, содержащий идентификатор ведомого узла, от которого запрашиваются данные. Длина сообщения передачи LIN LEN должна быть установлена равной нулю, в регистр старта передачи должно быть записано ненулевое значение. При получении ответа от ведомого устройства, он будет помещен в Регистры принятого сообщения соответствующего канала драйвера LIN с одновременной установкой признака в Регистре наличия принятых данных LIN этого канала.
+
For MASTER to receive data from SLAVE-node, need to send corresponding request to LIN bus: Send the message header contains the identifier of the slave node from which the data is requested. The length of transmission message  LEN LEN must be set to zero, in to transmission start register to be recorded non-zero value. Upon receipt of response from the slave, the data will be placed in receive register of the  corresponding LIN driver channel with simultaneous setting mark in LINx Data Set Ready Register data availability.
  
Пример функциональной диаграммы для получения MASTERом данных от SLAVE-устройства. MASTER каждые 100мс отправляет в шину запрос на получение данных от ведомого устройства с идентификатором 0х02. Получив ответ, контроллер запоминает 2 первых байта данных, в D-триггере.
+
An example of a functional diagram for MASTER data reception from SLAVE-node. MASTER every 100ms sends the data request from the slave with the identifier 0x02. After receiving a response, the controller stores the first 2 bytes of data in the D-flip-flop.
  
 
[[File:6_10_4_1.png|center|950px]]
 
[[File:6_10_4_1.png|center|950px]]
  
Для передачи данных в режиме MASTER необходимо заполнить регистры идентификатора, и данных передаваемого сообщения LIN, установив при этом в Регистре передаваемого сообщения LIN LEN, значение равное количеству байт данных передаваемого сообщения, которое должно быть больше нуля но меньше девяти. Команда драйверу на отправку сообщения посылается путем установки ненулевого значения в «Регистр начала передачи сообщения LINх», в результате чего, содержимое регистров данных копируется в буфер передачи LIN-сообщения, если он свободен, драйвер немедленно приступит к отправке сообщения.
+
For data transmission in MASTER mode, the ID and Data registers must be filled, while setting transmission LIN LEN Register, a value equal to the number of transmitting data bytes, which must be greater than zero but less than nine. Instruction for LIN driver to send messages obtained by setting a non-zero value in the "LINx Request To Send Register". As a result, the contents of the registers is copied into the transmit buffer LIN, if it is free, the driver will immediately proceed to send a message.
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''С целью предотвращения потери данных, перед отправкой нового сообщения LIN рекомендуется убедиться в готовности буфера передачи соответствующего канала драйвера LIN к передаче очередного сообщения, проверив значение в Регистре готовности буфера передачи данных LINx.''
+
|valign="top" style="padding-left:0.5em;"|''To prevent data loss, before sending a new LIN message, it is recommended to ensure readiness to the transfer of the next message from corresponding LIN channel transmit buffer, by checking the LINx Ready To Send Register.''
 
|}
 
|}
  
Пример функциональной диаграммы отправки данных в шину LIN ведущим устройством. MASTER каждые 100мс отправляет в шину сообщение с идентификатором 0х01, содержащее 2 байта данных (0х0А и 0х55).
+
Example of functional diagram, sending data to the LIN bus by MASTER.
 +
MASTER every 100ms sends a message to the bus with the identifier 0x01 that contains 2 bytes of data (0h0A and 0x55).
  
 
[[File:6_10_4_2.png|center|800px]]
 
[[File:6_10_4_2.png|center|800px]]
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''Если в регистре начала передачи сообщения LINх постоянно установлено ненулевое значение, то попытки копирования данных в буфер передачи для отправки сообщения LIN будут предприниматься на каждом цикле выполнения диаграммы. Во избежание переполнения буфера передачи LIN инициируйте начало передачи данных единичными импульсами, используя, например, функциональные блоки детекторов фронта.''
+
|valign="top" style="padding-left:0.5em;"|''If LINx Request To Send Register permanently set a non-zero value, then the attempt to copy the data to the transmission buffer for sending LIN messages will be taken at each diagram execution cycle. To avoid overflow of LIN transmission buffer, triggers the start of data transmission by single pulse using, for example, front detector functional blocks.''
 
|}
 
|}
  
=== Работа контроллера в режиме SLAVE ===
+
=== Canny7 in SLAVE mode ===
  
Работая в режиме SLAVE, узел сети LIN успешно принимает любые данные передаваемые по сети, но не может сам передавать данные в LIN, не получив на то соответствующего запроса от MASTER.
+
Operating SLAVE mode, LIN node successfully receives any data transmitted over the network, but can not transmit data to the LIN itself, without not having received the request from MASTER.
  
Для перевода канала контроллера в режим SLAVE, необходимо в соответствующий каналу адрес «Регистр конфигурации LINx» скопировать значение константы, соответствующей выбранному режиму работы.
+
To switch LIN driver channel in to SLAVE mode, it is necessary to copy the constant value corresponding to the selected mode in to appropriate driver channel address: "LINx mode setup register».
  
Для обеспечения успешной отправки данных узлом находящемся в режиме SLAVE по запросу MASTER-узла, необходимо заранее, не дожидаясь запроса, подготовить данные к передаче. Для этого необходимо заполнить все необходимые регистры сообщения передачи драйвера LIN, а именно: регистр идентификатора LIN ID, регистр длины сообщения LIN LEN и разместить передаваемую информацию в регистрах данных LIN. Разрешение на отправку сообщения дается путем установки значения «1» в «Регистр начала передачи сообщения LINх», в результате чего содержимое регистров данных копируется в буфер передачи LIN-сообщения, если он свободен. Отправка однажды помещенных в буфер передачи данных будет выполняться драйвером автоматически, при каждом получении запроса от MASTERа.
+
To ensure successful data sending for node in SLAVE mode on MASTER-node request ,It must advance without waiting for a request, to prepare the data for transmission. This requires to fill in all the necessary LINx Transmit Data Register, namely: LIN ID register, message length register LIN LEN and place sending information in LIN data register.
 +
Permission to send is given by setting a value "1" to "LINx Request To Send Register", whereby the contents of data registers is copied into LIN transmit buffer, if it is free. Sending of data, once placed in the buffer will be automatically performing by LIN driver, with each request from the MASTER.
  
 
{|
 
{|
|valign="top" style="padding-left:0.5em;"|''Примечание:''
+
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''Если в регистре начала передачи сообщения LINх постоянно установлено ненулевое значение, то попытки копирования данных в буфер передачи для отправки сообщения LIN будут предприниматься на каждом цикле выполнения диаграммы. Во избежание переполнения буфера передачи LIN инициируйте начало передачи данных единичным импульсом, используя, например, функциональные блоки детекторов фронта.''
+
|valign="top" style="padding-left:0.5em;"|''If LINx Request To Send Register permanently set a non-zero value, then the attempt to copy the data to the transmission buffer for sending LIN messages will be taken at each diagram execution cycle. To avoid overflow of LIN transmission buffer, triggers the start of data transmission by single pulse using, for example, front detector functional blocks.''
 
|}
 
|}
  
Контролировать поступление запроса от MASTER и успешную отправку автоматического ответа на него драйвером узла находящегося в режиме SLAVE можно по появлению значения «1» в Регистре успешной отправки данных драйвера LINx. Обновлять данные находящиеся в буфере передачи возможно после его освобождения. Состояние буфера передачи можно отслеживать по значению соответствующего регистра драйвера.
+
Monitor a request reception from the MASTER and successful automatic response to it by LIN driver in SLAVE mode possible by the appearance of the value "1" in LINx Data Delivered Register. Update data in the buffer transmission is possible after its release. Status of the send buffer can be tracked by the value of the corresponding register.
  
Пример функциональной диаграммы передачи данных LIN узлом в режиме SLAVE.
+
An example of a functional diagram for data transmission by LIN node in SLAVE mode.
  
 
[[File:6_10_5_1.png|center|600px]]
 
[[File:6_10_5_1.png|center|600px]]
  
Пример функциональной диаграммы получения SLAVEом данных от ведущего устройства. Получая сообщение с идентификатором 0х01, содержащее какие-либо данные, контроллер сохраняет первые два байта данных сообщения в D-триггере.
+
An example of a functional diagram SLAVE receiving data from the MASTER. Controller, receiving message with the identifier 0x01 that contains any data, stores the first two bytes of data message in the D-flip-flop.
  
 
[[File:6_10_5_2.png|center]]
 
[[File:6_10_5_2.png|center]]
  
 +
=== Energy saving mode (low power consumption mode) ===
 +
 +
To save energy, LIN specification provides the ability to switch all LIN network nodes in low energy consumption mode. Most often, such a transition is initiated by master node by sending an appropriate message to the bus,or slave nodes switch by their own, when there is no activity on the bus for a specified time interval. Exit sleep mode can be initiated by any node on the bus. MASTER-node initiates LIN bus awakening by normal query slaves. However, waking up initiated by SLAVE-node is carried by short installation of GND potential on the line.
 +
 +
In the LIN driver of controller Canny 7, to wake the BUS, MASTER-node just need to start transmitting data or query slaves. SLAVE-nodes sends a request to awake the BUS by  passing a message with any identifier, but have zero length, i.e. "LINx Transmit Data Register LEN» = 0.
  
== Смотри также ==
+
== See also ==
 
[[CANNY 7]]
 
[[CANNY 7]]
  
[[UART Driver|UART / RS232 / Modbus]]
+
[[CANNY 7, UART Driver]]
  
[[CAN Driver|CAN Interface]]
+
[[CANNY 7, CAN Driver]]

Latest revision as of 00:49, 20 September 2020

General description

Two of eleven input-output channels of CANNY 7, which can be placed under control of UART/RS-232 driver (Channel №9 and №10), can be used to organize data reception and transmission as two independent LIN driver channels.

LIN driver channels can be connect both together and individually, have individual baud rate settings , pull-up line and bus node type- MASTER or SLAVE.

LIN driver in its operation uses the resources of controller channels, but has a higher priority than discrete input-output driver. Thus, upon LIN driver activation, for the involved channels in its operation, changing values in registers associated controllers' discrete input-output driver will be ignored.

Driver registers

The following describes the acceptable LIN driver operation control registers values.

LIN driver configuration Registers allows to set up the controller as a LIN bus node:

Address Expected values
LIN1 Mode Setup Register
LIN2 Mode Setup Register
1...65535 = setup a LIN driver channel configuration, determines the current operation mode and parameters (determined by special constant from the constants directory);
0 = disconnect the channel from the LIN driver, return channel control to input-output channels driver and allow its status changes from the functional diagram.

Channel configuration for operation in this mode is determined by a constant, which is a combination of parameters: protocol version , baud rate, operation mode and the availability of internal channel pull-up.

Parameter The list of acceptable values
LIN protocol version 1.3; 2.0
baud rate 2400; 9600; 19200
Operation mode MASTER; SLAVE
Pull-up plus; float

Named constants that represent LIN configuration parameters combination, available to the user in the "LIN Modes" CannyLab constants directory, which can be accessed via function block entry context menu having "constant" type.

LIN driver diagnostic registers.

Address Return Values
LIN1 Overflow Register
LIN2 Overflow Register
1 = corresponding channel LIN buffer is full;
0 = corresponding channel LIN no buffer overflow detected.
LIN1 Error Register
LIN2 Error Register
1 = during LIN data reception an error occurred;
0 = the driver is operating normally.
LIN1 Ready to Send Register
LIN2 Ready to Send Register
1 = corresponding channel LIN data transmit buffer is free and ready;
0 = LIN driver data transmission buffer is busy.
LIN1 Data Delivered Register
LIN2 Data Delivered Register
1 = in SLAVE mode, successful data transfer indication from the buffer of corresponding channel LIN, in response to MASTER node request;
0 = when the corresponding LIN channel is in a SLAVE mode, there were no MASTER node request received.

LIN Receive Registers.

Address Return Values
LIN1 Data Set Ready Register
LIN2 Data Set Ready Register
1 = the message is received and placed into corresponding LIN channel receive buffer;
0 = in the corresponding LIN channel receive buffer no actual data present.
LIN1 Idle Register
LIN2 Idle Register
1 = no activity on the corresponding channel LIN drivers, the line is in a passive mode;
0 = fixed activity on the line of corresponding LIN driver channel.
LIN1 Received Data Register LEN
LIN2 Received Data Register LEN
0...8 = a value, equal to the number of data bytes in the packet received via respective LIN channel.
LIN1 Received Data Register ID
LIN2 Received Data Register ID
0...63 = message ID, obtained via respective channel LIN . (See note.)
LIN1 Received Data Register b1:b0
...
LIN1 Received Data Register b7:b6
LIN2 Received Data Register b1:b0
...
LIN2 Received Data Register b7:b6
0...65535 = respective data byte values, LIN reception buffers of each channel by two bytes to the register.
Note: LIN Received Data Register ID displays only the lower 6 bits of the identifier: 4-bit address of the device and the 2- bits used in the LIN 1.1 to encode the message length, and later to expand the address. 10 higher bits of LIN received message ID register always zero.

LIN transmit registers.

Address Expected Values
LIN1 Request to Send Register
LIN2 Request to Send Register
1 = to load data from the transfer registers in the respective channel LIN transmit buffer;
0 = do not load data to the respective channel LIN transmit buffer.
LIN1 Transmit Data Register LEN
LIN2 Transmit Data Register LEN
0...8 = "the number of data bytes that will be transmitted to the line when receiving a command to send on the corresponding LIN channel.
LIN1 Transmit Data Register ID
LIN2 Transmit Data Register ID
0...63 = LIN ID value for message transmission via respective LIN channel.
LIN1 Transmit Data Register b1:b0
...
LIN1 Transmit Data Register b7:b6
LIN2 Transmit Data Register b1:b0
...
LIN2 Transmit Data Register b7:b6
0...65535 = data byte values to transmit on respective LIN channel by two bytes to the register.
Note: When sending LIN-messages, the driver discards all but the lower 6 bits of LIN ID register, automatically generates two parity bits and complements them ID, according to requirements of the standard.
Note: When working with LIN networks versions below 1.3, be careful in the formation of outgoing messages. The driver allows the use of combinations of length and identifier transmitting message unacceptable in this standard.

Canny7 in MASTER mode

To switch LIN driver channel in to MASTER mode, it is necessary to copy the constant value corresponding to the selected mode in to appropriate driver channel address: "LINx mode setup register».

For MASTER to receive data from SLAVE-node, need to send corresponding request to LIN bus: Send the message header contains the identifier of the slave node from which the data is requested. The length of transmission message LEN LEN must be set to zero, in to transmission start register to be recorded non-zero value. Upon receipt of response from the slave, the data will be placed in receive register of the corresponding LIN driver channel with simultaneous setting mark in LINx Data Set Ready Register data availability.

An example of a functional diagram for MASTER data reception from SLAVE-node. MASTER every 100ms sends the data request from the slave with the identifier 0x02. After receiving a response, the controller stores the first 2 bytes of data in the D-flip-flop.

6 10 4 1.png

For data transmission in MASTER mode, the ID and Data registers must be filled, while setting transmission LIN LEN Register, a value equal to the number of transmitting data bytes, which must be greater than zero but less than nine. Instruction for LIN driver to send messages obtained by setting a non-zero value in the "LINx Request To Send Register". As a result, the contents of the registers is copied into the transmit buffer LIN, if it is free, the driver will immediately proceed to send a message.

Note: To prevent data loss, before sending a new LIN message, it is recommended to ensure readiness to the transfer of the next message from corresponding LIN channel transmit buffer, by checking the LINx Ready To Send Register.

Example of functional diagram, sending data to the LIN bus by MASTER. MASTER every 100ms sends a message to the bus with the identifier 0x01 that contains 2 bytes of data (0h0A and 0x55).

6 10 4 2.png
Note: If LINx Request To Send Register permanently set a non-zero value, then the attempt to copy the data to the transmission buffer for sending LIN messages will be taken at each diagram execution cycle. To avoid overflow of LIN transmission buffer, triggers the start of data transmission by single pulse using, for example, front detector functional blocks.

Canny7 in SLAVE mode

Operating SLAVE mode, LIN node successfully receives any data transmitted over the network, but can not transmit data to the LIN itself, without not having received the request from MASTER.

To switch LIN driver channel in to SLAVE mode, it is necessary to copy the constant value corresponding to the selected mode in to appropriate driver channel address: "LINx mode setup register».

To ensure successful data sending for node in SLAVE mode on MASTER-node request ,It must advance without waiting for a request, to prepare the data for transmission. This requires to fill in all the necessary LINx Transmit Data Register, namely: LIN ID register, message length register LIN LEN and place sending information in LIN data register. Permission to send is given by setting a value "1" to "LINx Request To Send Register", whereby the contents of data registers is copied into LIN transmit buffer, if it is free. Sending of data, once placed in the buffer will be automatically performing by LIN driver, with each request from the MASTER.

Note: If LINx Request To Send Register permanently set a non-zero value, then the attempt to copy the data to the transmission buffer for sending LIN messages will be taken at each diagram execution cycle. To avoid overflow of LIN transmission buffer, triggers the start of data transmission by single pulse using, for example, front detector functional blocks.

Monitor a request reception from the MASTER and successful automatic response to it by LIN driver in SLAVE mode possible by the appearance of the value "1" in LINx Data Delivered Register. Update data in the buffer transmission is possible after its release. Status of the send buffer can be tracked by the value of the corresponding register.

An example of a functional diagram for data transmission by LIN node in SLAVE mode.

6 10 5 1.png

An example of a functional diagram SLAVE receiving data from the MASTER. Controller, receiving message with the identifier 0x01 that contains any data, stores the first two bytes of data message in the D-flip-flop.

6 10 5 2.png

Energy saving mode (low power consumption mode)

To save energy, LIN specification provides the ability to switch all LIN network nodes in low energy consumption mode. Most often, such a transition is initiated by master node by sending an appropriate message to the bus,or slave nodes switch by their own, when there is no activity on the bus for a specified time interval. Exit sleep mode can be initiated by any node on the bus. MASTER-node initiates LIN bus awakening by normal query slaves. However, waking up initiated by SLAVE-node is carried by short installation of GND potential on the line.

In the LIN driver of controller Canny 7, to wake the BUS, MASTER-node just need to start transmitting data or query slaves. SLAVE-nodes sends a request to awake the BUS by passing a message with any identifier, but have zero length, i.e. "LINx Transmit Data Register LEN» = 0.

See also

CANNY 7

CANNY 7, UART Driver

CANNY 7, CAN Driver