trouble getting started
Michael Maiorana email (remove spam text)
Thanks for reading this. I'm trying to get started playing with PIC's and
I'm having some difficulty. I have been unable to find any help in the FAQ
or the archives (archive searches are failing).
Here is what I did.
I built the parallel port flash pic programmer from
I am trying to program a 16f870. I assembled my code using the mpasm. The
programmer properly identifies the PIC and says it succesfully programmed
it. When I put the pic in its circuit, the oscillator does not run (and
obviously it doesn't work).
The code is simple, I stole it from the archives and tweeked it for the
16f870. The code is at the end of this message.
The circuit is equally simple. RC4 has a 1k resistor, to an LED, to ground.
There is a 4MHz crystal across the "osc" pins, with 22pf caps to ground on
each side. Ground to pins 8 and 19, and 5 volts to pin 20. When I apply
power I get no flashing and an oscilloscope on the crystal shows it is not
As a side note, I tried to add the following line to my code to insure that
the config register was correctly configured for a crystal
The code assembles, but the programmer freaks out with programming errors. I
looked at the hex file and it looks wrong. Here is the second to last line,
which is the only difference between the code that programmed correctly and
the new code with the config register specified.
I thought the first two bytes were the number of bytes to program on this
line, the next two were the address, and the last byte was the checksum.
This is supposed to be writing 3FFE hex to address 2007 (or 400E in the hex
file). Notice that the length is only one byte long, and the address does
not have the bytes reversed, and that there is an extra 00 in the middle.
Can anyone make sense of this?
If you can think of some thing to try I'd appreciate the help.
Palm Harbor, FL
Title "LED flasher."
list P = 16F870
include "P16f870.inc" ; use definition file for 16F870
; USER RAM DEFINITIONS
CBLOCK 0x20 ; RAM starts at address 20h
org 0x0000 ; start address = 0000h
; INITIALISE PORTS
; binary used to see individual pin level
movlw b'00000000' ; all port pins = low
bsf STATUS,RP0 ; set RAM Page 1 for TRIS registers
; INITIALISE PORTS
; binary used to see individual pin IO status
movlw b'00000000' ; all IO pins = outputs
movlw b'00000110' ; all analog pins = digital
bcf STATUS,RP0 ; back to RAM page 0
; LED FLASH LOOP
Loop bsf PORTC,4 ; RC4 = high = led on
bcf PORTC,4 ; RC4 = low = led off
; 1/2 SEC DELAY SUBROUTINE WITH 4MHz CLOCK
Delay movlw 01h
DeLoop0 decfsz NaLo,F
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
See also: www.piclist.com/techref/microchip/begin.htm?key=pic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the