CANNY 7, System Registers

From CANNY Wiki
Jump to: navigation, search

General description[edit]

System resources are divided into an address group of read registers and an address group of write registers. Referring to the given registers from the functional diagram, you can get demanding information for practical application about the current status of the controller, and control its operational mode. The set of system registers located in the "System Registers" directory of CannyLab IDE registers list are accessible via "Input Register" and "Output Register" context menu.

Reset controller[edit]

Controller reset occurs as a result of any of the three events: when power up the controller, soft reset from the functional diagram or on command by WatchDog Timer. The controller is initialized after reset: the entire memory contents is cleared, input-output channels are reset to a neutral state, system software drivers are transferred to the initial state, power consumption is set to normal, and a functional diagram execution starts from the beginning. The non-volatile memory content does not change at reset.

Information about the reset is available by accessing the address "Power On Detect Register"

Address Return Values
Power On Detect Register
1 = the current execution cycle is the first one, since soft reset or restored power
0 = the current execution cycle is not the first one, since soft reset or restored power

Forced reset of the controller is performed by writing a nonzero value to "Reset Register" address. In this case, the controller reset takes place immediately after the end of the execution cycle of functional diagram, if there is a record.

Address Expected values
Reset Register
≥ 1 = start a forced controller reset
0 = value is ignored


Built-in LED[edit]

The controller has a built-in bi-color (green/red) LED. The functional diagram controls switching-on of each color by writing specific values into the appropriate registers.

Address Expected values
Green LED On/Off Register
≥ 1 = turn-on built-in Green LED
0 = turn-off built-in Green LED
Red LED On/Off Register
≥ 1 = turn-on built-in Red LED
0 = turn-off built-in Red LED
Note: Turning the LED simultaneously in both colors is unavailable, so if functional diagram set simultaneous switching on of Red and Green LEDs, the LED turns green only (green priority).

A functional diagram fragment, which turns on built-in Red LED for one second after each controller reset.

6 5 3 1.png


Hibernation[edit]

After reset, the controller starts working at normal power consumption, functional diagram will be executed continuously. Transition to Hibernation Mode carried out by the command of functional diagram will record a non-zero value to "Sleep Mode Enable Register". Transition to Sleep Mode takes place immediately after the end of functional diagram execution cycle, in which such recording was made, in the absence of conditions that impede this transition.

The duration of "sleep" phase can be set from the functional diagram by writing a value to the address "Sleep Mode Time Scale Register". By default, if the functional diagram has no entry in the corresponding register, the "sleep" phase of hibernation mode lasts 1000ms. This means that while controller is in low power mode, or in the absence of conditions for transition to the normal power, the controller makes a pause of 1 second after each execution cycle of functional diagram.


Address Expected values
Sleep Mode Enable Register
≥ 1 = go into low power mode
0 = return to normal power mode
Sleep Mode Time Scale Register
0...65535 = duration of "sleep" phase in milliseconds after each execution cycle of functional diagrams

Returning controller to normal power can be done manually - immediately after the end of the execution cycle of functional diagrams, during which it was written "0" at "Sleep Mode Enable Register", or automatically by any of the following events:

  • with changing of the electric potential in any terminal with the appropriate controller channel, configured as an active input or pulse counter;
  • when enabled from the functional diagram of any of the drivers CAN, LIN, UART/RS232, IR or Elita GSW with changing of the electric potential on the corresponding drivers' terminal.

Information on the current power mode is available when accessing the address "Sleep Mode Control Register"

Address Return Values
Sleep Mode Control Register
1 = controller is in Sleep Mode
0 = controller is in Normal Mode
Note: When creating a functional diagram, using low-power mode should be considered as a side effect brought by the change in the time scale. This effect manifests itself in functional blocks increment time: delay start, stop and PWM generators in a low power mode occurs in leaps and bounds according to the time actually spent in the phase of "sleep" (default 1000 ms increments).

A fragment of a functional diagram with typical low-power mode control: transition to the low power mode in the absence within 10 seconds conditions preventing it and automatic return to normal mode due to controller periphery activity or set ban to "sleep" from the diagram:

6 5 4 1.png
Note: Inversion of the output of the function block №4.

WatchDog Timer[edit]

To eliminate infinite loop occurrence out of functional diagram, of what could happen in the event of controller incorrectly connected or errors in the system software provided by WatchDog Timer (WDT).

In CannyLab IDE up to version 1.4, the user can control watchdog operation: enable or disable it, set its period.

From CannyLab version 1.4 onwards, the user does not have access to the management of WDT. The watchdog timer is enabled permanently and its period is 1 ... 2 seconds.

If pausing of the functional diagram execution exceeds the period of WDT, the controller will be automatically reset.

