piclist 2001\08\31\231329a >
Thread: trouble getting started
www.piclist.com/techref/microchip/begin.htm?key=pic
flavicon
face BY : 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
www.rotgradpsi.de/mc/picproge.html#UnterstuetztePICs
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
oscillating.
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
__CONFIG _HS_OSC
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.
:02400E00FE3F73
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.
Best Regards,
Mike M.
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
NaHi
NaLo
NbHi
NbLo
       ENDC
;
       org 0x0000      ; start address = 0000h

; INITIALISE PORTS
; binary used to see individual pin level

       movlw b'00000000'       ; all port pins = low
       movwf PORTA
       movlw b'00000000'
       movwf PORTB
       movlw b'00000000'
       movwf PORTC

       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
       movwf TRISA
       movlw b'00000000'
       movwf TRISB
       movlw b'00000000'
       movwf TRISC

       movlw b'00000110'       ; all analog pins = digital
       movwf ADCON1

       bcf STATUS,RP0  ; back to RAM page 0

; LED FLASH LOOP

Loop    bsf PORTC,4     ; RC4 = high = led on
       call Delay

       bcf PORTC,4     ; RC4 = low = led off
       call Delay
       goto Loop

; 1/2 SEC DELAY SUBROUTINE WITH 4MHz CLOCK

Delay   movlw 01h
       movwf NbHi
       movlw 03h
       movwf NbLo
       movlw 8Ah
       movwf NaHi
       movlw 5Bh
       movwf NaLo

DeLoop0 decfsz NaLo,F
       goto DeLoop0
       decfsz NaHi,F
       goto DeLoop0
       decfsz NbLo,F
       goto DeLoop0
       decfsz NbHi,F
       goto DeLoop0
       ;
       return

       end

--
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


<001501c13292$4247cba0$c9b35c18@tampabay.rr.com> 7bit

See also: www.piclist.com/techref/microchip/begin.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) trouble getting started

month overview.

new search...