ME Labs, Inc.
719-520-5323
 
Home:
  Developer Resources:

Programming Clues
    Sample Programs
   
    PICBASIC PRO™
Compiler Manual
    PICBASIC™ Compiler
Manual
    Serin2/Serout2 Modes
    ASCII Character Set
    Number Conversion
    Floating Point
Routines
    PBP Debug Monitor
    Articles and Tutorials

Hardware Clues
    Parts / Vendor List
    PICPROTO™ Boards
    LAB-X1 Docs
    LAB-X2 Docs
    LAB-X20 Docs
    LAB-X3 Docs
    LAB-X4 Docs
    LAB-XUSB Docs
    LAB-XT Docs
     
 

Migration from 16F877A to 16F887

The PIC16F877A is an older part that is becoming obsolete.  In our bundled development systems, we have replaced the 16F877A with the more modern 16F887.  However, many of the books that we sell only have sample programs for the 16F877A.  This is especially problematic in the book "LAB-X1 Tutorial and Resource Book" by Harprit Sandhu, which is included in our Super Bundle development system.  The following information is intended to assist in converting programs for use with the 16F887.  The syntax below is for PICBASIC PRO Compiler.

Much of the function of the 16F877A ADCON1 register has been moved to the ANSEL and ANSELH registers in the 16F887:

ADCON1 (16F877A) ANSEL (16F887) ANSELH (16F887) ADCON1 (16F887) DESCRIPTION
ADCON1 = %00000000  '($00, 0) ANSEL = %00011111 ANSELH = %00000000   PORTA analog
ADCON1 = %00000100  '($04, 4) ANSEL = %00001011 ANSELH = %00000000   AN0, AN1, AN3 analog
ADCON1 = %00000110  '($06, 6) ANSEL = %00000000 ANSELH = %00000000   All pins digital
ADCON1 = %00000111  '($07, 7) ANSEL = %00000000 ANSELH = %00000000   All pins digital
ADCON1 = %00001110  '($0E, 14) ANSEL = %00000001 ANSELH = %00000000   AN0 analog
ADCON1 = %10000010  '($82, 130) ANSEL = %00011111 ANSELH = %00000000 ADCON1.7 = 1 PORTA analog, result right-justified
ADCON1.7 = 1     ADCON1.7 = 1 result right-justified

DEFINE ADC_CLOCK does not function on the 16F887.  This define must be replaced by a setting to the ADCON0 register:

DEFINE for16F877A ADCON0 setting for 16F887
DEFINE  ADC_CLOCK  0 ADCON0 = %00000000
DEFINE  ADC_CLOCK  1 ADCON0 = %01000000
DEFINE  ADC_CLOCK  2 ADCON0 = %10000000
DEFINE  ADC_CLOCK  3 ADCON0 = %11000000