Function Diagram actual run time[edit]

The time required for the controller to perform functional diagram in actual conditions depends on the number and type of functional blocks present in the diagram, the number of drivers involved in the system software and their activity. In practice, CANNY 7 execution cycle of a diagram contains about 400 function blocks and is actively interacting with CAN driver, lasts approximately 9 ms.


Note: When creating a functional diagram, the effect of execution loop duration should be considered. The effect is reflected in the fact that the increment of functional blocks time counters- start/stop delays and PWM generators occurs abruptly. Thus, when the actual cycle length of 6 cm, all PWM generators actual period on the diagram is a multiple of 6 ms.

Information about the length of functional diagram previous execution cycle is available at "Last Execution Loop Duration Register".

Address Return Values
Last Execution Loop Duration Register, ms
0...65535 = length of functional diagram previous execution cycle in integer fractions of milliseconds.
Note: The most accurate way to measure the total time of the controller operation, such as the implementation of the clock is the summation with accumulation of the values obtained at "Last Execution Loop Duration Register" during each execution cycle of functional diagram.

A fragment of a functional diagram that implements a high-precision seconds counter is suitable for use in real-time clock:

6 5 6 1.png

Device ID[edit]

With CANNY 7 updated boot loader release, version 001004, during manufacture each device is assigned a unique identification number that can be used for further development, and to better protect against unauthorized use.

Access to the device identifier is carried out via relevant special system registers.

Address Return Values
Device ID Register D1:D0
0...0xFFFF = Lover two bites (D1 & D0) controller ID;
Device ID Register D3:D2
0...0xFFFF = Upper two bites (D3 и D2) controller ID.


During custom diagram development in CannyLab, the device ID, can be found by accessing device information available in the section "Device" → "Information" of main menu or by clicking the "Information" toolbar, where it is represented in 4-byte (32-bit) number, with the location of the high byte on the left.

For example, the identifier 0x563B8693 as followed: Device ID Register D1:D0 is equal to 0x8693, Device ID register D3:D2 is 0x563B.

Example - functional diagram illustrating an operation with the device identifier. In the diagram a value read from device identification registers is compared with the given and if they match, the network will display "device ID is correct" saved "1".

6 5 7 1.png

Monitoring of interface activity of controller (RU)[edit]

"Регистр контроля активности интерфейсов контроллера" - синтетический регистр, отражающий текущую активность задействованных в пользовательской диаграмме внешних интерфейсов контроллера, либо включенных в режиме счетчика или в режиме активного входа каналов ввода-вывода. В те моменты времени, когда по задействованным пользователем интерфейсам контроллера CAN/LIN/UART/ИК и т.д. не осуществляется прием либо передача каких-либо сигналов и не происходит изменений электрического потенциала на соответствующих активным каналам-входам контактах контролера, в "Регистре контроля активности интерфейсов контроллера" находится значение "0".

Использование данного регистра удобно в алгоритмах управления режимами энергопотребления контроллера.

Регистр Возвращаемые значения
Регистр контроля активности интерфейсов контроллера
≥ 1 = в течении предыдущего цикла выполнения диаграммы, на одном или нескольких задействованных в диаграмме интерфейсах или активных каналах ввода-вывода обнаружена активность
0 = в течении предыдущего цикла выполнения диаграммы, ни на одном задействованном в диаграмме интерфейсе контроллера или активном канале ввода-вывода активности не обнаружено


Vendor ID (RU)[edit]

With CANNY 7 updated boot loader release, version 001005, during devices manufacture, each of which is assigned a identification number of the vendor (supplier), which can be used in the future for the development of custom diagrams for additional protection against unauthorized use.

Device Vendor ID assigned by the manufacturer of controllers is the same for all controllers, designed for a single counterparty, or can be installed separately on a specific party controllers. For the production of controllers with a specific identifier vendor please contact the manufacturer.

Access to work with the device identifier via the corresponding special system register of controller.

Регистр Возвращаемые значения
Регистр идентификатора вендора устройства
0...0xFFFF = значение индивидуального идентификационного номера вендора;


В процессе разработки пользовательской диаграммы, из CannyLab, идентификатор устройства можно узнать обратившись к информации об устройстве, доступной в пункте «Устройство» => «Информация» главного меню программы или по нажатию кнопки «Информация» панели инструментов, где он представлен в виде 2х байтового (16-битного) числа, с расположением старшего байта слева.

Пример функциональной диаграммы, иллюстрирующей работу с идентификатором вендора устройства. В диаграмме значение, прочитанное из регистра идентификатора вендора устройства, сравнивается с заданными и в случае их совпадения в именованную сеть «корректный вендор» сохраняется значение «1».

6 5 9 1.png

See also[edit]

CANNY 7