WORLD'S SIMPLEST PROGRAM


Home
 

PIC Programmer MkV

Instruction Set for PIC12F629
PIC12F629 data
(pdf)
BlankF629.asm

PIC12F629.inc

See more projects using micros:
Pic A PIC Project

Notepad2.zip     Notepad2.exe 
Library of Sub-routines "Cut and Paste
"
Library of routines:   A-E   E-P    P-Z 

 

 

This is where you start with programming. Build the PIC Programmer MkV and build the World's Simplest circuit on a PC board for a PIC12F629 chip, LED and resistor.
When the World's Simplest Program is "burnt" into the chip, the LED will flash.
This is not a "normal" program as the Watch-Dog Timer has been turned ON and after 18mS it resets the chip to "org 0X00" and the program executes the 8 instructions again.
At the 6th and 7th instruction, the state of GP4 will change from HIGH to LOW or LOW to HIGH and this will toggle the LED.
At the 8th instruction the micro will go to sleep and after about 18,000 microseconds, it will be woken up by the watch-dog timer and go to location 0x00.
At instruction 3, we have added a pre-scaler to the WDT to extend its timing to 18mS x 8 = 0.144Secs. You can change this value and note the different flash-rate.
Making bit 3 of the option_reg = 0 will produce a very fast flash-rate as the prescaler will be removed from the WDT.
This program tests your programmer and the chip you are burning as well as the circuit containing the LED.
It also shows the function of the watch-dog timer.
Normally, when the WDT is turned ON, it must be periodically cleared (reset) via the instruction clrwdt so that it does not come into operation.
For instance, before entering a delay loop, the WDT is reset.
If not, it may reset your program and you will be wondering why your project does not work.
Go to
PIC12F629 data and read page 12: OPTION Register. It shows how the bits are allocated to the WDT. Change these bits and see how the flash-rate changes.  
 

Here are the files:
World'sSimplest.asm
World'sSimplest.hex

;*************************************
;WORLDS SIMPLEST PROGRAM             *
;  18-5-2010                         *
;                                    *
;************************************

	list	p=12F629
	radix	dec
	include	"p12f629.inc"		
		
	__CONFIG  _MCLRE_OFF & _CP_OFF & 
                _WDT_ON & _INTRC_OSC_NOCLKOUT  ;Internal osc.

;************************************
;Beginning of program
;************************************
	org	0x00
	bsf	status, rp0 	;bank 1		
	bcf	TRISIO,4	;GP4 output		
	movlw   b'00001011' ;bit3=1=WDT  011=/8 WDT=18mSx8=0.144Sec
        movwf   option_reg     	;must be in bank 1
        bcf	status, rp0	;bank 0	
        movlw	b'00010000'	;to toggle GP4
	xorwf	GPIO,f
	sleep
		
	END	

Here are some changes you can make to see the differing flash-rates: 
change
               sleep
      to: 
              goto    $

change

          movlw   b'00001011'
          movwf   option_reg
 
to:

         movlw   b'00001111'
         movwf   option_reg

or to:

         movlw   b'00000111'
         movwf   option_reg

11/5/2010