How to Configure GPIOs as Inputs on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 2 - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 4:22
Loaded: 3.77%
Stream Type LIVE
Remaining Time 4:22
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 4:22

    How to Configure GPIOs as Inputs on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 2

    From the series: Getting Started with C2000 Microcontroller Blockset

    Learn how to configure the GPIO peripherals of C2000™ MCUs as digital inputs using C2000 Microcontroller Blockset in Simulink®. You’ll learn how you can configure a GPIO pin on the C2000 MCUs as digital input and read the status of a switch connected to the GPIO pin on an F28379D LaunchPad™.

    Published: 13 Jan 2025

    Welcome to the video on General Purpose Input Output, GPIO. GPIO refers to a set of pins on a microcontroller that can be programmed to either read digital input or output digital signals. GPIO pins can be used to connect and control various external devices, such as sensors, buttons, LEDs, motors, and more. They provide a flexible way to interface with the physical world and enable communication between the microcontroller.

    Here in Simulink, there are two blocks available for it. One is the digital input block, and the other one is digital output block. In this video, we are going to see about the digital input block. Before getting started, I have my hardware setup in this fashion, basically a switch and resistor in between ground and 3.3 volt. And I have the wire connected to the GPIO pin.

    And I 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.

    Once you have your board selected, a new hardware tab would be visible in your Simulink toolstrip, displaying the selected hardware board. Now your model is configured for your Delfino F28379D Launchpad.

    Having configured my model, let's get started. You can click on the Library Browser and, under C2000 Microcontroller Blockset, can expand the F2837xD, and you could see the peripherals that are available for this launchpad.

    Now I am bringing in the GPIO digital input block. As I said previously, the digital input block is used to read a signal via particular pin. How do I know that which pin is being read? For that, you can configure the digital input block by double clicking on it. And you can select the GPIO pin by selecting the corresponding GPIO group over here.

    Since there are 120 pins available, it is classified into multiple groups, that is, from GPIO0 to GPIO7 is categorized into one group. And GPIO8 to 15 is categorized into other group and so on.

    So to select a particular pin, you can select that particular group and select on the pin. Say, for example, if I want to select the GPIO pin 31, you can click on this group and select that particular pin alone.

    Here, GPIO31 is selected. The rate at which the selected GPIO pin is being read is mentioned over here in the sample time. Here, the pin is read at a rate of 0.1 second. That is, for every 0.1 second, the value gets updated via this block.

    And the format in which it is stored in the computer can be selected by this parameter, that is, the data type. And there are multiple options available from double to Boolean. And you can leave it to auto so the Simulink model automatically configures according to the input value.

    After configuring all the parameters over here, you can click on OK. Now, to view the read input signal, you can add a scope block. Double click on the canvas and type in "scope" to bring in a block.

    You can either bring that from the library browser over here, or you can directly Double click on the canvas over here. Now, let me run the model in Monitor and Tune mode. Monitor and Tune enables you to monitor the signal, and you can modify the parameters of the model, which immediately gets reflected into your target hardware. This Monitor and Tune mode would be useful in debugging your model.

    Now you could see the model is running, and the GPIO toggles from 0 to 1 whenever I press the switch. And that's all about the digital input block. Thanks for watching this video.

    Up Next:

    View full series (16 Videos)

    View more related videos