MEVIHUB

Led Blink Using TMS320F28335

Overview

In this tutorial, we will learn how to blink the LED using the TMS320F28335 microcontroller.

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

THEORY:

LEDs (LEDs) are the most commonly used components, usually to display the digital status of contacts.

The TMS320F28335 board has 4 LEDs connected to general-purpose DSP I / O contacts. The anode of each LED is connected to the ground, and the cathode of each LED is connected to the port via a 220-ohm resistor. To turn on a single LED, set the signal of the corresponding port to high.

General Purpose I / O Peripheral (GPIO) in the TMS320 Digital Signal Processor (DSP). The GPIO peripheral provides special general-purpose contacts that can be configured as inputs or outputs. When configured as an input, we can determine the status of the input by reading the state of the internal register. When configured as an output, we can write to the internal register to monitor the managed state on the output contact.

GPIO Connection

S.NoGPIOControl Card
1GPIO_3GPIO3

RESULT:

Hence by the above code, we have blinked the LED with the 1 GPIO Pins.

Final Code For Single Led Blink

/*
 * main.c
 *
 *  Created on: 16-Mar-2022
 *      Author: Admin
 */

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include FileS

void main(void)
{
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();

EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO3=0;
GpioCtrlRegs.GPADIR.bit.GPIO3=1;
GpioCtrlRegs.GPAPUD.bit.GPIO3=0;
EDIS;

while(1)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO3=1;
    DELAY_US(1000000);
}

}

Final Code For Multiple Led Blink

/*
 * main.c
 *
 *  Created on: 16-Mar-2022
 *      Author: Devilal
 */

#include "DSP28x_Project.h"   //Device headerfile

void main(void)

{
  InitSysCtrl();
   // gpio configuration
   EALLOW;

   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;   // input selection completed

   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;// input selection completed


  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;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO4=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO4=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO4=0;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO5=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO5=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO5=0;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO6=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO6=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO6=0;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO7=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO7=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO7=0;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO8=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO8=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO8=0;// input selection completed

  GpioCtrlRegs.GPAMUX1.bit.GPIO9=0;// selecting the gpio pin
  GpioCtrlRegs.GPADIR.bit.GPIO9=1;//1 mean output pin,0 mean input pin
  GpioCtrlRegs.GPAPUD.bit.GPIO9=0;// input selection completed


EDIS;
  while(1)
  {
      GpioDataRegs.GPACLEAR.bit.GPIO1=1; // turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO2=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO3=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO4=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO5=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO6=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO7=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPACLEAR.bit.GPIO8=1;// turns on the led;(1 means  turn on,0 means turns off)
      GpioDataRegs.GPASET.bit.GPIO9=1;// turns on the led;(1 means  turn on,0 means turns off)
      DELAY_US(1000000); //turns off after a delay of 1000000 microseconds
      GpioDataRegs.GPASET.bit.GPIO1=1;  // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO2=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO3=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO4=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO5=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO6=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO7=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPASET.bit.GPIO8=1; // turns off the led (1 means  turn off,0 means turns on)
      GpioDataRegs.GPACLEAR.bit.GPIO9=1; // turns off the led (1 means  turn off,0 means turns on)
      DELAY_US(1000000); //turns on after a delay of 1000000 microseconds



  }
}

Output Images

Exit mobile version