Você está na página 1de 30

IES-PIC16xx

PIC16F877A BASED EMBEDDED DEVELOPMENT BOARD

Product datasheet

No.34/A PUTHU AMMAN KOVIL STREET, THACHANALLUR, TIRUNELVELI-627 358.

Mob no: +91-9042363612, +91-9840838264


E-mail: ielecsystems@gmail.com

Revision History
Revision History
Revision

Author

Date

Description

1.0

RAM KUMAR.D

2014/07/27

First Release

Content
Si.no
1
2
3
4
5
6
7

Topics
INTRODUCTION
ABOUT PIC16F877A BASED EMBEDDED DEVELOPMENT BOARD.
THE PIC16F877A PROJECT BOARD HARDWARE DETAILS
BLOCK DIAGRAM OF BOARD.
SYSTEM REQUIREMENT
WORKING PROCEDURE OF SOFTWARE.
SAMPLE C PROGRAM.

Page no
2
2
3
4
6
6
19

1. INTRODUCTION:
DEDICATED TO USERES:::
Embedded technology is mainly used for improving the creativity. We hope this product and presentation
about PIC16F877A based embedded platform tasks will definitely help to people who are very much
interested in this embedded technology.

2. ABOUT PIC16F877A BASED EMBEDDED DEVELOPMENT BOARD.


In the product all peripherals interface by user configurable so it is useful model for students can do develop
their own application. The board was supported to pic16f877a chips which have 4kB Flash program memory
for dumping user programs. Its have been 33 I/O terminal burg connector extensions and 2 pair of Vcc,Gnd
extended by burg connector for external usage.
This document contains the information about how to work with IES-PIC16xx development board, how
to programming the Flash of PIC16F877A MCU and some basic samples using EMBEDDED C language.

IES-PIC16xx Rev: 1.0

Page 2of 30

HARDWARE DETAILS
3. THE PIC16F877A EMBEDDED BOARD HARDWARE DETAILS.
8-LED ARRAY

PICKIT3
ISP PORT

ISP
PORT

FRC
CONNECTOR

POWER ON/OFF
SWITCH

I2C
EEPRO
5VDC
INPUT

UART
PORT
ISP/IO MODE

8-INPUT
SPDT
SWITCH

SWITCH

MAX232

BUZZER

4-DIGIT
SEVEN
SEGMENT

PIC16F877

RELAY
EXTENSION

I2C RTC
MOTOR
PORT

RELAY
CRYSTAL OSC
20 MHz

LM35

12V
STEPPER
MOTOR
DRIVER

IO PORT
EXTENSION
ALPHANUMERIC
16*2 LCD

4X4 MATRIX
KEY

RESET
BUTTON

FLASH DOWN/RUN
SWITCH

Figure -3.1 PIC16F877A embedded development block diagram.

IES-PIC16xx Rev: 1.0

Page 3 of 30

BLOCK DIAGRAM OF BOARD.


4. BLOCK DIAGRAM OF BOARD.
The block diagram of PIC16xx based embedded development board.
I/O BURG
EXTENSION

PIC16F877A
MICROCONTROLLER

POWER
SUPPLY

ADC

POWER ON
RESET

4X4MATRIX
KEY PAD
LM35 TEMP
SENSOR
8-SWITCH
ARRAY

SERIAL
DRIVER

PWM

8-LED
ARRAY
BUZZER
RELAY

I2C BURG EXTENSION

I2C
RTC

4KB FLASH

OUTPUT BURG EXTENSION

INPUT BURG EXTENSION

I/O

FLASH
SELECTION

I2C
EEPROM

4 DIGITS SEVEN
SEGMENT
STEPPER MOTOR
DERIVER
16*2-LCD
ALPHANUMERIC

Figure -4.1 PIC16xx based embedded development block diagram.

4.1 POWER SUPPLY.


Power supply was placed on bottom of the trainer. Its give +5v/0.5A and
+12V/0.5A. Its have the following user essential features.
Features
Stabilized output, low ripple and low interference.
High efficiency and low energy consumption.
Power status indicated by led monitor.
POWER SUPPLY SPECIFICATION
Input : 110-240V AC 50-60Hz.
Output: DC Outputs +5V / 0.5A,+12V/0.5A Regulated.

IES-PIC16xx Rev: 1.0

Page 4 of 30

BLOCK DIAGRAM OF BOARD.


4.2 PIC16F877A (8Bit microcontroller).

FEATURES
Timer0: 8-bit timer/counter with 8-bit prescaler.
Timer1: 16-bit timer/counter with prescaler,can be incremented during Sleep via external
crystal/clock.
Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
Two Capture, Compare, PWM modules.
o Capture is 16-bit, max. Resolution is 12.5 ns.
o Compare is 16-bit, max. Resolution is 200 ns.
o PWM max. Resolution is 10-bit.
Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave).
Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address
detection.
Parallel Slave Port (PSP) 8 bits wide with external RD, WR and CS controls (40/44-pin only).
Brown-out detection circuitry for Brown-out Reset (BOR).
10-bit, up to 8-channel Analog-to-Digital Converter (A/D).
Brown-out Reset (BOR).
Analog Comparator module with:
- Two analog comparators.
- Programmable on-chip voltage reference(VREF) module.
- Programmable input multiplexing from device inputs and internal voltage reference.
- Comparator outputs are externally accessible.
100,000 erase/write cycle Enhanced Flash program memory typical.
1,000,000 erase/write cycle Data EEPROM memory typical.
Data EEPROM Retention > 40 years.
Self-reprogrammable under software control.
In-Circuit Serial Programming (ICSP) via two pins.
Single-supply 5V In-Circuit Serial Programming.
Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation.
Programmable code protection.
Power saving Sleep mode.
Selectable oscillator options.
In-Circuit Debug (ICD) via two pins.

IES-PIC16xx Rev: 1.0

Page 5 of 30

BLOCK DIAGRAM OF BOARD.


4.3 SERIAL DRIVER.
Serial driver is designed by Max232 mainly to communicate between PC and
development board. It will convert TTL to Rs232 logic and Rs232 logic to TTL.It is equivalent to Mc1488
and Mc1489. Max232 and P89c51 chip was coupled by Txd and Rxd signals which are twisted together.

4.4 I /O PORT TERMINALS.


All 33 I/O port lines terminated by screw type extension connector for to
be implement a new application.

4.5 POWER ON RESET.


Initially when power is switched on the system will get reset. This
is called power on reset. If we think system reset is unusual case, then press reset button or power switch
OFF and ON. This is done by capacitor discharge section.

4.6 FLASH SELECTION.


Slide switch is provided for16kb flash programming access and LED for status
of programming (OFF) or execution (ON).Program is downloaded from computer through serial port
when slide switch down along with pressing Reset key.
If we want program execution, then put switch slide up and press Reset key.

5. SYSTEM REQUIREMENT:
The minimum system configuration is as follows.
A desktop or laptop computer with Intel Pentium or an equivalent processor (running a 32-bit
Microsoft operating system).
Windows XP or Windows Vista operating system with service pack.
At least 1GB free space on the hard drive.
At least 512Kb RAM.
At least one standard serial communication port COM1 as must.
A CD/DVD drive should be need for beginning the software installation.

6. WORKING PROCEDURE OF SOFTWARE.


This board chip support hex file only so that the following softwares are needed as (i). MPLAB IDE AND
CCS (Custom computer services) compiler for to creating Hex files using EMBEDDED C language.
(ii). PICpgm ISP (In Serial/System Programmer) this for to download the Hex file from system to chip
through RS232 cable.

IES-PIC16xx Rev: 1.0

Page 6 of 30

WORKING PROCEDURE OF SOFTWARE.


Working Flow of MPLAB8.3 IDE (included simulation):
MPLAB IDE contains edit, link, compile, and debug for PIC microcontroller application.

Create a project file & source file

Add a source file to project file

These three steps


for target
file creation(.hex).

Build a project file

Simulate the project using Debug


These two steps for
simulation.

Debug Using MPLAB SIM

Figure -6.1 Flow diagram of working procedures.


This procedure was one time procedure for all the exercise except simulation and hardware connection.

IES-PIC16xx Rev: 1.0

Page 7 of 30

