| Target Support Package™ IC1 | ![]() |
Target Support Package IC1/ C166 Driver Library

The C166 Resource Configuration block differs in function and behavior from conventional blocks. Therefore, we refer to this block as the C166 Resource Configuration object.
The C166 Resource Configuration object is required to provide information that is used to configure driver blocks and timer interrupts.
You must include this block in your model if
You are using any of the driver blocks supplied with the Target Support Package™ IC1 product
You are taking advantage of the automatically generated scheduler that is driven by timer interrupts.
You do not need to include the C166 Resource Configuration object in your model if you are not using any of the C166 driver library blocks, and if you do not require the automatically generated scheduler (for example, if you are supplying your own main.c).
The C166 Resource Configuration object maintains configuration settings that apply to the Infineon C166 microcontroller. Although the C166 Resource Configuration object resembles a conventional block in appearance, it is not connected to other blocks via input or output ports. This is because the purpose of the C166 Resource Configuration object is to provide information to other blocks in the model. C166 device driver blocks register their presence with the C166 Resource Configuration object when they are added to a model or subsystem; they can then query the C166 Resource Configuration object for required information.
To install a C166 Resource Configuration object in a model or subsystem, open the C166 Drivers library and select the C166 Resource Configuration icon. Then drag and drop it into your model or subsystem, like a conventional block.
Having installed a C166 Resource Configuration object into your model or subsystem, you can then select and edit configuration settings in the C166 Resource Configuration window. See Using the C166 Resource Configuration Window for further information.
Note If your model or subsystem requires a C166 Resource Configuration object (see above), you should place it at the top-level system for which you are going to generate code. If your whole model is going to run on the target processor, put the C166 Resource Configuration object at the root level of the model. If you are going to generate code from separate subsystems (to run specific subsystems on the target), place a C166 Resource Configuration object at the top level of each subsystem. You should not have more than one C166 Resource Configuration object in the same branch of the model hierarchy. Errors will result if these conditions are not met. |
When the C166 Resource Configuration block is placed into a model, it modifies the preloadfcn callback of the model. If you wish to add a command to the preloadfcn callback of a model that already has an C166 Resource Configuration block, do not remove the commands that are already installed. Instead, copy the installed preloadfcn callback and append your commands. Then set the preloadfcn to the merged command. If you corrupt the preloadfcn, you can retrieve the command from any model that has a C166 Resource Configuration block, as the preloadfcn will be the same for all models. You can retrieve the preloadfcn with the following command: plf = get_param(bdroot,'preloadfcn')
A configuration is a collection of parameter values affecting the operation of one or more device driver blocks in the Target Support Package IC1 library. The C166 Resource Configuration object currently supports the following types of configurations:
C166 System Configuration Parameters (c166drivers): C166 microcontroller clocks and other CPU-related parameters
Asynchronous/Synchronous Serial Interface Configuration ParametersAsynchronous/Synchronous Serial Interface Configuration: parameters related to the serial driver blocks and Simulink® external mode
CAN Configuration Parameters: parameters for CAN interrupt levels
TwinCAN Configuration Parameters: parameters for TwinCAN interrupt levels
C-CAN Configuration Parameters: parameters for C-CAN interrupt levels
The C166 drivers configuration always appears in the active configuration pane. If there are also blocks in your model from the Asynchronous/Synchronous Serial Interface (ASC0) sublibrary, you will also see the configuration for these, as seen in the next example. If you add an ASC0 block to a model without any ASC0 blocks, the appropriate configuration is created and activated in the C166 Resource Configuration block. Similarly, if you add CAN blocks to a model, a CAN configuration is created.
You can see an example like this by opening the demo model c166_serial_transmit and double-clicking on the C166 Resource Configuration block.
A configuration remains active until all blocks associated with it are removed from the model or subsystem. At that point, the configuration is in an inactive state. Inactive configurations are lost from the C166 Resource Configuration window when the model is saved and reopened. You can reactivate a configuration by simply adding an appropriate block into the model.
To open the C166 Resource Configuration window, install a C166 Resource Configuration object in your model or subsystem and double-click on the C166 Resource Configuration icon. The C166 Resource Configuration window then opens.
This example shows the C166 Resource Configuration window for a model that has active configurations for the C166 microcontroller (c166drivers) and for the Asynchronous/Synchronous Serial Interface (ASC0) blocks, as found in the demo c166_serial_transmit.

The C166 Resource Configuration window consists of the following elements:
Active Configurations panel: This panel displays a list of currently active configurations. To edit a configuration, click its entry in the list. The parameters for the selected configuration then appear in the System Configuration panel.
To link back to the library associated with an active configuration, right-click its entry in the list. From the menu that appears, select Go to library.
To see documentation associated with an active configuration, right-click its entry in the list. From the menu that appears, select Help.
System Configuration panel: This panel lets you edit the parameters of the selected configuration. The parameters of each configuration type are detailed in C166 Resource Configuration Window Parameters.
Status panel: The Status panel displays error messages that may arise if resource allocation conflicts are detected in the configuration.
OK button: Dismisses the window.
The following sections describe the parameters for each type of configuration in the C166 Resource Configuration window. The default parameter settings are optimal for most purposes. If you want to change the settings, read the relevant sections of the C166 User's Manual. You can find this document at the Infineon Web site at the following URL:
http://www.infineon.com/
For the ST10 User's Manual, see the ST Microelectronics Web site at following URL:
http://www.st.com/

Depending on your hardware variant, the Real-Time Clock (RTC) may be driven directly by the external oscillator input and it is, therefore, important that the external oscillator frequency is set correctly. Otherwise, if the RTC is used to provide any timing services, the behavior will be incorrect. The default value for external oscillator frequency is 5 MHz. You should check your hardware manual to establish the correct value for your setup. Note you can choose the RTC as a System_timer, see below.
This parameter allows one of the on-chip timers to be configured for use with execution profiling. The selected timer is configured to run indefinitely at a known frequency and is used by the execution profiling engine to record the times at which tasks start or finish executing. See Execution Profiling for more details.
To find supported timer configurations, you should check the General Purpose Timer section of the relevant User's Manual for your C166 microcontroller derivative.
You must set the system frequency of your C166 microcontroller hardware here. Note that the value depends on your hardware type and configuration. If you choose an incorrect value the model will be correspondingly fast or slow.
You must select which timer to use for generating interrupts to drive the model update rate. You should select a timer, or timer pair, that you do not intend to use for any other purpose within your application. We recommend you choose a pair of timers, e.g., T6, with reload from CAPREL. This will give the best possible sample time accuracy with no long term drift caused by higher priority interrupts. If you choose a single timer, e.g., T2 or RTC, the timer value will be reloaded within the timer interrupt service routine. With this approach, any delay in servicing the timer interrupt will be added to the time until the next timer interrupt is generated.
To find supported timer configurations, you should check the General Purpose Timer section of the relevant User's Manual for your C166 microcontroller derivative.
These two parameters together set the priority of sample time interrupts. You should choose values such that the sample time interrupts are suitably prioritized relative to other interrupts used by your application.

This read-only field shows the achieved serial interface bit rate. In general, this value differs slightly from the requested bit rate, but is the closest value that can be achieved by setting allowed values in C166 register S0BG and bitfield S0BRS of register S0CON.
Enter the desired bit rate for serial communications in this field. Appropriate register settings are calculated automatically. You can verify the actual bit rate in the Bit_rate_achieved field.
Select this entry to operate the serial interface in loopback mode. This may be useful for test purposes where the serial interface is required to receive data that it transmitted itself.
Select the desired combination of word length and parity/no parity. See the C166 User's Manual for more details.
If parity is enabled, you must select odd or even.
You must select the size of the RAM buffer that will be used by the serial receive driver. The maximum allowed value is 254.
Set the receive interrupt priority here. Note that the Target Support Package IC1 drivers allow only interrupt levels 14 and 15 to be used. The reason for this is that the drivers use the peripheral event controller (PEC), which provides very fast interrupt response but is restricted to levels 14 and 15.
This is a noneditable field that shows the value of the serial interface register S0CON and how it varies as dialog box settings are changed.
You must select either 1 or 2 stop bits.
See Receive_buffer_size.
See Receive parameters above.

The parameters listed below are the same for CAN modules A and B.
This parameter is read only; all transmitted messages are sent from buffer 14.
These two parameters together set the priority of sample time interrupts. You should choose values such that the sample time interrupts are suitably prioritized relative to other interrupts used by your application. Note that CAN module interrupts must be set to a higher priority than timer interrupts. Use the Validate Configuration button to make sure you do not select an interrupt level that is already in use.
You can use these mask configuration parameters to choose to ignore certain bits. In general, a CAN message is received only if its identifier is an exact match with the identifier specified in one of the receive buffers. You can use mask parameters to indicate that some of the bits in the received message identifier are "don't care."
This mask applies to buffer 15 only. Each bit in the mask that is set to zero causes the corresponding bit in the received message identifier to be ignored when comparing it to the message identifier that buffer 15 is configured to receive.
This mask applies to any of buffers 1 to 14 that are configured to receive messages with an extended identifier. Each bit in the mask that is set to zero causes the corresponding bit in the received message identifier to be ignored when comparing it to the message identifier that this buffer is configured to receive.
This mask applies to any of buffers 1 to 14 that are configured to receive messages with an standard identifier. Each bit in the mask that is set to zero causes the corresponding bit in the received message identifier to be ignored when comparing it to the message identifier that this buffer is configured to receive.
If the module is enabled, then initialization code for that CAN module is generated. Use this setting to prevent generation of driver code for a CAN module that is not required, or not available on your hardware variant.
Enter the desired bit rate. The default bit rate is 500000.
The number of CAN module clock ticks per message bit.
The maximum number of clock ticks that the CAN device can resynchronize over when it detects that it is losing message synchronization.
The point in the message where the CAN module samples the value of the message bit.
Length (number of messages) of the transmit queue. The transmit queue holds messages that are waiting to be transmitted. An increase in performance can be achieved by reducing the queue length. However, if the queue's length is too small, it may become full, causing messages to be lost.

The TwinCAN Configuration Parameters are a subset of the CAN Configuration Parameters, plus these additional parameters:
Select the desired pin. The default is P4.5(CAN_A) or P9.0(CAN_B).
Select the desired pin. The default is P4.6(CAN_A) or P9.1(CAN_B).

The C-CAN Configuration Parameters are the same subset of the CAN Configuration Parameters as the TwinCAN Configuration Parameters, plus the following two settings. The parameters are the same for C-CAN modules 1 and 2.
When this option is not selected (the default), C-CAN modules 1 and 2 are connected to separate I/O pins. Use this option if C-CAN modules 1 and 2 both share the same microcontroller I/O pins P4.5 (receive) and P4.6 (transmit). In this mode both CAN modules are connected to the same CAN bus via a shared transceiver. This option takes effect only if both C-CAN modules are enabled. See the microcontroller User Manual for more details.
When selected, the transmit lines for both CAN 1 and CAN 2 are configured for open drain. Use this option if both C-CAN modules are connected (externally from the microcontroller) to the same CAN transceiver. This option takes effect only if both C-CAN modules are enabled and if the option for both modules to use shared pins is not selected. See the microcontroller User Manual for more details.
![]() | C166 Execution Profiling via TwinCAN A | CAN Bus Status | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |