main content

getting started with texas instruments c2000 microcontroller blockset -凯发k8网页登录

this example shows you how to use c2000™ microcontroller blockset to run a simulink® model on texas instruments c2000 hardware.

introduction

c2000™ microcontroller blockset enables you to generate a real-time executable and download it to your ti development board. the blockset includes a library of simulink blocks for configuring and accessing texas instruments c2000 peripherals and communication interfaces. in this example you will learn how to configure a simple simulink model to generate code for any ti c2000 hardware and to run the generated code on the board to periodically turn an led on and off. this example shows you how to configure two different models to run in different cpu cores.

prerequisites

if you are new to simulink, we recommend completing the:

required hardware

to run this example, you can use any ti c2000 hardware. for your convenience, the following hardware models are preconfigured to execute the example:

  • and 180 pin controlcard docking station

model

open_system('c28069_blink.slx');

task 1 - create, configure and run the model for ti piccolo f28069m launchpad (single core)

in this task you will create and configure a simple model blinking an on-board led to run on ti piccolo f28069m launchpad (single core).

1. enter sllibrarybrowser at the matlab® prompt. this opens the simulink library browser.

2. in the simulink library browser, navigate to libraries > c2000™ microcontroller blockset and select c2806x processor.

3. double-click the gpio block. review the block mask, which contains a description of the block and parameters for configuring the associated user gpio.

4. in matlab, select home > new > simulink model.

5. drag the gpio block from c2806x library to the model.

6. drag the constant block from simulink library to the model.

7. connect the output of the constant block to either one of the corresponding input of each gpio block. configure the gpio and constant block as follows:

  • a. configure gpio block with pin 39 for blue led or with pin 34 for red led.

  • b. ensure the toggle gpio option is enabled. enabling this option will toggle the gpio pin when input passed to this block is 1. the rate of toggle will be based on the sample time of the input.

  • c. for constant block, specify the sample time (0.5). since the toggle option is enabled in gpio block, this ensures gpio is 1 for period of 0.5 sec and 0 for 0.5 secs. so, the period of the waveform is 1 sec.

8. save your model and connect the ti piccolo f28069m launchpad to your computer with a usb cable.

9. open the saved model to configure the model for f28069m launchpad:

  • a. open the modeling tab and press ctrl e (model settings) to open configuration parameters dialog box.

  • b. go to hardware implementation > hardware board and select ti piccolo f2806m launchpad.

  • c. ensure boot from flash is enabled if the application has to load to the flash. if you do not select this option, the application loads to the ram.

  • d. click ok.

10. go to the hardware tab and click build, deploy & start to generate code for the model and deploy the executable.

11. the generated code is built and run on the f28069m launchpad automatically. when the model starts running on the f28069m launchpad, observe that the user led on the board blinks with a period of 1 second.

12. save your model. a model is included for your convenience.

task 2 - create, configure and run the model for ti delfino f28379d launchpad (dual core)

in this task you will create and configure a simple model blinking an on-board led to run on f28379d launchpad (dual core).

f2837xd is a dual core. you can create 2 models. one each for and to generate 2 separate executables.

create a model for cpu1 of f28379d

1. enter sllibrarybrowser at the matlab prompt. this opens the simulink library browser.

2. in the simulink library browser, navigate to libraries > c2000™ microcontroller blockset and select f2837xd processor.

3. double-click the gpio block. review the block mask, which contains a description of the block and parameters for configuring the associated user gpio.

4. perform the steps 4 to 8 of task 1 for ti delfino f28379d launchpad. for this task, configure gpio block with pin 34 for red led.

5. select the ti delfino f28379d launchpad and verify the cpu used for your model. for this task, select cpu1. this selection creates and downloads the executable for cpu1.

6. go to the hardware tab and click build, deploy & start to generate code for the model and deploy the executable.

7. the generated code is built and run on the f28379d launchpad automatically. when the model starts running on the f28379d launchpad, observe that the user led on the board blinks with a period of 1 second.

8. save your model. a model is included for your convenience.

create a model for cpu2 of f28379d

since ti delfino f28379d launchpad is a dual core processor, you can create a similar model using cpu2 option and blink the led.

1. perform the steps 1 to 4 of task 2 for ti delfino f28379d launchpad.

2. select the ti delfino f28379d launchpad and verify the cpu used for your model. for this task, select cpu2 and configure gpio block with pin 31 for blue led. this selection creates and downloads the executable for cpu2.

3. the generated code is built and run on the f28379d launchpad automatically. when the model starts running on the f28379d launchpad, observe that the user led on the board blinks with a period of 1 second.

4. save your model. a model is included for your convenience.

note:

  • do not use the gpio pins is used in cpu1.

  • ensure that peripherals used in cpu1 are not used in cpu2. if same peripherals are used in cpu1 and cpu2, the model may not work as expected.

by creating 2 models for ti delfino f28379d launchpad, you can blink 2 led's. one from cpu1 and another with cpu2.

task 3 - create, configure and run the model for f2838x (multi-core) processor

in this task you will create and configure a simple model blinking an on-board led to run on f2838x (multi-core).

f2838x is a multi-core processor. you can create 3 models to generate 3 separate executables for:

for cpu1 and cpu2 of f2838x(c28x)

1. enter sllibrarybrowser at the matlab prompt. this opens the simulink library browser.

2. in the simulink library browser, navigate to libraries > c2000™ microcontroller blockset > f2838x > select f2838x_c28x processor.

3. double-click the gpio block. review the block mask, which contains a description of the block and parameters for configuring the associated user gpio.

4. create cpu1 and cpu2 model by performing the steps 4 to 8 of task 2 for f2838x(c28x) processor.

5. a preconfigured model ( and ) is included for your convenience.

note: do not use the same gpio pins used in cpu1 and cpu2.

for arm cortex-m4 of f2838x_m4

1. enter sllibrarybrowser at the matlab prompt. this opens the simulink® library browser.

2. in the simulink library browser, navigate to libraries > c2000™ microcontroller blockset > f2838x > select f2838x_m4 processor.

3. double-click the gpio block. review the block mask, which contains a description of the block and parameters for configuring the associated user gpio.

4. perform the steps 4 to 7 of task 1 for f2838x-m4 processor and save the model.

note: while configuring the gpio pin, select the appropriate pin applicable for arm cortex-m4 processor. do not use same gpio pins used in cpu1 or cpu2.

5. open the saved model to configure the model for f2838x_m4:

  • a. open the modeling tab and press ctrl e (model settings) to open configuration parameters dialog box.

  • b. go to hardware implementation > hardware board and select ti f2838x. in the processing unit, select *cortexm4.

  • c. ensure boot from flash is enabled if the application has to load to the flash. if you do not select this option, the application loads to the ram.

  • d. click ok.

6. go to the hardware tab and click build, deploy & start to generate code for the model and deploy the executable.

7. the generated code is built on the f2838x (arm cortex-m4) and run automatically. when the model starts running on the f2838x (arm cortex-m4), observe gpio pin toggling with a period of 1 second.

8. save your model. a model is included for your convenience.

note: for multicore processor like f2838x, try interchanging the gpio's between cpu2 and arm cortex-m4 or cpu1 and arm cortex-m4 and observe the led blink.

other things to try

experiment with other blocks in the texas instruments c2000 processors block library. for example:

  • create and run a model that repeatedly blinks an led. hint: use the pulse generator block.

  • create and run a model that repeatedly blinks an led. hint: use the external mode example.

网站地图