Overview

This is a simple project on the seven segment display interface with tms320f28335. The tutorial presents a simple example of printing numeric numbers on a seven-segment display. The tutorial task is to print numbers from 0 to 9 on a single seven-segment display. There are two types of seven-segment displays, Common Anode and Common Cathode.

Required Hardware Components

Hardware

  • Launchxl-F28379D
  • 7 Segment Display

Software:

  • Code Composer Studio

Specifications:

TMS320F28335 Microcontroller

On-chip memory

  1. 256K × 16 Flash, 34K × 16 SARAM
  2. Clock frequency: Up to 150 MHz (6.67-ns cycle time)
  3. Operating voltage: 1.9-V/1.8-V core, 3.3-V I/O design
  4. 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

Gpio Connection:

S.NoGpio_connectionDsp_connection
1.Gpio_01( output)Gpio_01( output)
2.Gpio_02( output)Gpio_02( output)
3.Gpio_04( output)Gpio_04( output)
4.Gpio_06( output)Gpio_06( output)
5.Gpio_07( output)Gpio_07( output)
6.Gpio_09( output)Gpio_09( output)
7.Gpio_10( output)Gpio_10( output)

 Block diagram:

About 7 segment display:

Seven segment displays are the output display device that provides a way to display information in the form of image or text or decimal numbers. It consists of seven segments of light-emitting diodes (LED s) which are assembled like numerical 8. Since seven segment displays can not form alphabets like X and Z, so they can not be used for the alphabet and they can be used only for displaying decimal numerical magnitudes. However, seven-segment displays can form alphabets A, B, C, D, E, and F, so they can also use for representing hexadecimal digits. The  Working of  Seven  Segment  Displays is explained below.

Common Cathode 7-segment Display

The Common Anode (CA) – In the common anode display, all the anode connections of the LED segments are joined together to logic “1”. The individual segments are illuminated by applying a ground, logic “0” or “LOW” signal via a suitable current limiting resistor to the Cathode of the particular segment (a-g).

Common Anode 7-segment Display

In general, common anode displays are more popular as many logic circuits can sink more current than they can source. Also note that a common cathode display is not a direct replacement in a circuit for a common anode display and vice versa, as it is the same as connecting the LEDs in reverse, and hence light emission will not take place.

Depending upon the decimal digit to be displayed, the particular set of LEDs is forward biased. For instance, to display the numerical digit 0, we will need to light up six of the LED segments corresponding to a, b, c, d, e and f. Then the various digits from 0 through 9 can be displayed using a 7-segment display as shown.

Step by step execution process:

Step 1: Initialize the GPIO pin(select the pin number).

Step 2: Select the pin as an output(means 1).

Step 3: Repeat steps 1 and 2 for selecting multiple pins.

Step 4: Connect the pins to the seven segments LED display according to the respective LED segments.

Step 5: Put CLEAR command for turning on the LED segment.

Step 6: Put SET command for turning off the LED segment.

Step 7: Set commands for displaying different digits.

Step 8: Keep a delay 1 second after each digit is displayed.

Step 9: Execute the final code and verify the output.

Final code:

#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
   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.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.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.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

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

  EDIS;
   
 while(1)
 
  {


 // 0
       GpioDataRegs.GPACLEAR.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPACLEAR.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO9=1;
       GpioDataRegs.GPASET.bit.GPIO10=1;
       DELAY_US(1000000);

// 1
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPASET.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPASET.bit.GPIO7=1;
       GpioDataRegs.GPASET.bit.GPIO9=1;
       GpioDataRegs.GPASET.bit.GPIO10=1;
       DELAY_US(1000000);
// 2
       GpioDataRegs.GPACLEAR.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPASET.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPASET.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);
// 3
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPASET.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);
// 4
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPASET.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPASET.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);
// 5
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPASET.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);
// 6
       GpioDataRegs.GPACLEAR.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPASET.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);
// 7
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPASET.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPASET.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPASET.bit.GPIO9=1;
       GpioDataRegs.GPASET.bit.GPIO10=1;
       DELAY_US(1000000);
// 8
       GpioDataRegs.GPACLEAR.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPACLEAR.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
        DELAY_US(1000000);
// 9
       GpioDataRegs.GPASET.bit.GPIO1=1;
       GpioDataRegs.GPACLEAR.bit.GPIO2=1;
       GpioDataRegs.GPACLEAR.bit.GPIO4=1;
       GpioDataRegs.GPACLEAR.bit.GPIO5=1;
       GpioDataRegs.GPACLEAR.bit.GPIO6=1;
       GpioDataRegs.GPACLEAR.bit.GPIO7=1;
       GpioDataRegs.GPACLEAR.bit.GPIO9=1;
       GpioDataRegs.GPACLEAR.bit.GPIO10=1;
       DELAY_US(1000000);


 }

}

Output Images

By Devilal

Leave a Reply

Your email address will not be published. Required fields are marked *