CAN Definition

This MotoHawk™ block selects which CAN bus to initialize.

Block ID

CAN Definition

Library

MotoHawk_lib/CAN Blocks

Description

This MotoHawk™ block selects which CAN bus to initialize. It has configuration options for the baud rate settings.

The first option is choosing one of the fixed "default" baud rate settings. All of these selections won't be supported on all modules, but it offers default time quanta settings that are appropriate for the target if it is available.

The second option is setting up "custom" baud rate settings. This option controls the exact baud rate and the time quanta settings. Additionally, there is an option to specify these settings with a data store. The block cross checks for data type and dimension if this is selected. If a data store is used for selecting the time quanta, then another option exists for some modules to choose if time quanta changes should take place immediately, or only upon a restart of the application. The default is for time quanta changes to take place upon the next application startup.

Note that the baud rate settings are only applied on power on unless the 'Update Bit Timing Without Restart' option is available and chosen. The data store "Storage" setting is very important when the bit timing is only applied at application startup.

The CAN Baud Rate Status block can assist the configuration of these settings at run time.

Selecting Time Quanta

When setting up "custom" baud rate settings, the following equation is used to determine the actual attainable baud rate:
baudrate calcuation
Where:
rp = required prescalar
mp = maximum prescalar
ab = attainable baud rate
db = desired baud rate
ttq = total time quanta
clock = clock frequency

Refer to the appropriate target help page to determine CAN clock frequency and hardware specific limits to prescalar.

Example: Suppose a particular module has a CAN clock of 14000000 Hz and a Total Time Quanta of 14 is desired for the 250 KBaud bus speed. The equation would reveal a required prescalar of floor(14000000/(250000*14)) = 4. The module limits the prescaler between 1 and 255, so the actual attainable baud rate would be 14000000 / (max (min(4, 255) , 8) * 14 ) = 250000.

Upgrading from Obsolete CAN Definition

The Obsolete CAN Definition provided MotoTune connectivity attributes that are not available on this variant of the CAN Definition. This functionality has been moved to the MotoTune CAN Definition block.

Frame Rate Limiting

Each time the CAN silicon receives a CAN frame an interrupt routine will execute. This interrupt puts the received frame into a queue and then “posts” a notification to the dispatching task telling it that a frame has been received. As its name suggests, the dispatching task processes the received CAN frames, dispatching them to the various CAN receive processes that are interested in the frame (as defined by its ID). The dispatching task also identifies those CAN frames that don't need to be dispatched. Such frames are received (because they were not rejected by the hardware filter) but are of no interest to the application. These frames are discarded. This operation is sometimes referred to as software filtering.

Dispatch processing consumes CPU, which can be quite high when there is significant CAN traffic on a bus running a high baud rate (say 1Mbit) that is not being rejected by the CAN's hardware filter. The consumed CPU could even be so high that task starvation results.

CAN Frame Rate Limiting, which is available on some CAN drivers, allows the application to have some control over how much CPU it will allow the dispatcher to consume. It basically suspends frame processing for a period of time when frame processing is approaching the specified limit. CPU is not being consumed processing frames while the process is suspended. Frames are still received, and will be queued while free queue entries remain, but the CPU to process those received frames will be restricted. Received frames are discarded once the receipt queue is full.

The Get CAN Info block is able to read the current rate of frame processing. This value could be used to tune what is an acceptable limit. A large receipt queue should be employed if the limit is set to be very near the typical processing rate in order to handle bursts of activity without data loss.

Block Parameters

Parameter Field Values Comments/Description
Name Alpha-numeric text, single-quote enclosed Name of CAN definition. Should be unique and C-legal (no special characters such as spaces, dashes, commas, though underscore allowed. Other MotoHawk blocks may reference this CAN channel by the name entered in this field. For instance, the user could define the name of CAN 1 as ‘Body_Bus’ while naming CAN 2 ‘Engine_Bus’.
Resource Dropdown Specify which CAN resource to initialize.
Bit Timing Source Dropdown "Default" displays a fixed dropdown list of baud rate options or "Custom" displays more options for baud rate settings.

NOTE: Most applications use one of the pre-defined baud rates, usually 250k. Only advanced users with specific needs are advised to attempt to utilize a custom baud rate.
Default Bit Timing Dropdown Only visible if "Default" is selected for the Bit Time Source.
Select from a fixed dropdown list of baud rates. The time quanta settings are chosen automatically.
Update Bit Timing Without Restart Checkbox Only visible if "Custom" is selected for the Bit Time Source and a time quanta parameter source is a data store.
If checked, time quanta changes are effective without a restart of the application.
Baud Rate Source Dropdown Only visible if "Custom" is selected for the Bit Time Source. Select either "Constant" or "Data Store Reference".
Baud Rate Numeric Only visible if "Custom" is selected for the Bit Time Source and Baud Rate Source is set to "Constant". Specifies the desired baud rate. It must be from 1-1000000.
Baud Rate Data Store Name Alpha-numeric text Only visible if "Custom" is selected for the Bit Time Source and Baud Rate Source is set to "Data Store Reference". Specifies an existing uint32 scalar data store name.
Sample Point Time Quanta Source Dropdown Only visible if "Custom" is selected for the Bit Time Source. Select either "Constant" or "Data Store Reference".
Sample Point Time Quanta Dropdown Only visible if "Custom" is selected for the Bit Time Source and Sample Point Time Quanta Source is set to "Constant". Specifies the desired sample point time quanta.
Sample Point Time Quanta Data Store Reference Alpha-numeric text Only visible if "Custom" is selected for the Bit Time Source and Sample Point Time Quanta Source is set to "Data Store Reference". Specifies an existing uint8 scalar data store name.
Total Time Quanta Source Dropdown Only visible if "Custom" is selected for the Bit Time Source. Select either "Constant" or "Data Store Reference".
Total Time Quanta Dropdown Only visible if "Custom" is selected for the Bit Time Source and Total Time Quanta Source is set to "Constant". Specifies the desired total time quanta.
Total Time Data Store Reference Alpha-numeric text Only visible if "Custom" is selected for the Bit Time Source and Total Time Quanta Source is set to "Data Store Reference". Specifies an existing uint8 scalar data store name.
Synchronization Jump Width Source Dropdown Only visible if "Custom" is selected for the Bit Time Source. Select either "Constant" or "Data Store Reference".
Synchronization Jump Width Dropdown Only visible if "Custom" is selected for the Bit Time Source and Synchronization Jump Width Source is set to "Constant". Specifies the desired synchronization jump width.
Synchronization Jump Width Data Store Reference Alpha-numeric text Only visible if "Custom" is selected for the Bit Time Source and Synchronization Jump Width Source is set to "Data Store Reference". Specifies an existing uint8 scalar data store name.
Transmit Queue Size Numeric Specify the number of messages held in the transmit queue. For most applications the default of 16 is adequate. Applications sending many CAN messages may require a larger value.
Receive Queue Size Numeric Specify the number of messages held in the receive queue. For most applications the default of 16 is adequate. Applications receiving many CAN messages may require a larger value.
Receive Self-Transmitted Messages Check box The hardware supports a configuration that will allow message frames transmitted by this resource to also be received by this resource. Such received message frames are indistinguishable from received message frames sent by another source. This feature is enabled when checked and disabled when unchecked. Disabling this feature may enhance execution performance by minimizing the number of messages that the CAN software needs to service.

This option will only be visible if the selected resource's hardware allows the application to control how this "self-reception" feature is to behave.
HW Receives Self-Transmitted Messages Check box Hardware may have an inbuilt, unmodifiable configuration that defines whether message frames transmitted by this resource are also received by this resource. This resource will receive message frames that it transmits when this attribute is checked and won't receive them when unchecked.

This attribute will only be visible when MotoHawk is able to determine how the selected resource will behave.
Specify Receipt Dispatch Task Check box Each CAN frame that is received by the hardware is queued by an interrupt service. A frame, once queued, is then dispatched to its intended recipient(s) by a task, which by its nature, only executes when there are no interrupts pending. By default this work is sent to the highest priority task. However a CAN bus may only be used for low priority communication that don't warrant being dispatched at such a high priority. This option allows user selection of the task which queues received frames for subsequent dispatch. This, by nature of the selected task's priority, allows the queuing priority to be managed.

The receipt queue may need to be deeper if a low priority task is used since frames may sit in the queue for longer before being dispatched.

This attribute will only be visible when MotoHawk is able to support such task specification.
Receipt Dispatch Task Name Single quote enclosed alpha numeric The name of the task that is to be used by this CAN port for received frame dispatching.

This attribute will only be visible when MotoHawk is able to support such task specification and the Specify Receipt Dispatch Task option has been checked.
Use Frame Rate Limiting Checkbox Specifies whether the CAN port is to use Frame Rate Limiting to ensure the CPU spent processing CAN frames can be bounded.

Only visible if Frame Rate Limiting is supported by the target.
Frame Rate Limiting specification Dropdown Specifies whether a datastore reference or constant value is to be used to specify the Frame Rate Limit.

Only visible if Frame Rate Limiting is supported by the target and selected for use.
Frame Rate Limit (frames/second) Unsigned integer The Frame Rate Limit that is to be applied to this CAN port in frames/second.

Only visible if Frame Rate Limiting is supported by the target, selected for use, and the specifies that a constant value is to be used to specify the limit.
Frame Rate Limit (frames/second) Data Store Reference Alpha-numeric text The name of the Data Store Definition that is to specify the Frame Rate Limit in frames/second. The block expects to reference a scalar uint16.

Only visible if Frame Rate Limiting is supported by the target, selected for use, and a specifies that a datastore reference is to be used to specify the limit.