You are currently viewing How to Interface 7SEG with dsPIC30F4011 – dsPIC Development Board

How to Interface 7SEG with dsPIC30F4011 – dsPIC Development Board

Spread the love

The dsPIC30F4011 Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s dsPIC30F (dsPIC30F4011), Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers. In this post ,We can see how to interface 7SEG with dsPIC30F4011 Development board .

Seven Segment Display

A seven segment display is the most basic electronic display device that can display digits from 0-9. The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. They are laid out as a squared-off figure β€˜8’.

Interfacing Seven Segment Display

Fig. 1 shows how to interface the seven segments with microcontroller. A seven segment is generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA).

Interfacing Seven Segment with dsPIC30F4011

We now want to display a four digit number in dsPIC30F Development Board by using seven segment displays. The seven segment display is connected with dsPIC30F4011 microcontroller.

In dsPIC30F Development Kit, 4 nos. of common anode seven segment displays are controlled by seven segment drivers.

Pin Assignment for Interfacing 7 Segment Display with dsPIC30F4011

Circuit Diagram to Interface the 7 segment display with dsPIC30F

Source Code

The Interfacing seven segment displays with dsPIC30F4011 program is very simple and straight forward, which display a four digit number in seven segment display .The C programs are developed in Mplab software. Here we are increment a counter and display this value loaded into seven segment driver in dsPIC30F Development Board.

C Program to 7 Segment Display using dsPIC30F

Title : Program to Seven Segment display

#include "p30f4011.h"

#include "delay.c"


#define Single LATBbits.LATD3
#define Ten LATBbits.LATD2
#define hundred LATBbits.LATD1
#define Thousand LATBbits.LATD0 int x,temp;

unsigned char thou=0,hun=0,ten=0,single=0;
unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90};
unsigned char n=1;

void hex2dec(unsigned char);
void send_seg(unsigned char,unsigned char, unsigned char,unsigned char);
void delay(unsigned char);

int main()

TRISD = 0x0000;
TRISB = 0x0000;
ADPCFG = 0xffff;

if(x == 300)

void send_seg(unsigned char thou,unsigned char hun, unsigned char ten,unsigned char single)


temp=(temp & 0)| 0x0e00 | a[single];
PORTB=temp; n=2;

else if(n==2)

temp=(temp & 0)| 0x1600 | a[ten];

else if(n==3)

temp=(temp & 0)| 0x1a00 | a[hun];
PORTB=temp; n=0;


temp=(temp & 0)| 0x1c00 | a[thou];

To compile the above C code you must need the Mplab software and Microchip C30 C Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without dsPIC30F Development Board

The PICKIT2 software is used to download the hex file into your microcontroller IC dsPIC30F4011 through USB.

Testing the I2C – SEVEN SEG with dsPIC30F

Give +9V power supply to dsPIC30F Development Board; the four seven segment display is connected with the dsPIC30F Development Board. First check the entire seven segments LED’s are properly working or not. Here we are display just 1234 in four seven segment. The entire seven segments receive it through I2C & display it in order.

If any data is not coming in seven segments, then you just check the entire seven segments LED’s are working or not. Change the seven segment driver IC & Check the I2C connections. Check the four seven segments connections. Otherwise you just check the code with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

  • How to Create & Debug a Project in Mplab using dsPIC30F.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.