Page Sponsored by 
Back to Victorian University Electronics Intranet Home Page Mirror.
Programming the PIC16F877 on a SimmStick.

Left, the 16F877 sample as supplied from the Microchip distributors, Zatek.

Looking at the programming info for the F877 reveals that the process is the same as for the 16F84. I therefore hoped to use my existing programmer. The only problem is that I currently use Nigel Goodwin's software to drive the hardware. This software is specifically for the F84. Apart from the problem of the size of the program memory there is also the problem of the configuration bits. I connected every thing and tried a small test program. No problems with the program but the configuration fuses failed to verify. As the lower order configuration bits are the same for the F84 I tried to run the program in a target board just to check, no luck. I then realised that the general purpose registers in bank 0 didn't start until 20h as compared to 0ch in the F84. I edited the program to take into account the register addresses and reloaded, this time success. I haven't tried a larger program to see if Nigel's software will program the higher addresses.

I then tried the P16PRO software, as it says that it supports the 16F877. I downloaded the 21 day trial version and had a look at it. I then copied it to the computer that I use for micro controller development and it froze the computer, only the three finger salute worked. I didn't have time to try to find out what the problem is but the computer is just a stock 100Mhz Pentium. I copied the software to a notebook to check and it ran OK there, which it did. Back to the original computer. After maki ng the necessary changes to the software to match Don's programmer I was able to program a F84 with no problems. I then tried the F877, no go. As I had already programmed the device using the hardware, it had to be the software. I checked the entries in the device.ini file and found there were some differences between the F84 entry and the F877 entry that didn't agree with the Microchip specs. I edited the F877 entry to match the F84 entry where appropriate and tried again. Instant success.

The table below is an extract from the device.ini file showing both the F84 & F877 entries. The F877 entry has been changed so that p.delay = 10 and Vpp = 1.

PIC16F83    512    64   1   7   18    1     10     0    0    1
PIC16CR83   512    64   1   8   18    1     10     0    0    1
PIC16C84    1024   64   1   1   18    1     10     0    0    1
PIC16F84    1024   64   1   7   18    1     10     0    0    1
PIC16CR84   1024   64   1   8   18    1     10     0    0    1
PIC16F873   4096   128  1   14  28    1      2     0    0    2
PIC16F874   4096   128  1   14  40    1      2     0    0    2
PIC16F876   8192   256  1   14  28    1      2     0    0    2
PIC16F877   8192   256  1   14  40    1     10     0    0    1

Photo showing my PIC 16F84 programmer hardware. The board in the foreground is an old Dontronics F84 programmer. It is attached to a Simmbus motherboard made with some Vero board. The 10 pin in circuit programming header attaches the two boards. This setup is the equivalent of Don's present DT001 mother board with the target board sitting in the first Simm slot. The target board is a SimmStickPIC004B board.

Photo showing minimum population of the PIC004B target board.

After programming the 877 with the walking led program below, I noticed the LCD connector on the PIC004B board. I quickly edited a 4bit LCD program I had for the F84 to try. When I went to fit the LCD header I noticed that it had the pins reversed compared to the LCDs I have. Instead I used my normal LCD test board. For photos and sample program click here.

Sample walking led program for the 16F877. Use PIC004B as target processor board and a DT203 board for the leds. My test used a 10Mhz xtal for the 877.

;Test program for 16F877
;assembled using mpasm version 1.3
                LIST      P=16C84, F=INHX8M
                include ""

ram1            EQU     20H
ram2            EQU     21H
ram3            EQU     22H
LOOP_8          EQU     23H
LED_BYTE        EQU     26H

                GOTO    start
                ORG 0005          
start           MOVLW   TRISA
                MOVWF   FSR
                MOVLW   000
                MOVWF   INDF
                INCF    FSR     ,f
                MOVWF   INDF
                MOVWF   PORTA     
                MOVWF   PORTB
                MOVLW   08
                MOVWF   LOOP_8          ;DO IT 8 TIMES
                MOVLW   00
                MOVWF   PORTB_COUNT     ;LOAD PORT B COUNT
                MOVLW   0FF
                MOVWF   PORTA_COUNT     ;PORT A TO -1
                BSF     STATUS,W        ;SET CARRY
                RLF     PORTB_COUNT,F   ;WALK PORT B LEFT
                MOVF    PORTB_COUNT,W   ;
                MOVWF   PORTB           ;STORE TO B
                INCF    PORTA_COUNT,F   ;
                MOVF    PORTA_COUNT,W   ;
                MOVWF   LED_BYTE
                RLF     LED_BYTE,F
                RLF     LED_BYTE,F
                MOVF    LED_BYTE,W
                MOVWF   PORTA
                CALL    delay
                DECFSZ  LOOP_8,F
                GOTO    LOOP
                MOVLW   00
                MOVWF   PORTB
                GOTO    ENTRY

delay           MOVLW   000       
                MOVWF   ram2        
                MOVLW   004       
                MOVWF   ram3      
delay1          MOVLW   0F3       
                MOVWF   ram1      
delay2          NOP               
                DECFSZ  ram1      , f       
                GOTO    delay2
                DECFSZ  ram2      , f       
                GOTO    delay1
                DECFSZ  ram3      , f       
                GOTO    delay2

                org     2007h
                data    0xf31

Written by Peter Averill
Victoria Universtiy TAFE
Electronics Technology Department
13 June 1999

Written by Peter Averill
Victoria Universtiy TAFE
Electronics Technology Department
13 June 1999

Copying these pages:
Back to Victorian University Electronics Intranet Home Page Mirror.
DonTronics Links:
Home Products Prices Directory Order Contact New Books Files Links FAQ