WORLD’S SIMPLEST PROGRAM using PIC12F629

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.

Worlds Simplest programme


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

 

Source : WORLD’S SIMPLEST PROGRAM using PIC12F629

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter