You are currently viewing How to Interface LEDs with dsPIC30F4011 dsPIC Evaluation Board

How to Interface LEDs with dsPIC30F4011 dsPIC Evaluation Board

Spread the love

The DsPIC30F4011 Evaluation 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.

The Microchip dsPIC30F4011 Evaluation kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers.

LED (Light Emitting Diodes)

Light Emitting Diodes (LED) is the most commonly used components, usually for displaying pins digital states. Typical uses of LEDs include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.

Interfacing LED

Fig. 1 shows how to interface the LED to microcontroller. As you can see the Anode is connected through a resistor to GND & the Cathode is connected to the Microcontroller pin. So when the Port Pin is HIGH the LED is OFF & when the Port Pin is LOW the LEDis turned ON.

nterface LEDs with dsPIC30F4011 dsPIC Evaluation Board
Fig. 1 Interfacing LED to Microcontroller

Interfacing LED with dsPIC30F4011

We now want to flash a LED in dsPIC30F Evaluation Board. It works by turning ON a LED & then turning it OFF & then looping back to START. However the operating speed of microcontroller is very high so the flashing frequency will also be very fast to be detected by human eye.

The DsPIC30F4011 Evaluation Board has eight numbers of point LEDs, connected with I/O Port lines (PORTx.0 – PORTx.7) to make port pins high.

Pin Assignment with dsPIC30F4011

pin assignment for  Interface LEDs with dsPIC30F4011 dsPIC Evaluation Board

Circuit Diagram to Interface LED with dsPIC30F4011

circuit diagram for Interface LEDs with dsPIC30F4011 dsPIC Evaluation Board

Source Code

The Interfacing LED with dsPIC30F4011 program is very simple and straight forward, that uses a delay procedure loop based software delay. In C programs you cannot be sure of delay, because it depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes. The C program is developed with Mplab software & Microchip C30 Compiler.

C Program to switch ON and OFF LED using dsPIC

Title : Program to Blink LEDs

#define XTFREQ 5000000
#define Freq 7500
#define Offset ((XTFREQ/Freq)/2)
#define led1 PORTB
#define tled1 TRISB void delay();
unsigned long int i;
int main()
tled1 = 0x00;
led1 = 0x00;
led1 = 0xFF;
led1 = 0x00;
void delay(int x)
unsigned int k,l;

To compile the above C code you must need the Mplab software & Microchip C30 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 DsPIC30F4011 Evaluation Board.

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

Testing the LED with dsPIC30F4011

Give +9V power supply to dsPIC Evaluation Board; the LED is connected with dsPIC Evaluation Board.

When the program is downloading into dsPIC30F4011 Evaluation in Board, the LED output is working that the LED is ON some time period and the LED is OFF some other time period.

If you are not reading any output from LED, then you just check the jumper connections & check the LED is working. Otherwise you just check it 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.

☞More instructions are available in following articles,

dSPIC Evaluation Board

User Manual for DSPIC30F4011 Evaluation Kit

Creating & Debugging a Project in MPLAB using dsPIC30F

Leave a Reply

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