This documentation is out of date.
The new version of the documentation is here: https://cannylogic.com/docs |
Difference between revisions of "CANNY 7, System Registers"
[unchecked revision] | [unchecked revision] |
(initial edit, will continue later) |
m (clarification) |
||
Line 1: | Line 1: | ||
== General description == | == General description == | ||
− | User-accessible system resources are divided into read registers and write registers. By accessing these registers from the function diagram, you can configure the controller’s operating modes and access the controller status information that is necessary for your usage case. The list of system registers is available in the "System Registers" window in CannyLab IDE, accessible via "Input Register" and "Output Register" context menus. | + | User-accessible system resources are divided into read registers and write registers. By accessing these registers from the function diagram, you can configure the controller’s operating modes and access the controller status information that is necessary for your usage case. The list of system registers is available in the "System Registers" directory in the register selection window in CannyLab IDE, accessible via "Input Register" and "Output Register" context menus. |
== Reset controller == | == Reset controller == |
Latest revision as of 20:04, 14 December 2020
Contents
General description
User-accessible system resources are divided into read registers and write registers. By accessing these registers from the function diagram, you can configure the controller’s operating modes and access the controller status information that is necessary for your usage case. The list of system registers is available in the "System Registers" directory in the register selection window in CannyLab IDE, accessible via "Input Register" and "Output Register" context menus.
Reset controller
Controller reset can occur as a result of any of the three events: the controller is powered on, a request for a soft reset is sent from the function diagram, at the command of the WatchDog Timer. The controller is initialized after a reset: the contents of random access memory are cleared, input-output channels are reset to a neutral state, system software driver configuration is rolled back to its initial state, power consumption is set to normal, and the function diagram execution starts from the beginning. The non-volatile memory content does not change after a reset.
Information about the reset is available by accessing the "Power On Detect Register"
Address | Return Values | ||||||
---|---|---|---|---|---|---|---|
Power On Detect Register |
|
You can force a soft reset of the controller by writing a non-zero value to the "Reset Register". The controller will be reset after finishing the execution cycle during which the value was written.
Address | Expected values | ||||||
---|---|---|---|---|---|---|---|
Reset Register |
|
Built-in LED
The controller is equipped with a built-in bi-color (green/red) LED. Each color can be switched on or off independently from the function diagram by writing specific values into the appropriate registers.
Address | Expected values | ||||||
---|---|---|---|---|---|---|---|
Green LED On/Off Register |
| ||||||
Red LED On/Off Register |
|
Note: | Turning on both colors of the LED simultaneously is impossible. Priority is given to the green LED if both registers have a non-zero value. |
A function diagram fragment, which turns on the built-in Red LED for one second after each controller reset.
Hibernation
After a reset, the controller starts working in the normal power consumption mode, with the function diagram being executed continuously. Transition to Hibernation Mode is done by writing a non-zero value to the "Sleep Mode Enable Register". Transition to Sleep Mode takes place immediately after the end of the execution cycle, during which the value was written, in the absence of conditions that could 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 |
| ||||||
Sleep Mode Time Scale Register |
|
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 |
|
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:
Note: | Inversion of the output of the function block №4. |
WatchDog Timer
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
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 |
|
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:
Device ID
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 |
| |||
Device ID Register D3:D2 |
|
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".
Monitoring of interface activity of controller (RU)
"Регистр контроля активности интерфейсов контроллера" - синтетический регистр, отражающий текущую активность задействованных в пользовательской диаграмме внешних интерфейсов контроллера, либо включенных в режиме счетчика или в режиме активного входа каналов ввода-вывода. В те моменты времени, когда по задействованным пользователем интерфейсам контроллера CAN/LIN/UART/ИК и т.д. не осуществляется прием либо передача каких-либо сигналов и не происходит изменений электрического потенциала на соответствующих активным каналам-входам контактах контролера, в "Регистре контроля активности интерфейсов контроллера" находится значение "0".
Использование данного регистра удобно в алгоритмах управления режимами энергопотребления контроллера.
Регистр | Возвращаемые значения | ||||||
---|---|---|---|---|---|---|---|
Регистр контроля активности интерфейсов контроллера |
|
Vendor ID (RU)
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.
Регистр | Возвращаемые значения | |||
---|---|---|---|---|
Регистр идентификатора вендора устройства |
|
В процессе разработки пользовательской диаграммы, из CannyLab, идентификатор устройства можно узнать обратившись к информации об устройстве, доступной в пункте «Устройство» => «Информация» главного меню программы или по нажатию кнопки «Информация» панели инструментов, где он представлен в виде 2х байтового (16-битного) числа, с расположением старшего байта слева.
Пример функциональной диаграммы, иллюстрирующей работу с идентификатором вендора устройства. В диаграмме значение, прочитанное из регистра идентификатора вендора устройства, сравнивается с заданными и в случае их совпадения в именованную сеть «корректный вендор» сохраняется значение «1».