PIC16F877A code not running on EASYPIC V7

Thread Starter


Joined Sep 2, 2018
Enclosed code is one simple example from Bate's book "Interfacing Pic microcontroller".
The codes run properly in Proteus VMS, but not on EasyPic V7 board (to start and stop blinking I use RB1 and 2 buttons in pull up setting). Only RD6 and RD3 are lighted up constantly, but no light sequence like in the simulation.

I had same problems (not running on easypicv7) for other codes with this 16F877A.

I don't know if it is a problem of configuration or so (I remember in the past that to make 16F628A I had to pull down RB4, for instance...).
I don't know if something similar is needed here...

Thank you for any kind suggestion/advise.


;  Source File:   LED2.ASM
;  Author:  MPB
;  Date:  2-1-13
;  Slow output binary count is stopped, started
;  and reset with push buttons.
;  Processor:  PIC 16F877A
;  Hardware:  Prototype
;  Clock:  RC = 40kHz
;  Inputs:  Port B: Push Buttons
;  RB1, RB2 (active low)
;  Outputs:  Port D: LEDs (active high)
;  WDTimer:  Disabled
;  PUTimer:  Enabled
;  Interrupts:  Disabled
;  Code Protect:  Disabled

   PROCESSOR 16F877   ; Define MCU type
   __CONFIG 0x3733     ; Set config fuses

; Register Label Equates....................................

PORTB  EQU  06   ; Port B Data Register
PORTD  EQU  08   ; Port D Data Register
TRISD   EQU  88   ; Port B Direction Register
Timer  EQU  20   ; GPR used as delay counter

; Input Bit Label Equates ..................................

Inres  EQU  1   ; 'Reset' input button = RD0
Inrun  EQU  2   ; 'Run' input button = RD1


  CODE  0  ; Program code start address

; Initialise Port B (Port A defaults to inputs).............

  BANKSEL   TRISD  ; Select bank 1
  MOVLW  b'00000000'     ; Port B Direction Code
  MOVWF   TRISD     ; Load the DDR code into F86
  BANKSEL   PORTD  ; Select bank 0
  GOTO   reset  ; Jump to main loop

; 'delay' subroutine ........................................

  MOVWF    Timer     ; Copy W to timer register
  DECFSZ    Timer     ; Decrement timer register
  GOTO     down     ; and repeat until zero
  RETURN  ; Jump back to main program

; Start main loop ...........................................

  CLRF  PORTD  ; Clear Port B Data

  BTFSS    PORTB,Inres     ; Test reset button
  GOTO     reset     ; and reset Port B if pressed
  BTFSC    PORTB,Inrun     ; Test run button
  GOTO    start     ; and repeat if n pressed

  INCF     PORTD     ; Increment output at Port B
  MOVLW    0FF     ; Delay count literal
  CALL   delay  ; Jump to subroutine 'delay'
  GOTO     start     ; Repeat main loop always

  END     ; Terminate source code
Mod edit: posted code and schematic from .zip


Last edited by a moderator:

Thread Starter


Joined Sep 2, 2018
Hello Ian.
I install it by connecting it from external breadboard to OSC1 pin13 of easypic v7 mcu as required in the schematic.

Thank you


Joined Jun 26, 2012
A few things besides the obvious i.e. check wiring, make sure power and ground are run to all of the boards, proper voltages to all power supply pins etc.
Try to see if the oscillator is running. A first order check is to measure the voltage on OSC2. It should be 30-50% of Vdd. If it's 5v or 0, the oscillator is not running.
Consider adding a simple LED test to turn them all on, delay awhile, then turn them all off before starting the main program. That will tell you that the PIC is running.
Make sure the variable resistor is at least 3K per PIC spec. I'd suggest putting a 3k fixed resistor in series with the variable R to be sure.
Try commenting out the switch input lines and just let it free run. When you get the LEDs counting at the right speed, add the switch code back.
Counting on a PORT can introduce r-m-w problems. Consider keeping the counter in RAM then just writing it to the PORT using MOVWF.
Double check the config bits. Your drawing and the code have different values (although both specify RC oscillator).
Make sure your programmer is not in the debug mode.

Finally, keep in mind that Proteus will 'run' with a configuration that won't work on hardware i.e. it can 'run' with no oscillator shown on the schematic.

Good luck!

; getting rid of r-m-w problem

PORTDimg equ 21 ; maintains an image of PORTD for modifications/counting
  clrf PORTD
  clrf PORTDimg  ; init both


  incf PORTDimg,F  ;increment the IMAGE
  movf PORTDimg,W ; then copy to port without r-m-w
  movwf PORTD

Thread Starter


Joined Sep 2, 2018
Many thanks John for your kind and exhaustive suggestion.

I managed the problem by substituiting the configuration as in code part below.
I guess that in 0x3733 there was the problem (maybe the "in circuit debug enable").

Now it works properly also on easypicv7 hardware.

Thank you very much again.

;    PROCESSOR 16F877    ; Define MCU type
;    __CONFIG 0x3733        ; Set config fuses
list P = 16F877A
include P16F877A.inc
__config _RC_OSC & _WDT_OFF & _LVP_OFF & _PWRTE_ON