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:

  • DSP controller board (TMS320F28335)
  • JTAG, XDS100V2 board

Specifications:

TMS320F28335 Microcontrollers

On-chip memory

  • 256K × 16 Flash, 34K × 16 SARAM
  • Clock frequency: Up to 150 MHz (6.67-ns cycle time)
  • Operating voltage: 1.9-V/1.8-V core, 3.3-V I/O design
  • Six-channel DMA controller (for ADC, McBSP, ePWM, XINTF, and SARAM)

Communications peripherals

  • Up to 2 CAN modules
  • Up to 3 SCI (UART) modules
  • Up to 2 McBSP modules (configurable as SPI)
  • One SPI module
  • One Inter-Integrated Circuit (I2C) bus

Analog subsystem

  • 12-bit ADC, 16 channels
  • 80-ns conversion rate
  • 2 × 8 channel input multiplexer
  • Two sample-and-hold
  • Single/simultaneous conversions
  • Internal or external reference

Enhanced control peripherals (EPWM)

  • Up to 18 PWM outputs
  • Up to 6 HRPWM outputs with 150-ps MEP resolution

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

  • GPIO0 to GPIO63 pins can be connected to one of the eight external core interrupts
  • –Up to 18 PWM outputs
  • –Up to 6 HRPWM outputs with 150-ps MEP

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

Three 32-bit CPU timers

This image has an empty alt attribute; its file name is TMS320F28335-removebg-preview.png

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.

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

By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: