PIC16F887 MPLabX XC8 Tutorial

Introduction

XC8 compiler is a C compiler targeting 8-bit PIC devices, develops by Microchip. It's free with full features. But if you want to pay, you can buy a standard or a pro edition.

In this tutorial, I select PIC16F887. It was released around 2009. Currently, It still in production with lower cost. However, Microchip has been release many new 8-bit PIC devices with many more features than PIC16F887.

At this time, The latest version of its main IDE MPLABX is v5.4. The latest version of XC8 compiler is v2.20. They are cross-platform. We can develop the firmware using this IDE and C compiler on Windows, Linux and Mac OS. 


PIC16F887 tutorial with XC8
A screen shot MPLABX v1.51 starting up, that I use for this tutorial.

Anyway, I use MPLABX IDE v1.51 with XC8 v1.31 for this tutorial page. They are light-weight and easy to use. The latest version is rich of resources and functionalities, but we don't need those stuffs.

The MPLABX IDE 1.51 and XC8 1.31

Getting started and basic digital inputs outputs programming 

  1. Programming the PIC16F887 with MPLABX XC8
  2. Programming the digital inputs outputs of PIC16F887 with XC8
  3. PIC16F887 LED scrolling programming with XC8
  4. PIC16F887 interfaces to a single digit seven-segment display with XC8
  5. PIC16F887 controlling the DC servo motor without hardware PWM module
  6. PIC16F887 set and reset an output relay-controlled lamp
  7. PIC16F887 interfaces to a unipolar stepper motor 
  8. Using digital input with weak pull up resistor of PIC16F887
  9. Introduction to external interrupt of PIC16F887
  10. Programming the PortB interrupt on change of PIC16887
  11. Making a digital up down counter using PortB interrupt on change of PIC16F887 with Multiplexed Display 
  12. Driving a single 8x8 dot matrix display using PIC16F887
  13. PIC16F887 interface to a bipolar stepper motor
  14. PIC16F887 controls the direction and speed of a brushed DC motor without using PWM module
  15. Interfacing the 74HC595 shift registers with PIC16F887 digital pins
  16. Interfacing a parallels in serial out shift register to PIC16F887 via digital pins

PIC16F887 Configurations

Analog To Digital Converter 

  1. Introduction to analog to digital converter module
  2. Using ADC module to read analog voltage between 0 to 5 volts DC
  3. Reading multiple analog voltage inputs in the ADC module
  4. Working with ADC references voltage of PIC16F887
  5. Interfacing LM35 temperature sensor to the ADC module of PIC16F887
  6. Designing a positive and negative DC voltage meter using the 10-bit ADC module
  7. Reading the ADC using interrupt method
  8. Interfacing LDR and NTC thermistor to PIC16F887 ADC module

The MPLABX IDE 6.15 (2023) and XC8 2.36  

The earlier releases of MPLABX IDE and XC8 C compiler does not run properly on Microsoft Windows 10 x64 with updates. So I decided to use the latest version of the MPLABX IDE 6.15 in late 2023. The latest version include code configuration tool, ML, etc. The PICKKit2 programmer tool doesn't work in this new IDE. Using an older version of XC8 C compiler of 2.36 is not a problem. It still work in new IDE but it doesn't contain any new release of Microchip devices that I don't need them here.

