MEVIHUB

Button Interfacing Using TMS320F28335

Overview

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

SOFTWARE: 

Code Composer Studio

HARDWARE REQUIRED:

Specifications:

TMS320F28335 Microcontrollers

On-chip memory

Communications peripherals

Analog subsystem

Enhanced control peripherals (EPWM)

•16-bit or 32-bit External Interface (XINTF)

Up to 88 individually programmable, multiplexed GPIO pins with input filtering

Three 32-bit CPU timers

Schematic Diagram

Gpio Connection

S.NoGpio_connectionDsp_connection
1.Gpio_01( output)Gpio_01( output)
2.Gpio_02( output)Gpio_02( output)
3.Gpio_03( output)Gpio_03( output)
4.Gpio_04( input)Gpio_04( input)
5.Gpio_05( input)Gpio_05( input)
6.Gpio_06( input)Gpio_06( input)

 Block diagram:

Step by step execution process:

  • Step 1: Initialise the Gpio pin(select the pin number).
  • Step 2: Select the pin as output(means 1) or input(means 0).
  • Step 3: Repeat steps 1 and 2 for selecting multiple pins.
  • Step 4:Select the button GPIO pin as an input pin and give a command for button status
  • Step 5: Use the “if” and “else” statements to control the output (ON and OFF ) states
  • Step 6:If the button is pressed (ON ) set the CLEAR command to turn On the output
  • Step 7: If the button is not pressed then the SET command to stable
  • Step 8: Now execute the final code and verify the output.
https://mevihub.com/wp-content/uploads/2022/04/button-interface-tms320f8335-1.mp4

Final Code

#include "DSP28x_Project.h"   //Device headerfile*

#define __TRUE 		1
#define __FALSE		0
int button_status1,button_status2,button_status3;

void main(void)

{
  InitSysCtrl();
   // gpio configuration
   EALLOW;


   // OUTPUT
		GpioCtrlRegs.GPAMUX1.bit.GPIO1	=0;  // selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO1	=1;  //1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO1	=0;  // 0 PULL UP ENABLED 1  PULL UP DISABLE

		GpioCtrlRegs.GPAMUX1.bit.GPIO2	=0;// selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO2	=1;//1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO2	=0;// 0 PULL UP ENABLED 1  PULL UP DISABLE


		GpioCtrlRegs.GPAMUX1.bit.GPIO3	=0;// selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO3	=1;//1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO3	=0;// 0 PULL UP ENABLED 1  PULL UP DISABLE

		// input pin selection

		GpioCtrlRegs.GPAMUX1.bit.GPIO4	=0;// selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO4	=0;//1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO4	=0;// 0 PULL UP ENABLED 1  PULL UP DISABLE

		GpioCtrlRegs.GPAMUX1.bit.GPIO5	=0;// selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO5	=0;//1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO5	=0;// 0 PULL UP ENABLED 1  PULL UP DISABLE

		GpioCtrlRegs.GPAMUX1.bit.GPIO6	=0;// selecting the gpio pin
		GpioCtrlRegs.GPADIR.bit.GPIO6	=0;//1 mean output pin,0 mean input pin
		GpioCtrlRegs.GPAPUD.bit.GPIO6	=0;// 0 PULL UP ENABLED 1  PULL UP DISABLE

		EDIS;


    while(1)
     {

       //   here read input data when you press the button read the button status
         // when you press the button check the status
         // if button status == 0 then turn of the led
        // else button status == 1 then turn on the led


         button_status1 = GpioDataRegs.GPADAT.bit.GPIO4;
         button_status2 = GpioDataRegs.GPADAT.bit.GPIO5;
         button_status3 = GpioDataRegs.GPADAT.bit.GPIO6;

        if(button_status1 == __FALSE)
        {
        GpioDataRegs.GPASET.bit.GPIO1=1;        
       }

        else
        {
        GpioDataRegs.GPACLEAR.bit.GPIO1=1;      
       }

        if(button_status2 == __FALSE)
        {
        GpioDataRegs.GPACLEAR.bit.GPIO2=1;
        }

        else
        {
        GpioDataRegs.GPASET.bit.GPIO2=1;
        }

        if(button_status3 == __FALSE)
        {
        GpioDataRegs.GPACLEAR.bit.GPIO3=1;
        }

        else
        {
        GpioDataRegs.GPASET.bit.GPIO3=1;

        }

     }

}

Output Images

Exit mobile version