Skip to Main Content Skip to Search
Product Documentation

C6416 DSK DIP Switch - Simulate or read DIP switches

Library

Embedded Coder/ Embedded Targets/ Processors/ Texas Instruments C6000/ C6416 DSK

Description

Added to your model, this block behaves differently in simulation than in code generation and targeting.

In Simulation — the options Switch 0, Switch 1, Switch 2, and Switch 3 generate output to simulate the settings of the user-defined dual inline pin (DIP) switches on your C6416 DSK. Each option turns the associated DIP switch on when you select it. The switches are independent of one another.

By defining the switches to represent actions on your target, DIP switches let you modify the operation of your process by reconfiguring the switch settings.

Use the Data type to specify whether the DIP switch options output an integer or a logical string of bits to represent the status of the switches. The table that follows presents all the option setting combinations with the result of your Data type selection.

Option Settings to Simulate the User DIP Switches on the C6416DSK

Switch 0 (LSB)

Switch 1

Switch 2

Switch 3 (MSB)

Boolean Output

Integer Output

Cleared

Cleared

Cleared

Cleared

0000

0

Selected

Cleared

Cleared

Cleared

0001

1

Cleared

Selected

Cleared

Cleared

0010

2

Selected

Selected

Cleared

Cleared

0011

3

Cleared

Cleared

Selected

Cleared

0100

4

Selected

Cleared

Selected

Cleared

0101

5

Cleared

Selected

Selected

Cleared

0110

6

Selected

Selected

Selected

Cleared

0111

7

Cleared

Cleared

Cleared

Selected

1000

8

Selected

Cleared

Cleared

Selected

1001

9

Cleared

Selected

Cleared

Selected

1010

10

Selected

Selected

Cleared

Selected

1011

11

Cleared

Cleared

Selected

Selected

1100

12

Selected

Cleared

Selected

Selected

1101

13

Cleared

Selected

Selected

Selected

1110

14

Selected

Selected

Selected

Selected

1111

15

Selecting the Integer data type results in the switch settings generating integers in the range from 0 to 15 (uint8), corresponding to converting the string of individual switch settings to a decimal value. In the Boolean data type, the output string presents the separate switch setting for each switch, with the Switch 0 status represented by the least significant bit (LSB) and the status of Switch 3 represented by the most significant bit (MSB).

In Code generation and targeting — the code generated by the block reads the physical switch settings of the user switches on the board and reports them as shown in the table above. Your process uses the result in the same way whether in simulation or in code generation. In code generation and when running your application, the block code ignores the settings for Switch 0, Switch 1, Switch 2 and Switch 3 in favor of reading the hardware switch settings. When the block reads the DIP switches, it reports the results as either a Boolean string or an integer value as the following table shows.

Output Values From The User DIP Switches on the C6416DSK

Switch 0 (LSB)

Switch 1

Switch 2

Switch 3 (MSB)

Boolean Output

Integer Output

Off

Off

Off

Off

0000

0

On

Off

Off

Off

0001

1

Off

On

Off

Off

0010

2

On

On

Off

Off

0011

3

Off

Off

On

Off

0100

4

On

Off

On

Off

0101

5

Off

On

On

Off

0110

6

On

On

On

Off

0111

7

Off

Off

Off

On

1000

8

On

Off

Off

On

1001

9

Off

On

Off

On

1010

10

On

On

Off

On

1011

11

Off

Off

On

On

1100

12

On

Off

On

On

1101

13

Off

On

On

On

1110

14

On

On

On

On

1111

15

Dialog Box

Switch 0

Simulate the status of the user-defined DIP switch on the board.

Switch 1

Simulate the status of the user-defined DIP switch on the board.

Switch 2

Simulate the status of the user-defined DIP switch on the board.

Switch 3

Simulate the status of the user-defined DIP switch on the board.

Data type

Determines how the block reports the status of the user-defined DIP switches. Boolean is the default, indicating that the output is a vector of four logical values.

Each vector element represents the status of one DIP switch; the first is Switch 0 and the fourth is Switch 3. The data type Integer converts the logical string to an equivalent unsigned 8-bit (uint8) value. For example, when the logical string generated by the switches is 0101, the conversion yields 5 — the MSB is 0 and the LSB is 1.

Sample time

Specifies the time between samples of the signal. This value defaults to 1 second between samples, for a sample rate of one sample per second (1/Sample time).

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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