Professional Documents
Culture Documents
Product datasheet
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.
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
Page 3 of 30
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
RTC
4KB FLASH
I/O
FLASH
SELECTION
I2C
EEPROM
4 DIGITS SEVEN
SEGMENT
STEPPER MOTOR
DERIVER
16*2-LCD
ALPHANUMERIC
Page 4 of 30
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.
Page 5 of 30
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.
Page 6 of 30
Page 7 of 30
To start the MPLAB IDE software and produce window similar to shown.
Page 8 of 30
Click on Next and select device as PIC16F877A then click on Next after this
The following window will appear.
Page 9 of 30
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.
Page 10 of 30
Page 11 of 30
Page 12 of 30
Now Add Files to project window will appear. Here browse the source/application file
directory and open it for adding to project.
Page 13 of 30
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.
Page 14 of 30
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.
Page 15 of 30
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).
Page 16 of 30
By selecting Program PIC option. It starts programming and screen appear like this. The Red color led
is glowing at the time of programming.
Page 17 of 30
In the hardware ISP mode 4-dip switch changed to down position and SW2 switch is changed to RUN
mode for program execution.
Page 18 of 30
SAMPLE C PROGRAM
7. SAMPLE C PROGRAM.
7.1-LED Interface:::
This program for toggling the LED using PORT B.
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);
}
}
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;
}
}
}
}
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
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
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);
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
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);
}
}
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
Page 30 of 30