WORKING PROCEDURE OF SOFTWARE.


6.1: Creating the Project.
To start IDE, go to
START All Programs MPLAB IDE v8.30 click on MPLAB IDE v8.30 or click on desktop shortcut
MPLAB IDE v8.30 icon.

To start the MPLAB IDE software and produce window similar to shown.

Select Project and click Project wizard

IES-PIC16xx Rev: 1.0

Page 8 of 30

WORKING PROCEDURE OF SOFTWARE.


The following window will appear.

Click on Next and select device as PIC16F877A then click on Next after this
The following window will appear.

The same following option should be selected for Embedded C programs


development. Then click on Next, after this the following window will appear.

IES-PIC16xx Rev: 1.0

Page 9 of 30

WORKING PROCEDURE OF SOFTWARE.

Browse the project directory and give project file name without extension. Click
on Next and Next. Finally the following summary window will appear.

Check out the all information regarding your target and click on Finish.
After this project file was created on project directory.

IES-PIC16xx Rev: 1.0

Page 10 of 30

WORKING PROCEDURE OF SOFTWARE.


Finally the following window will show.

6.2: Creating Source/application file.


Select File and click New

IES-PIC16xx Rev: 1.0

Page 11 of 30

WORKING PROCEDURE OF SOFTWARE.


Untitled Notepad will appear. Here you can type the C program or edit the example C program as you like
and save with extension must.

Finally the following window will appear.

IES-PIC16xx Rev: 1.0

Page 12 of 30

WORKING PROCEDURE OF SOFTWARE.


6.3: Adding Source/Application file to the project.
Right click on Source file and left click on Add files.

Now Add Files to project window will appear. Here browse the source/application file
directory and open it for adding to project.

IES-PIC16xx Rev: 1.0

Page 13 of 30

WORKING PROCEDURE OF SOFTWARE.


6.4: Building the Program (Compilation).
Click on Project tab pull down menu and click to Build All for program syntax Compilation.

Finally Output window will appear with error information of the program syntax. If
BUILD SUCCEEDED source file name.hex file was created on project directory. This is a target of
hardware file for downloading.

IES-PIC16xx Rev: 1.0

Page 14 of 30

WORKING PROCEDURE OF SOFTWARE.


6.5: PICPgm Programmer Procedure.
To start Programmer before ensure the ISP switchs (4-pin dip switch & SW2) in ISP mode and go to
START All Programs PICPgm Programmer click on PICPgm Programmer or click on desktop
shortcut PICPgm Programmer icon.

To start the PICPgm Programmer software and produce window similar to shown.

If hardware properly could in ISP mode the programmer fined device information and display in device
information window other else its shown as unknown.

IES-PIC16xx Rev: 1.0

Page 15 of 30

WORKING PROCEDURE OF SOFTWARE.


In the File tab pull down menu, Load HEX file to be selected or click on Browse.

After this Open Window will appear then in the browsing window chosen directory and target file
(source file name.hex). The file is opened and loaded to the code memory buffer (Not hardware).

IES-PIC16xx Rev: 1.0

Page 16 of 30

WORKING PROCEDURE OF SOFTWARE.


In the Command tab pull down menu, Program PIC to be selected.

By selecting Program PIC option. It starts programming and screen appear like this. The Red color led
is glowing at the time of programming.

IES-PIC16xx Rev: 1.0

Page 17 of 30

WORKING PROCEDURE OF SOFTWARE.


It erasing, programming and verifies written program. Finally green color
programming window appear in few seconds with message of programming finished successfully.
Otherwise click on Log tab menu. Its shown what is done now. Now program downloading is over.

In the hardware ISP mode 4-dip switch changed to down position and SW2 switch is changed to RUN
mode for program execution.

IES-PIC16xx Rev: 1.0

Page 18 of 30

SAMPLE C PROGRAM
7. SAMPLE C PROGRAM.
7.1-LED Interface:::
This program for toggling the LED using PORT B.

#include<16f877.h> // Device header file


#use delay(clock=20000000) // Configure the crystal Clock.
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) //configure the RS232
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT //Config Bits
unsigned int i=0x55;
void main()
{
while(1)
{
i=~i;
output_b(i);
delay_ms(500);
}
}

7.2-SWITCH Interface:::
This program for switch interfacing with LED. Switch using PORT D and LED using PORT B.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
unsigned char i;
void main()
{
while(1)
{
i=input_d();
output_b(i);
}
}

IES-PIC16xx Rev: 1.0

Page 19 of 30

SAMPLE CPROGRAM
7.3-4x4 Matrix Key Interface
This program for 4X4 Matrix key interface. 4 columns connected to the PORT-B and 4-rows connected
to the PORT-D.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
unsigned int a;
void main()
{
output_b(0x0f);
output_d(0x0);
printf("\n\r 4X4 Key Interface");
while(1)
{
output_d(0x0e);
a=input_b();
if((a & 0x0f)!=0x0f);
{
switch(a&0x0f)
{
case 0x0e:putc('0');
break;
case 0x0d:putc('1');
break;
case 0x0b:putc('2');
break;
case 0x07:putc('3');
break;
}
}
output_d(0x0d);
a=input_b();
if((a & 0x0f)!=0x0f);
{
switch(a&0x0f)
{
case 0x0e:putc('4');
break;
case 0x0d:putc('5');
break;
case 0x0b:putc('6');
break;
IES-PIC16xx Rev: 1.0

Page 20 of 30

SAMPLE C PROGRAM
case 0x07:putc('7');
break;
}
}
output_d(0x0b);
a=input_b();
if((a & 0x0f)!=0x0f);
{
switch(a&0x0f)
{
case 0x0e:putc('8');
break;
case 0x0d:putc('9');
break;
case 0x0b:putc('A');
break;
case 0x07:putc('B');
break;
}
}
output_d(0x07);
a=input_b();
if((a & 0x0f)!=0x0f);
{
switch(a&0x0f)
{
case 0x0e:putc('C');
break;
case 0x0d:putc('D');
break;
case 0x0b:putc('E');
break;
case 0x07:putc('F');
break;
}
}
}
}

IES-PIC16xx Rev: 1.0

Page 21 of 30

SAMPLE C PROGRAM
7.4-Seven Segment Interface:::
This program for seven segment interface. PORT-C used was segment selection. PORD-D used was
segment displayed.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
unsigned int led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90},i;
void main()
{
output_d(0x00);
output_c(0x00);
while(1)
{
output_c(0x01);
output_d(0x88);
delay_ms(1);
output_c(0x02);
output_d(0x80);
delay_ms(1);
output_c(0x04);
output_d(0xc6);
delay_ms(1);
output_c(0x08);
output_d(0xc0);
delay_ms(1);
}
}
7.5-Buzzer Interface:::
This program for Buzzer interface using PORT-D0.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT

IES-PIC16xx Rev: 1.0

Page 22 of 30

SAMPLE C PROGRAM
void main()
{
output_d(0x00);
top:
output_high(PIN_d0);
delay_ms(500);
output_low(PIN_d0);
delay_ms(500);
goto top;
}
7.60-Reley Interface:::
This program for Relay interface using PORT-D0.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
void main()
{
output_d(0x00);
top:
output_high(PIN_d0);
delay_ms(500);
output_low(PIN_d0);
delay_ms(500);
goto top;
}
7.7-Stepper Motor Interface:::
This program for stepper motor interfacing using PORT-D.

#include<16F877.h>
#use delay(clock=20000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT

IES-PIC16xx Rev: 1.0

Page 23 of 30

SAMPLE C PROGRAM
void main()
{
while(1)
{
output_d(0xf9);
delay_ms(10);
output_d(0xf5);
delay_ms(10);
output_d(0xf6);
delay_ms(10);
output_d(0xfa);
delay_ms(10);
}
}

7.8-LCD Interface:::
This program for for 16x2 LCD.
PORT-E0- used as RS pin.
PORT-E1-used as R/W pin.
PORT-E2-used as E pin.
PORR-D0-D7- used as Data lines(D0-D7)

#include<16F877A.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
void lcd_data_string(unsigned char *str);
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
unsigned char arr1[]={" IElec Systems"};
unsigned char arr2[]={" Nellai."};
unsigned char a,i;
void main()
{
output_d(0x00);
output_e(0x00);

IES-PIC16xx Rev: 1.0

Page 24 of 30

SAMPLE C PROGRAM
lcd_cmd(0x38);
lcd_cmd(0x0f);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_data_string(arr1);
lcd_cmd(0xc0);
lcd_data_string(arr2);
}
void lcd_cmd(unsigned char value)
{
output_d(value);
output_low(PIN_E0);
output_low(PIN_E1);
output_high(PIN_E2);
delay_ms(10);
output_low(PIN_E2);
return;
}
void lcd_data(unsigned char item) // Program to send data to LCD
{
output_d(item);
output_high(PIN_E0);
output_low(PIN_E1);
output_high(PIN_E2);
delay_ms(10);
output_low(PIN_E2);
return;
}
void lcd_data_string(unsigned char *str) // Program to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
delay_ms(10);
//delay_us(40);
}
return;
}
IES-PIC16xx Rev: 1.0

Page 25 of 30

SAMPLE C PROGRAM
7.9-I2C Serial EEPROM.
This program for 24s02 I2C EEPROM.

#include <16F877.H>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#use I2C(MASTER,sda=PIN_C4,scl=PIN_C3)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
int16 address;
int8 data;
void main()
{
printf("\n\r EEPROM Write Data is 0x65");
i2c_start();
i2c_write(0xae);
i2c_write(0x00);
i2c_write(0x10);
i2c_write(0x65);
i2c_stop();
while(1)
{
i2c_start();
i2c_write(0xae);
i2c_write(0);
i2c_write(0);
i2c_start();
i2c_write(0xaf);
data=i2c_read(0);
i2c_stop();
printf("\n\r %x ",data);
while(1);
}
}
7.10-LM35 Interface:::
This program for LM35 temperature sensor.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT

IES-PIC16xx Rev: 1.0

Page 26 of 30

SAMPLE C PROGRAM
float adc_data;
unsigned int adc_data1;
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
while(1)
{
adc_data = read_adc();
adc_data1 = adc_data * 1.7;
printf("\n\r Temperature %d",adc_data1);
}
}
7.11-On-chip ADC:::
This program for on-chip ADC.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
unsigned int adc_data;
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
while(1)
{
adc_data = read_adc();
printf("\n\r Temperature %d",adc_data);
}
}

IES-PIC16xx Rev: 1.0

Page 27 of 30

SAMPLE C PROGRAM
7.11-On-chip UART:::
This program for on-chip UART.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
void main()
{
printf("\n\r Press Any Key On the Keyboard");
printf("\n\r");
while(1)
{
putc(getc());
}
}
7.12-Traffic light controller interface:::
This program for TLC.

#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
void main()
{
output_b(0xff);
output_c(0xff);
output_d(0xff);
output_e(0xff);
while(1)
{
output_b(0xc3);
output_e(0x03);
output_c(0x1b);
output_d(0xff);
delay_ms(2000);
output_b(0xdd);
output_e(0x03);
output_c(0x1b);
output_d(0xff);
delay_ms(2000);
IES-PIC16xx Rev: 1.0

Page 28 of 30

SAMPLE C PROGRAM
output_b(0x7e);
output_e(0x03);
output_c(0x18);
output_d(0xff);
delay_ms(2000);
output_b(0xbe);
output_e(0x03);
output_c(0x1b);
output_d(0xff);
delay_ms(2000);
output_b(0xde);
output_e(0x00);
output_c(0x0f);
output_d(0xff);
delay_ms(2000);
output_b(0xde);
output_e(0x03);
output_c(0x17);
output_d(0xff);
delay_ms(2000);
output_b(0xde);
output_e(0x07);
output_c(0x1b);
output_d(0xf1);
delay_ms(2000);
output_b(0xde);
output_e(0x07);
output_c(0x1b);
output_d(0xfe);
delay_ms(2000);
output_b(0xde);
output_e(0x03);
output_c(0x1b);
output_d(0x0f);
delay_ms(2000);
}
}
IES-PIC16xx Rev: 1.0

Page 29 of 30

THE END

Thanks to all
The end

IES-PIC16xx Rev: 1.0

Page 30 of 30