Getting Started with C2000 Microcontroller Blockset
From the series: Getting Started with C2000 Microcontroller Blockset
Follow this step-by-step guide on how to install and set up C2000™ Microcontroller Blockset with the required 3P tools to work with Texas Instruments® C2000 Microcontrollers and deploy a Simulink® model using the blockset to blink the on-board LED on the TI F280049c LaunchPad.
C2000 Microcontroller Blockset enables you to model digital power conversion and motor control applications for TI C2000 microcontrollers (MCUs). The blockset includes peripheral blocks, such as digital I/O, ADC, and ePWM, to perform simulations of control algorithms that require ADC-PWM synchronization in industrial and automotive applications using C2000 MCUs.
Published: 8 Aug 2023
Hello, everyone. This is Karthik Prabhakar here from MathWorks. In this video, I'm going to show you the steps to install and set up the C2000 Microcontroller Blockset. After the setup, we will also see how to use the blocks available in the C2000 Microcontroller Blockset to blink an LED on a C2000 Microcontroller Launchpad. You can install the C2000 Microcontroller Blockset in two ways. One is to install it along with other products while installing MATLAB, or through the Add-On Manager.
To add it through the Add-On Manager, open MATLAB and navigate to the Add-Ons button in the Home tab. Click the Add-Ons button. This will launch the Add-On Explorer. In the Search bar on the top right corner, type C2000, and hit Enter. C2000 Microcontroller Blockset is the one which we are looking for. now. Click on it, and it will navigate to the blockset.
On the right side, you can find the Install button. Once you click on the Install button, the installation wizard will be launched. To complete the installation, just follow the installation prompts. Also, make sure you read the MathWorks software license agreements before you click on the Accept button and continue with the installation process. You may be required to provide admin credentials during the installation process. Otherwise, the installation may not progress further in some PCs.
After the installation is completed, you need to complete the setup process with the required 3P tools, which are needed to build and load code on the TI C2000 Microcontrollers with the Blockset. To do this, we have the C2000 Setup MATLAB Function to launch the setup wizard. Type C2000 Setup in MATLAB to open this wizard.
The first step in this setup is to select the microcontroller families that you are planning to use with the C2000 Microcontroller Blockset. I would recommend you select the relevant microcontroller families that you are planning to use instead of All to reduce the download and installation time. You can always relaunch this wizard using the C2000 Setup MATLAB Function, in case you want to select more microcontroller families to work with.
Now you need to install the TI C2000 and the ARM Code Generation Tools. You can either install it automatically by clicking on the Install button, or you can click on Manual Download and download it using the links provided here and install it. I will choose the automatic option and click on Install. Once the installation is complete, you can proceed to the next step.
You need to install the TI Control Suite and Code Composer Studio, along with TI C2000Ware, which is required for code generation. If you don't have them installed already, it will show that it is not installed. And you can use the links provided here to download and install them like any other software. If there is a version mentioned in the links, it means that that is the version with which MathWorks has tested the support for TI C2000. It is recommended you use these version for smooth working with the block, set. And if you have already installed it, you will see that the installed version is already detected and shown here, and also indicates whether an upgrade is required or not.
In the next steps, you need to specify the path where TI Control Suite is installed in your PC. Similarly, specify the location where TI Code Composer Studio is installed and validated, followed by the C2000Ware.
With this, we come to the end of the setup wizard, where you can see the summary of all the third-party tools we have installed and configured to work with the C2000 Microcontroller Blockset. In the final screen, when you click on Finish, it will open the documentation of examples available in the C2000 Microcontroller Blockset, which you can refer for jump starting on various application developments with the TI C2000 Microcontrollers, using the C2000 Microcontroller Blockset in Simulink.
Now that we are ready with the C2000 Microcontroller Blockset installation, let's go ahead and work with the hardware by blinking an LED on the launchpad. Open Simulink, and create a blank model, and save the model as Blinky. Go to the Modeling tab, and select Model Settings. Click on the hardware implementation, and select the hardware board of your choice that you want to work with. In my case, it is going to be an F280049C launchpad, and click on OK.
Now, add a pulse generator and scope block to the model and connect them. And set the period parameter of the pulse generator block to two seconds and pulse width to 50%. And keep the rest of the parameters with default settings. This will generate a pulse train of high and low signals of one second each, which we can see in the scope when you run the simulation.
We can use this signal to make an LED connected to the C2000 hardware blink. To do that, stop the simulation, and go to the library browser, where you can see the C2000 Microcontroller Blockset library. When you open the library, you can see the list of C2000 hardware series supported. If you go further under each of them, you will find the list of peripheral blocks available for that specific C2000 series.
In my case, since I have F280049C launchpad, I am going to use the blocks under the F28004X series. Let's open that and drag and drop the GPIO block into the Simulink model, and connect the input of the GPIO block to the output of the pulse generator block. Now I need to select the GPIO pin of the LED connected on the launchpad. You can find this in the launchpad user guide.
In my case, it is a GPIO 23, which is connected to the LED4. Set this GPIO number on the GPIO block, and click on Apply. Make sure that you have the toggle GPIO 23 unchecked.
Now, go to the Hardware tab and click on the Build, Deploy, and Start button. You can open the Diagnostic viewer to see what's happening after you click on Build, Deploy, and Start. As you can see, once you click on the Build, Deploy, and Start, the model starts building and generates code for the model and creates a Code Composer Studio project for the generated code and creates an executable, then downloads the executable to the hardware.
Once the executable is downloaded on the hardware successfully, you can see that the code is flashed on the hardware, and the LED starts blinking. Make sure you have only one TI C2000 device which is connected to the PC of the type you have configured the model for. If you have multiple TI C2000 hardwares connected to the PC, the deployment may fail.
With that, we come to the end of the video. To learn more about the capabilities of the C2000 Microcontroller Blockset, you can try out the examples available in the C2000 Microcontroller Blockset documentation. Thank you for your time. Thanks for watching.