C166 Resource Configuration - Support device configuration for Infineon® C166® microcontrollers

Library

Target Support Package IC1/ C166 Driver Library

Description

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.

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.

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')

Types of Configurations

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:

Dialog Box

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.

Using the C166 Resource Configuration Window

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:

C166 Resource Configuration Window Parameters

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/

C166 System Configuration Parameters

External_oscillator_frequency

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.

Free_running_timer

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.

System_frequency

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.

System_timer

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.

Timer_interrupt_level and Timer_interrupt_level_group

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.

Asynchronous/Synchronous Serial Interface Configuration Parameters

Bit_rate_achieved

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.

Bit_rate_ideal

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.

Loopback_mode_enable

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.

Mode_control

Select the desired combination of word length and parity/no parity. See the C166 User's Manual for more details.

Parity_selection

If parity is enabled, you must select odd or even.

Receive_buffer_size

You must select the size of the RAM buffer that will be used by the serial receive driver. The maximum allowed value is 254.

Receive_interrupt_level and Receive_interrupt_level_group

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.

S0CON

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.

Stop_bits

You must select either 1 or 2 stop bits.

Transmit_buffer_size

See Receive_buffer_size.

Transmit_interrupt_level and Transmit_interrupt_level_group

See Receive parameters above.

CAN Configuration Parameters

The parameters listed below are the same for CAN modules A and B.

C166_Transmit_Buffer_Number

This parameter is read only; all transmitted messages are sent from buffer 14.

CAN_Int_Level_Group and CAN_Interrupt_Level

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.

Masks

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."

Buffer_15_Mask

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.

Global_Mask_Extended

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.

Global_Mask_Standard

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.

Module_Enabled

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.

Timing

CAN_Bit_Rate

Enter the desired bit rate. The default bit rate is 500000.

Number_Of_Quanta

The number of CAN module clock ticks per message bit.

Resynchronization_Jump_Width

The maximum number of clock ticks that the CAN device can resynchronize over when it detects that it is losing message synchronization.

Sample_Point

The point in the message where the CAN module samples the value of the message bit.

Transmit_Queue_Length

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.

TwinCAN Configuration Parameters

The TwinCAN Configuration Parameters are a subset of the CAN Configuration Parameters, plus these additional parameters:

TwinCAN_Rx_Pin

Select the desired pin. The default is P4.5(CAN_A) or P9.0(CAN_B).

TwinCAN_Tx_Pin

Select the desired pin. The default is P4.6(CAN_A) or P9.1(CAN_B).

C-CAN Configuration Parameters

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.

CAN_modules_share_pins

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.

CAN_transmit_lines_open_drain

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.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS