Overview

This article is going to teach you all the steps required by a beginner to interface a Push Button with TMS320F28379D. In this article, you are going to learn about how to make a pin input in TMS320F28379D and how to read a Digital pin in TMS320F28379D. Things you should have before continuing.

Required Hardware Components

Hardware

  • Launchxl-f28379d
  • Push button
  • Led

Software:

  • Code Composer Studio

Bill of Materials

S.NoCOMPONENTSDESCRIPTIONQUANTITYlink
1Launchxl-f28379d Launchxl-f28379d 1https://www.amazon.com/Arduino-A000066-ARDUINO-UNO-R3/dp/B008GRTSV6
2LEDLED1ader-em18-board-with-serial-ttl-interfacing-125-khz-through-a-rs232-converter-to-pc/?src=google&kwd=&adgroup={adgroup}&devicec&campaign={campaign}&adgroup={adgroup}&keyword=&matchtype=&gclid=CjwKCAjw49qKBhAoEiwAHQVTo-i85TwixHnJAFNHLfwUknLhBVYloMe3ECBLmMFtUFrk8qGBxO0vzhoCIAQQAvD_BwE
6Jumper WiresJumper Wires40https://www.flipkart.com/arduino-female-male-dupont-20cm-jumper-wire-40pcs-interconnect-electronic-hobby-kit/p/itmf8e5ezvkequ3h?pid=EHKF8DVBG9BXZHHH&lid=LSTEHKF8DVBG9BXZHHHUGSG9J&marketplace=FLIPKART&cmpid=content_electronic-hobby-kit_14498130132_u_8965229628_gmc_pla&tgi=sem,1,G,11214002,u,,,543116155366,,,,c,,,,,,,&ef_id=CjwKCAjwndCKBhAkEiwAgSDKQYwKr3euuMpKCLDJnf-

Introduction

In this project, I am going to control the On-Board LED from a Push Button. By this, you are going to learn about how to read and write a pin digitally.

Circuit Diagram

Gpio Connection

GPIO_34OUTPUT_LED
GPIO_67INPUT_PUSH_BUTTON

Step_1

Configure GPIO Pins For OUT_Put Pin

    GPIO_setPinConfig(DEVICE_GPIO_PIN_LED2);
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU1);

Configure GPIO Pins For OUT_Put Pin

    // select input gpio pin
    GPIO_setPinConfig(GPIO_67_GPIO67);
    GPIO_setDirectionMode(67, GPIO_DIR_MODE_IN);
    GPIO_setPadConfig(67, GPIO_PIN_TYPE_PULLUP);  //  Pull-up enable for input
    GPIO_setMasterCore(67, GPIO_CORE_CPU1);

Create function for gpio configurations

{
    // select input gpio pin
    GPIO_setPinConfig(GPIO_67_GPIO67);
    GPIO_setDirectionMode(67, GPIO_DIR_MODE_IN);
    GPIO_setPadConfig(67, GPIO_PIN_TYPE_PULLUP);  //  Pull-up enable for input
    GPIO_setMasterCore(67, GPIO_CORE_CPU1);

    // select output gpio pin

    GPIO_setPinConfig(DEVICE_GPIO_PIN_LED2);
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU1);

}

Turn ON led Command (Set 1 for ON)

GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);

Turn OFF Led Command (Set 0 for OFF)

GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);

Final Code

/*
 * main.c
 *
 *  Created on: 26-Nov-2021
 *      Author: Devilal
 */




#include "stdio.h"
#include "string.h"
#include "stdlib.h"

#include "F28x_Project.h"
#include "F2837xD_device.h"
#include "F2837xD_Examples.h"

#include "device.h"
#include "driverlib.h"

void gpio_init();

void main(void)
{
    Device_init();
    Device_initGPIO();
    gpio_init();
    while(1)
    {
        if(GPIO_readPin(67) == 0)
        {
            GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
            DEVICE_DELAY_US(10000);
            GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
            DEVICE_DELAY_US(10000);
        }
        if(GPIO_readPin(67)==1)
        {
            GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
            DEVICE_DELAY_US(10000);
        }
    }

}


void gpio_init()
{
    // select input gpio pin
    GPIO_setPinConfig(GPIO_67_GPIO67);
    GPIO_setDirectionMode(67, GPIO_DIR_MODE_IN);
    GPIO_setPadConfig(67, GPIO_PIN_TYPE_PULLUP);  //  Pull-up enable for input
    GPIO_setMasterCore(67, GPIO_CORE_CPU1);

    // select output gpio pin

    GPIO_setPinConfig(DEVICE_GPIO_PIN_LED2);
    GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU1);

}

OUTPUT

By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: