FPedersen's Pic Programming Page


Updated December 1999

Links

Info

Microchip Web Site

Sw Tools

MPASM

DIY Programmers

How to program PIC
Programmer for PIC 16C84A
Worlds smalest for PIC 16C84A
Prgrammer for PIC 16xxx

DIY Projects

DCC model Railroad interface
My DCC Model Railroad interface

Links

PIC Links

fpedersn@online.no

Pic Programming Experience and Link Page



This Page

This page are used to tell about my experience with PIC programming. My intention is to use multiple PIC 16F84 to controll a model RailRoad. It will contain Tips about programming, sample programs and Links to more info. I hope to update this page every month.


What's New

New page layout
My 2nd PIC application IOPICSD00


Next Month

Next month might contain an expanded sample program that will be able to schedule trains on a Modelrailroad. It might also contain information about In-Circuit Programming.


Experience

I have built a simple programmer for a PIC16F84. This programmer is really simple to build. Only problem with it is that it does not work with some Pentium PC (I have a DELL Latitude CP Pentium 233 MHz laptop computer) but it does work on my old 286.

I have made a pcb for testing. This is actually designed for a ModelRailroad DCC interface but is also useful for simple testprograms. This design can be found at : http://geocities.datacellar.net/CapeCanaveral/7706/tmw01.html

My first PIC application IOPIC000

I Have built a simple test program to blink the LED.
The necessary steps to test this is :
1. Download design for programmer
2. Build programmer and install a PIC16C84 or PIC16F84
3. Download testprogram and unzip (updated june 4 - now contains sourcecode)
4. Connect programmer to serial port and run programmer
5. Build TMW01 Hardware and install the programmed PIC Controller
6. Connect 5V DC (and Ground) to TMW01 (DO NOT CONNECT TO COMPUTER or anything else) and see led blinking.

7. Start experimenting by modifying iopic000.asm
8. download assembler MPASM from microchip
9. Insert PIC in programmer and continue with step 4

IOPIC000.ASM - Source Code

;*******************************************************************

;                           iopic001.asm

;

; This code blinks LED connected to pin 2 

; This program was written by fpederse 19990604

; It was originally based on walk.asm that can be found at:

;       http://hobbes.king.ac.uk/matt/pic/

;*******************************************************************



	LIST    P=16C84;f=inhx8m

	

_CP_OFF         equ     H'3FFF'                 ;code protect off

_PWRTE_ON       equ     H'3FFF'                 ;Power on timer on

_WDT_OFF        equ     H'3FFB'                 ;watch dog timer off

_XT_OSC         equ     H'3FFD'                 ;crystal oscillator

__CONFIG       _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC

						;configure programmer directive



w       equ     0       ; register destination numbers.

f       equ     1       

same    equ     1



z       equ     2       ; status flags

zero    equ     2

c       equ     0

carry   equ     0

	

count1  equ     0C      ; wait counter ls digit file register C

count2  equ     0D      ; wait counter ms digit file register D

portb   equ     06      ; port b I/O register f6

porta   equ     05      ; port a I/O register f5

status  equ     03      ; status register f3

;

;

;

	org     0       ; origin

;

init   

	movlw   0

	tris    porta                   ; set porta as outputs

	movwf   porta                   ; set porta levels all low

;-----------------------------------------------------------------------

; Start usermodificable code :

;-----------------------------------------------------------------------

start

	bsf     porta,3                 ; set porta bit 3 high / pin 2 / LED

	call    wait_sec_10             ; Wait approx. 10 Sec                    

	bcf     porta,3                 ; Set porta bit 3 low  / pin 2 / LED

	call    wait_sec_10             ; Wait approx. 10 Sec

	goto    start

	

;      

; ----------------------------

; wait subroutines 

; ----------------------------

wait_min

	call    wait_sec_30

	call    wait_sec_30

	return

wait_sec_30

	call    wait_sec_10

	call    wait_sec_10

	call    wait_sec_10

	return

wait_sec_10

	call    wait_sec_5

	call    wait_sec_5

	return

wait_sec_5

	call    wait_sec

	call    wait_sec

	call    wait_sec

	call    wait_sec

	call    wait_sec

	return

wait_sec

	call    wait1

	call    wait1

	return

wait1

	call    wait0

	call    wait0

	call    wait0

	call    wait0

	return

wait0    

	movlw   .200            ; load count1 with decimal 200

	movwf   count1

d1      movlw   .200            ; load count2 with decimal 200

	movwf   count2  

			      

	

d2      decfsz  count2,same     ; decrement and skip next line if zero

	goto    d2              ; if not zero           

	decfsz  count1          ; decrement count1 if count2 is zero

	goto    d1              ; do inside loop again if count2 nz

	return

; ----------------------------        



END





My 2nd PIC application IOPICSD00

IO Pic Serial Detector basic functionality will be to read the input startus of port B and send this to a RS232 Port connected to port A. This project is based on Microship Application note 555 Microship Application note 555

Future projects based on this will be a Train detector with 64 block input and a rs232 output, and it will also be used for a handheld throtle.




fpedersn@online.no


This page hosted by get your own Free Home Page
1