Home Code PIC16F877 flashing LED example

PIC16F877 flashing LED example

by shedboy71

This first example is the usual flashy LEDs example.

We will be introducing the development board we use (its the QL200 PIC development board), we will be using the mikroC pro for PIC compiler and we use the QL Programmer software that comes with the development board to program the PIC.

First of all , the development board. I chose this board as it had many features that I thought were suitable for myself as a beginner, it has a variety of LEDs, 4×4 key matrix, Seven segment display on board, a remote control IC, buzzer and many more features. You can hook up an LCD to a connector, there are areas for various 3rd party ICs such as EEPROMs, RTC chip, D/A convertor and so on.

The kicker for me was that this development board supports many PIC chips, mine has a PIC16F877A on it. Here is a picture of the board

QL200 development board

QL200 development board

Code

The example as stated was written using the mikroC PRO for PIC compiler. There are LEDs connected to PORTA, PORTB and PORTC, we will flash them on and off

 

[codesyntax lang=”c”]

void main()
{


TRISA = 0x00; // Sets all pins in PORTA as output
PORTB = 0xFF;
TRISB = 0x00; // Sets all pins in PORTB as output
PORTB = 0xFF; // Set
TRISC = 0x00; // Sets all pins in PORTC as output
PORTC = 0xFF;

do // To set infinite loop
{
Delay_ms(300); // 300 mili seconds delay
PORTA = 0x00;
PORTB = 0x00;
PORTC = 0x00;
Delay_ms(350); // 350 mili seconds delay
PORTA = 0xFF;
PORTB = 0xFF;
PORTC = 0xFF;

}while(1); // To set infinite loop
}

[/codesyntax]

 

Compile this and you will get a hex file created. I needed to use the programmer that came on the CD with the board. You can see this in the image below.

Fairly simple operation, connect your board to your PC using the USB cable supplied, select the programmer using Options -> Select Programmer. Make sure the Chip Select is set to the correct chip. Click on Load, locate your hex file from earlier, then click on prog to program your PIC. Now you should see the LEDs flashing on and off.

QL -programmer

QL -programmer

Links

QL200 PIC Microchip MCU Development Board & USB Programmer Kit 1602 LCD ICD on Amazon UK

QL200 PIC Microchip MCU Development Board USB Programmer Kit 1602 LCD ICD on AMAZON US

Share

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More