From late 2023 I added some new programming examples. The PIC16F887 interfaces with character LCD, analog (LM35) and digital (1-Wire ds18B20) temperature sensor, temperature and humidity (DHT-11) sensor, and the Ultrasonic Range Finder (HC-SR04) sensor. 

  1. PIC16F887 HD44780 4-Bit LCD Example Using XC8
  2. PIC16F887 HD44780 8-Bit LCD Example Using XC8 
  3. PIC16F887 LM35 and LCD Interfacing Example Using XC8 
  4. PIC16F887 DS18B20 LCD Example Using XC8 
  5. PIC16F887 DHT-11 LCD Example Using XC8 
  6. PIC16F887 HC-SR04 Distance Sensor LCD Using XC8
 At the beginning of 2024, I started some new example using the Inter Integrated Circuit (I2C) module of PIC16F887. I use a 128x64 OLED I2C (SH1106) graphical LCD, a ds1307 Real Time Clock (RTC), a 24C16B I2C EEPROM, a PCF8574AP 8-bit I/O expander, a TM1637 LED display driver and keypad scanner, and a MCP23017 16-bit I/O expander chip.
  1. PIC16F887 I2C DS1307 RTC LCD Using XC8 
  2. PIC16F887 I2C AT24C16B EEPROM LCD Using XC8 
  3. PIC16F887 SH1106 I2C OLED Display Example using XC8 
  4. PIC16F887 TM1637 Six Digits 7-Segment Display Example Using XC8
  5. PIC16F887 TM1637 Display and Key Scan Example using XC8 
  6. PIC16F887 PCF8574 I2C Example using XC8 
  7. PIC16F887 KeyPad and Character LCD Example using XC8 
  8. PIC16F887 PCF8574AP I2C 4x4 Key Pad using XC8 
  9. PIC16F887 PCF8574AP I2C LCD Example using XC8 
  10. PIC16F887 MCP23017 I2C GPIO Example using XC8 
  11. PIC16F887 MCP23017 Key Pad and 7-Segment Display Example using XC8 
  12. PIC16F887 MCP23017 I2C LCD Example using XC8
  13. PIC16F887 MCP23017 LCD and Keypad Interfacing using XC8 
  14. PIC16F887 Serial Peripheral Interface Example 
  15. PIC16F887 SPI and MCP23S17 XC8 Example 
  16. PIC16F887 SPI MCP23S17 and Character LCD XC8 Example 
  17. PIC16F887 SPI MCP23S17 Character LCD and KeyPad XC8 Example 

Using a simple DIY prototype board could help the electronics hobbyists to reduce time in circuit construction on bread-board. I also prevent from wrong connections of wire that can destroy the chips. I made my own PIC16F877A/PIC16F887/PIC18F4550 prototype board.

PIC16F887 MPLabX XC8 Tutorial
A DIY Prototype Board for PIC16F877A PIC16F887 PIC18F4550 etc

 


No comments:

Post a Comment

Search This Blog

Labels

25AA010A (1) 8051 (7) 93AA46B (1) ADC (30) Analog Comparator (1) Arduino (15) ARM (6) AT89C52 (7) ATMega32 (56) AVR (57) CCS PICC (28) DAC (1) DHT11 (2) Display (105) Distance Sensor (3) DS18B20 (3) dsPIC (2) dsPIC30F1010 (2) EEPROM (5) Environment Sensor (4) esp8266 (1) I2C (29) Input/Output (67) Interrupt (19) Keil (5) Keypad (10) LCD (47) Master/Slave (1) MAX7221 (1) MCP23017 (5) MCP23S17 (4) Meter (3) MikroC (2) Motor (15) MPLABX (71) Nokia 5110 LCD (3) OLED (2) One-Wire (6) Oscillator (8) PCB (6) PCD8544 (3) PCF8574 (5) PIC (107) PIC12F (2) PIC16F628A (2) PIC16F630 (1) PIC16F716 (3) PIC16F818 (10) PIC16F818/819 (2) PIC16F84A (15) PIC16F876A (1) PIC16F877A (9) PIC16F88 (1) PIC16F887 (60) PIC18 (19) PIC18F1220 (4) PIC18F2550 (3) PIC18F4550 (12) PWM (11) RTC (8) Sensor (10) SH1106 (1) Shift Register (11) Shift Registers (3) SPI (24) STM32 (6) STM32 Blue Pill (6) STM32CubeIDE (6) STM32F103C8T6 (6) SysTick (3) temperature sensor (11) Thermometer (21) Timer/Counter (31) TM1637 (2) UART (7) Ultrasonic (4) Voltmeter (7) WDT (1) XC16 (2) XC8 (94)