How to Configure GPIOs as Outputs on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 3
From the series: Getting Started with C2000 Microcontroller Blockset
Learn how to configure the GPIO peripherals of C2000™ MCUs as digital outputs using C2000 Microcontroller Blockset in Simulink®. Learn how you can configure a GPIO pin on the C2000 MCUs as digital output, as well as write data to a digital output pin and blink the LED connected to the GPIO pin on an F28379D LaunchPad™.
Published: 13 Jan 2025
Welcome to the continuation video on GPIO. In this video, let's look into the digital output block. Before getting started, let me have my board connected to the laptop in which MATLAB is installed. Now let me have my model configured for my hardware board. In my case, it's F28379D launchpad. So by pressing Control-E, navigating to the Hardware Implementation, let me choose the same. And click on OK. Having configured my model for my hardware board, let's get started.
Go to the Library browser. And under C2000 Microcontroller Blockset, expanding on F2837xD, let me drag the Digital Output block into this white space called canvas. You can either add a block by this manner, or you can double-click on the white space, type in "digital output," and you could see this digital output block is under F2837xD. You can click on that to add in a block.
Double-clicking on this block, open its block parameter. So to configure this particular digital output block for a particular GPIO pin, you can select the GPIO pin by clicking on the associated GPIO group. To select the GPIO pin 31, which is the onboard blue LED on F28379D launchpad, let me choose GPIO24 to GPIO31 group and select this particular pin. When you click on a particular pin, another parameter called Toggle appears.
So for a digital value, there are two states, 0 and 1. If the current value is 0, by clicking on this Toggle, the output flips to 1. If the current value is 1, it toggles to 0. So this is the functionality of this parameter. And the rate at which this toggling happens depends on the associated block, that is the block connected to it. Say, for example, if I am having a constant block, it outputs a constant value 1. And double-clicking on it opens its block parameter.
Let the constant value be 1 and the sample time be 0.1. So for every 0.1 second, the digital output block toggles its value. Initially, it's 1. So after 0.1 second, it would be 0. And for the next 0.1 second, it would be 1. And this keeps happening. Now, let me click on Build, Deploy & Start. When you click on Build, Deploy & Start, code is being generated for your model, and the application is deployed into your microcontroller. Now you have a standalone application that is running on your microcontroller. And you could see the LED toggling as expected. So this is all about the GPIO digital output block. Thank you.