uhsfl%da lkafgda,hla hkq l=ulao @ fuhg Èh yels ir
klhla hkakhs' tu ksid fuhg fndfyda úg ndysßka iemhsh hq;af;a m%Þk ^ INPUTS & yd úÿ,s n,h ^ POWER & muKls' uhsfl%da fm%dfiirhla hkq l=ulao @ fuho Ñmhla u; msysg jQ mß>klhls' kuq;a fuys l%shd ldß;ajhg wjYh RAM , ROM, PIA , CLOCK jeks wfkl=;a WmlrK ndysßka iúl, hq;h = ' uhsfl%da fldkafgda,fha fuu WmlrK ish,a, Ñmh ;=,u wka;¾ .; fõ' uhsfl%da fldkafgda,fha b;sydih uhsfl%da fm%dfii¾ fyda lkafgda,hr fyda ^g%dkaii s ag¾ mjd& ìysùug fmr hq.fha isgu ñksid mß>kl Ndú;d lr ;sìks' fïjdfha l%shdldÍ Wmdx.h jQfha ßlal áhqnhhs ^VACUUM TUBE& fuh úYd," nr úfok iq¿ Wmdx.hls' 1948 § weußldfõ fn,a úoHd.drfha úoHd{hska f;m,la úiska TRANSISTOR o 1956 weursldfõ cela ls,aì úiska uq,au IC WmlrKho fidhd.;a miqj mß>kl j, m%udKh Èfkka Èku l=vd ùu fkdj,elaúh yels lreKla úh' fï ks¾udKh ñksidf.a bmerks isyskhla jQ ;ks Ñmhl mß>klhla (COMPUTERT ON A CHIP) hk isyskh ienE lsÍug Woõ úh' ienE MICRO PROSSESSOR iE§u wdrïN jQfha 1969 cmdkfha BUSICOM iud.fï úoH{hska úiska ;kk ,o hka;%hla i`oyd MICRO PROCESSOR ;ekSug W;aidy lsÍfuka miqjhs' fuh Ndr jQfha INTEL iud.fï MARCIAN HOFF keue;a;dgh' Tyqf.a woyia ref.k th ÈhqKq l, FEDRIGO FRANGGINS keue;a;d úiska m%:u j;djg 1971 § 4004 kñka MICRO POSSESSOR hla fjkl l%%shd lsÍu i`oyd 8 BIT MICRO POSSESSOR hla ksmojk f,i b,a,Sula lrk ,§ wjidkfha CTC iud.u fï woyi w;a yer ±uqj;a È.gu tA woyi Tiafia ls%hdl, wfkla iud.ï fol 1972 § f,dj m%:u 8 BIT MICRO POSSESSORh 8008 f,djg yÿkajd fok ,§' fuh Wmfoia (INSTRUCTION) 45 lska o 16 bit u;lhlskao iukaú; jQ w;r ;;amrhlg Wmfoia 300"000 ls%hdfõ fhoùfï yelshdjlska hqla; úh' Bg jir 2lgmiq INTEL iud.u ksmojQ 8080 MICRO PROCESSOR h mß>klhla l%%shd lsÍug ;rï n,j;a m,uq MICRO PROCESSOR h jk fuys wdrïN ñ, $ 360 úh'fï jk úg mß>kl lafIa;%fha isák ;j;a iud.ï lSmhla fï ks¾udKfha jákdlu jegfykakg úh' fuhska m%Odk iud.ula jQ MOTOROLA iud.u 6800 kuq;a Tyqf.au MICRO PROCESSOR la fjkl MICRO POSSESSOR yd MICRO CONTROLLER fm,l wdrïNh úh' 1
4004 MICRO PROCESSOR h
PENTIUM 4 MICRO PROCESSOR h 2
PIC 16F84A ye|skaùu uhsfl%da lkafg%da,rh Y%S ,xldfõ fï ;rï ckm%sh jQfha PIC FLASH mjqf,a meñKSu;a iuÕ hehs lsjfyd;a th w;sYfhdala;shla fkdfõ' fuu n,j;a ìÜ 8 uhsfl%da lkafg%da,rh meñKSu;a ta yd meñKs n,j;a kuq;a mdúÉÑhg myiq uDÿldx.;a" wvq ñ,g ;kd .;yels ir, fm%da.%Eu¾ iy FLASH mjqf,a we;s kej; kej; fm%da.%Eï lsrSfï myiqj;a fya;=fjka flfkl=g b;d wvq ld,hlska yd úhoulska ;udf.a ks¾udKh PIC uhsfl%da lkafg%da,r wdY%s;j lr.; yel' 1980 uq, Nd.fhA MICROCHIP iud.u t<soelajQ uq,au PIC lkafg%da,r j,ska n,dfmdfrd;a;= jQfha hï hï hka;% iQ;%j, md,k fldgia yd moaO;s iajhxl%ShlrKhhs' PIC (PERIPHERAL INTERFACE CONTROLLER) hk joku thg idCIs imhhs' kuq;a wo jk úg úYd, mrdihl me;sr ;sfnk PIC mjqf,a idudcslfhda moaO;s md,khg wu;r (DIGITAL SIGNAL PROCESSING , RF CONTROLLING, INTELLIGENT POWER CONTROLLING, A TO D CONVERSIONG) jeks úYd, mrdihl me;sr ;sfí' tu ksid wmf.a ld¾h Ndrhg jvd;a WÑ; md,lh wmg myiqfjka f;dard.; yel' ;jo oDvdx.j,g wu;rj MICRO CHIP iud.u yd ta yd iu.dój 3 jeks md¾Yùh iud.ï o PIC MICRO CHIP i|yd ixj¾Ok uDÿldx. ksmehSfï kshe,S isà' fuu ksid wmg f;arsula iys;j fyd|u ixj¾Ok uDÿldx. o b;d wvq ñ,g ^fyda fkdñf,au& ,nd .ekSfï yelshdj mj;S' uhsfl%da lkafg%da,rfha l%shdldrS;ajh u;lh (MEMORY) yd ta yd wdY%s; frcsiag¾ mokï fldg f.k isÿfõ' PIC 16F84A wNHka;r ieleiau my; mrsos fõ'
3
Pin configuration of PIC 16F84A
Block diagram of 16F84A
uhsfl%da lkafg%da,rhg úÿ,sh iemhQ úg th ;udg imhd we;s l%u f,aLkh mrSCId fldg thg imhd we;s o;a; j,g wkql+,j mshjfrka mshjr ;u ld¾hNdrh bgq lrhs' m%odk (INPUT) mrSCIdj " l%u f,aLkfha we;s fyda ndysrska we;=,ajk o;a; hï hï ;d¾lsl ;;aj yd .Ks; l¾u j,g Ndckh lsrSu yd thg wkql+,j m%;sodk we;s lsrsu o fuu ld¾hNdrhg we;=<;a fõ' fuu ld¾hNdrh ld¾hCIuj lsrsu i|yd uhsfl%da lkafg%da,rfha fuursh m%Odk fldgia 2lg fnod we;' DATA MEMORY PROGRAM MEMORY
PROGRAM MEMORY uhsfl%da lkafg%da,rfha l%shd;aul jk l%uf,aLkh ^wms úiska PROGRAM lrk& r|jd .ekSu i|yd Ndú;d lrk ia:sr u;lh (NON VOLATILE MEMORY) fukñka ye|skafõ' PIC 16F84A WmlrKfha fuh FLASH j¾.fha EEPROM tlla jk w;r 1KB Odrs;djlska iukaú;h' DATA MEM fâgd fuursh o kej; fldgia 2lg fnod oelaúh yel' tkï SFR yd GPR hkqfjks' fuys GPR hkqfjka y÷kajkafka uhsfl%da lkafg%da, tfla /ï i|yd Ndú;d lr we;s u;l m%udKhhs' fuys ADDRESS tl OC isg 2F olajd mrdihl mj;S' ( 68 BYTE ). fuu u;lh l%u f,aLkh l%shd;aul jk w;r;=r we;s jk úp,Hhka r|jd ;eîu i|yd Ndú;d lrk ;djld,sl u;lhls' SFR hg;g .efkkafka uhsfl%da lkafg%da, tfla l%shdldrS;ajh i|yd fm,.iajd we;s ( PORTA ,TRISA, TIMER0) jeks úúO frcsiagrhkah' fï tl tl .ek iúia;rj ó<Õ mrsÉfPaofhka oek.; yel' o;a; yeisrùfï myiqj i|yd uq¿ fuurshu BANK 2 lg fnod ;sfí' Tn úúO frcsiagr j,ska lshjk yd tajdg ,shk úg kshñ; BANK tl SELECT lr we;s njg j.n,d .; hq;=h' 4
fuursh BANK 2 lg fnodwe;s wdldrh' PIC 16F84A úfYAIdx. PIC 16F84A uhsfl%da Ñma iud.u úiska Tjqkaf.a merKs 16C84 OTP uhsfl%da lkafg%da,h fjkqjg bosrsm;a lrk ,o FLASH ;dCIKfhka hq;a uhsfl%da lkafg%da,rhls' fuys úfYAIdx. my; oelafõ' • úOdk 35la muKs' • BRANCHING INSTRUCTION yereKq fldg wfkla ish¨u INSTRUCTION tl pl%hlska bgq lrhs' • 20MHz olajd l%shdl< yels >áldj (CLOCK INPUT) • jpk 1024 (1 KB) fm%da.%Eï fuursh • nhsÜ 68 l RAM tl • ìÜ 14 m<, úOdk jpkh( COMMAND WORD) • ìÜ 8 m<, o;a; jpkh ( DATA WORD ) • mshjr 8 oDvdx. STACK frcsiagrh • w.% 13 la m%Þk$ m%;sodk i|yd fjkafldg we;' • iEu w.%hgu 25mA Odrdjla oersh yels ksid LED iDcqju CHIP tlg iúl< yel' • ìÜ 8l oDvdx. TIMER folla (TIMERO iy WATCH DOG TIMER& • 10"000 jrla kej; ,súh yels fm%da.%Euh fuursh • 10"000"000 jrla kej; ,súh yels EEPROM tl • foda,l j¾. 3 f;dard .; yel'
5
PIC 16F84A MEMORY MAP
EEPROM
iiïNdù u;lh RAM
6
frcsiagAr uhsfl%da lkafg%da,rfha ls%hdldrS;Ajhg iyh jk uQ,sl ;ekqï tAllh jk fuh FLIP-FLOP 8 lA tl;= ùfukA iE§ we;¡
A GENARAL PURPOSE 8 BIT REGISTOR
W REGISTOR WORKING REGISTER kñka o ye|skafõ' PIC 16F ldKavfha uhsfl%da lkafg%da, j, frcsiag¾ w;r iDcqj o;a; yqjudre l, fkdyels ksid o;a; yqjudrej w;rueos frcsiagrh jYfhka w registor Ndú;d fõ' MOVFW 0X0C 0X0F FROM MEMORY LOCATION 0X0C
MOVWF PORTB 0X0F TO W REGISTOR
NOW TO PORTB
0X0F hk w.h 0X0C hk RAM LOCATION tfla isg PORTB tlg TRANSFER lsrSu'
ALU REGISTOR uhsfl%da lkafg%da,rh;=, .Ks; l¾u isÿlsrsu i|yd odhl jkafka fuu frcsiagrhhs' fuhg tl;= lsrsu" wvq lsrSu" fnoSu" jeä lsrsu hk uQ,sl .Ks; l¾u yereKq fldg (OR, NOR, NOT, AND, NAND, XOR, XNOR hkdoS nQ,shka .Ks; l¾u o BIT SHIFTING, BIT ROTATING wdoS BIT ORIENTED l%shdldrlï o l< yel' kuq;a 16F84 jeks uOHu mjqf,a uhsfl%da lkafg%da,r j, oS fuu .Ks; l¾u fndfyduhla uDÿldx. wdY%s;j flfrk ksid ta i|yd ie,lsh hq;= ld,hla .; fõ' ;j o fï i|yd ixlS¾K uDÿldx. Wml%u yd W.=,a Ndú;d l, hq;=h' kuq;a 18F xxx hk Wiia mjQ,a j, ALU tl ;=, øDvdx. wdY%s; .=Kl ( HARDWARE MULTIPLIERS ) we;s ksid b;d blaukska yd wvq uDÿldx. Woõ j,ska (LESS SOFTWARE SUPPORT ) .Kkh lr yel'
7
PROGRAM COUNTER uhsfl%da lkafg%da,r tfla ls%hd ldÍjk l%u f,aLKh PROGRAM MEMORY tl ;=, we;af;a fma,s jYfhks' iEu fma,sulgu wxlhla (ADDRESS) tlla we;' fuu fma,s ACCESS lsÍu i|yd fuu ADDRESS tl r|jdf.k isák frcsiagrh PROGRAM COUNTER kï fõ' fuh PROGRAM tl wdrïNfha§ fyda RESTART tfla§ 0000 0000 w.hla .kS' bka miq .Áld iamkaohla iu.( CLOCK PULSE) PROGRAM COUNTER tfla w.h tllska jeä fõ' ^00000001& bka miq ls%hd ldÍ jkafka fuu fmA,sfha we;s ùOdkhhs' fuf,i .Áld iamkaokfhka iamkaohg program counter tfla w.h tlska tl jeäfjñka úOdk l%shdfõ fhdojhs' fuu ms,sfj, CALL, GOTO, RETURN ,RETLW wd§ BRANCHING INSTRUCTIONS i|yd mukla fjkia fõ' STACK POINTER MAIN PROGRAM tl ls%hdldÍ jk w;r CALL jk SUBROUTINE j, RETURN ADDRESS tl r|jd .kakd frðiagrh fukñka yeÈkafõ' 16F84A uhsfl%da lkafg%da,rh ;=, we;af;a 8 LEVEL STACK tlls'
STACK POINTER
ls%hdldÍ;ajh
TIMER 0 16F84A ;=, we;s ìÜ 8 ghsu¾ foflka tlla jk fuh ndysr >Àld iamkaokhlska fyda SYSTEM CLOCK tflka ls%hd lrúh yel' fuu ghsurh øDvdx. ghsu¾ tlla ( HARDWERE TIMER) ksid uDÿldx. j,ska iajdh¾:j Èùug yelsùu o wu;r jdishls' tu ksid PROGRAM tl RUN jk w;r;=f¾u fuu ghsurho Èjúh yel'
8
WATCH DOG TIMER fuh moaO;s >Àldfjka (SYSTEM CLOCK) iajdhd¾:j Èfjk ìÜ 8 ghsurhls' fuhg >Àld iamkaoh ( CLOCK PULSE ) ,nd§u ioyd fuh ;=, msysgjQ RC cd,hla we;' fuh ilS%h l, yelafla l%uf,aLfha uq,skau we;s CONFIGURATION BITS j,ska WATCH DOG TIMER tl ON lsÍfuka muks' fuu TIMER tl 0000 0000 mgka f.k 1111 1111 ù kej; 0000 0000 jk úg (OVER FLOW) OUT PUT tlla we;s fõ' fu.ska we;s flfrk m%;sodkh uyska uhsfl%da lkafg%da,r tl RESET ;;ajhg m;a lrhs' fuu.ska uhsfl%da lkafg%da,r tl hï PROGRAM LOOP tll ysr ùfï (TRAP) wjodkfuka uqojd.; yel' fuu ghsu¾ 2 gu fmdÿjQ PRE SCALER kï l%uf,aLk l, yels .Kskh ( PROGRAMMABLE COUNTER ) u.ska fuu fuu TIMER j, m%odk ixLHd;h fn§ug ,la lrhs'fuu fn§u 2"4"16"18"32"64"128" fyda 256 jk mßÈ iSreudre lr yel' ^ fuh OPTION REGISTOR PS 0, PS 1 yd PS 2 hk BIT j,ska l, yel')
PRESCALER ALIGNMENT BIT CHART
9
CONFIGURATION BITS j,ska WATCH DOG TIMER tl ON lsrSu
10
STATUS REGISTER fuu frcsiagrfhka m%Odk jYfhkau flfrk ld¾hh jkafka ALU frcsiagrfha isÿ isÿ jk .Ks; l¾u j, m%;sM, j,ska fldgila m%o¾Ykh lsrsuhs'fuys RP0 ìÜ tflka MEMORY BANK SELECT lsrSuo , Z ìÜ tflka isÿ jqk .Ks; l¾uhl ms,s;=r 0 njo yÕjhs' C ìÜ tflka yÕjkafka .Ks; l¾uhl m%;sM,h CARRY fyda BORROW hk j.h'^ fuys wfkl=;a ìÜ .ek miqj l;d lruq'&
11
INTCON REGISTOR 16F84A ;=, we; jk bkagrmaÜ md,kh lsrSu INTCON REGISTOR u.ska isÿ lrhs' bkagrmaÜ hkq fudkjdo@@ bkagrmaÜ hkqfjka y`ÿkajkafka uhsfl%da fldkafgda,h ;=, msysgqjd we;s úfYaI hdka;%khls' fuh il%Sh lsÍu u.ska uhsfl%da fldkafgda,h bka¾maÜ we;s jk fudfydf;a ;rñka isák ld¾H l=ula jqj;a th kj;d l%uf,aLkfha wklrk mrsos Bg jvd jeo.;a ld¾hHla lsÍug fmd,Ujhs' tu ld¾hHh ksu jQ miq uhsfl%da fldkafgda,h kej; ;uqka uq,k s a lrñka isá ld¾Hh keje;ajQ ;ekska wdrïN lrhs' fuh uhsfl%da fldkafgda,fha ndysr f,dalh iu. iïnkaO ùfï§ b;d jeo.;ah' PIC16F84A INTERRUPT we;sjk l%u'
• PORT B ys 0 fjks BIT tlg fhdok INPUT tlla u.ska' ( RB0 INTERRUPT) ( TIMER0 INTERRUPT) • TIMER 0 OVER FLOW ùfuka • PORT B j, 4 fjks ìÜ tfla isg 7 jk ìÜ tl olajd we;s ìÜj, jk fjkialï j,ska ( PORTB CHANGE INTERRUPT) ( EEPROM WRITE COMPLTE • EEPROM WRITE CYCLE tlla bjr ùfïoS INTERRUPT)
fuu INTERRUPT l%shd;aul lsrSug m
12
PORT REGISTOR uhsfl%da fldkafgda,h ndysr f,dalh iu. iïnkaO ùu isÿlrkafka fuu fmda¾Ü frðiagr u.sks' PIC 16F84A ;=, fmda¾Ü frðiagr follss' fmda¾Ü A ìÜ 6 lska hqla; fmd¾Ü frðiagrhls' fuu frðiagrfha ´kEu BIT tlla INPUT tlla fyda OUTPUT tlla jYfhka úkHdi.; l, yel' fuh l, yelafla fmda¾Ü A REGISTER tlgu iene`ÿkq TRIS A kï frðiag¾ tl u.ska ' PORTA wÞ, BIT tlg iïnkao TRIS A BIT tl CLEAR l, úg Bg wkql+, PORT A BIT tl INPUT tl jYfhka úkHdi .; fõ' PORTAg iïnkaO TRISA BIT tl CLEAR l, úg PORT BIT tl OUTPUT tlla jYfhka úkHdi .; (CONFIGURE) fjhs' Tn úiska l%u f,aLk ,sùfï§ fuh b;d ie,ls,f a ,ka l, hq;=h' WÞyrKhla jYfhka OUTPUT jYfhka CONFIGURE l, PORT PIN tlla jer§ulska SWITCH tllg iïnkaO lsÍfuka CHIP tl ±ù hdfï wjÞkula mj;S'
PORTA iy TRISA w;r iïNkaoh'
PORTA mska tll leáigyk 13
PIC 16F84A uhsfl%da fldkafgda,h l=vdjg mj;ajd .ekSu i`oyd PORT PINS uhsfl%da fldkafgda,h we;=,; we;s iuyr fudähq, iu`. iïnkao lr we;' fuysÈ PORT A4 jk mska tl TIMER 0 yS EXTERNAL COLCK INPUT tl iu`. iïnkao lr we;' TIMER 0 il%Sh fldg OPTION REGISTOR tfla 5 jk ìÜ tl ( TOSC) ilS%h lsÍu ;=,ska PROT A 4 BIT tl iajhxl%Shj INPUT tlla jYfhka úkHdi.; fõ'
PORT A4jk mska tl TIMER 0 yS EXTERNAL COLCK INPUT tl iu`. iïNkao lr we;s wdldrh
14
fmda¾Ü B PIC 16F84A uhsfl%da fldkafgda,h ;=,msysgd we;s fuh 8 BIT BI DIRECTIONAL PORT tlls' fuhg ineÈ we;s TRIS B frðiagrh yryd PORT B frðiagrfha ´kEu BIT tlla fjka fjka jYfhka INPUT yd OUTPUT jYfhka úkHdi.; l, yel' óg wu;rj fmda¾Ü B tfla 0 jk BIT tl (RBO) EXTERNAL INTERRUPT INPUT tlla jYfhka ls%hd lrhs' ;jo wm úiska CHIP tl PROGRAM lrk úg fmda¾Ü B tfla 6 jk PIN tl SERIAL CLOCK PIN tl jYfhka o fmda¾Ü B tfla 7 jk PIN tl SERIAL DATA PIN tl jYfhkao ls%hd lrhs'
PORTB mska tll leáigyk
PORTB0 mska tfla leáigyk 15
EEPROM ia:sr u;lh PERMANENT MEMORY PIC 16F84A Tng 64 BYTE ia:sr u;lhlA ,nd oS we;' wm úiska EEPROM hkqfjka
y÷kajkafka o fuu u;lhhs' fuu u;lfha we;s úfYaI m%fhdackh kï moaO;sfhka úÿ,sh úikaê l< úg oS mjd fuu u;lfha we;s o;a; fkduels mej;Suhs' tu ksid Tng ld,hla mj;ajd .; hq;= úÿ,sh úikaêjQ úg mjd r|jd w.hla fuu bv m%udKfha ,shd ;nd .;yel' Tng idudkH frcsiagrhlg fuka EEPROM tlg ,sùug fyda thska lsheùug fkdyel' (CANNOT BE DIRECTLY ADDRESSED) tu ksid ta i|yd fjka jq úfYAI frcsiag¾ lÜg,hla yryd EEPROM ,sùu yd lsheùu isÿlrhs' EEDADR EEPROM
,sùfï oS yd lsheùfï oS ;sìh hqq;= DATA tl r|jk ADDRESS tl ,shkq ,nkafka fuu frcsig a rhghs' EEDATA EEPROM tlg ,sùfï oS fyda lsheùfï oS ;sìh hqq;= DATA tl ,shkq ,nkafka fyda
lshjkafka fuu frcsiagrhghs'
EECON1 & EECON2 EEPROM tlg ,sùu yd lsheùu i|yd md,l frcsiagr hq.,la jYfhkaa l%shd lrhs
^EEPROM .ek jeäÿrg wfma miqj mdvïj,ska n,dfmdfrd;A;=jkAk&
16
JDM fm%da.%Eurh Tng b;d wvq uqo,lska idÞ .; yels fuu fm%da.%Eurh fuu .%ka:h iu. Tng imhd we;s IC PROG uDÿldx.h iu. ls%hdlrK fm%da.%Eurhls'fuh idÞ .ekSug wjYH mrsm: igyk iy P.C.B igyk my; bosrs m;A lr we; '
DB 9 CONNECTOR
DB99 PIN OUTS
PCB igyk 17
uhsfl%da lkafg%da,rhg l%uf,aL ,sùug m%:u wm úiska uhsfl%da lkafg%d, a rh ls%hd lrùug wjYH wfkl=;A ndysr Wmlrk .ek wjfNdaohla ,nd .; hq;=h¡ uhsfl%da lkafg%da,r moaO;shl ;sìh hq;=u uQ,sl wjYH;d 3ls' 1 n, iemhqu (power supply) 2 >Àld iamkaoh (clock pulse) 3 rSfiÜ mrsm:h ( reset circuit )
n, iemhqu PIC 16F84A uhsfl%da lkafg%da,rh i|yd fyd|skA hdukh l, (REGULATED) 5V n,iemhqula wjYH fõ'Tng fuh my; oelafjk wdldrhg idÞ.; yel¡
>Àld iamkaoh PIC 16F84A uhsfl%da lkafg%da,rh ls%hdldÍ ùug ksh; ixLHd;hlskA ,nd fok iamkao wjYH fõ' fuu iamkao ksmoùu i|yd PIC 16F84A uhsfl%da lkafg%da,rh ;=, fÞa,lhla ^OSCILLATOR) we;' fuu fÞa,lhl ls%hdldÍ ùu i|yd msg;ska hï hï WmlrK iïNkao lsrSug wjYH fõ'
PIC 16F84A uhsfl%da lkafg%da,rhg ls%iag,hla iúlr we;s whqre
¡ 18
PIC 16F84A uhsfl%da lkafg%da,rhg frifkagrhla iúlr we;s whqre¡
PIC 16F84A uhsfl%da lkafg%da,rhg RC mrsm:hla iúlr we;s whqre¡
fuys olajd we;s l%u ;=fkka ´kEu l%uhla PIC 16F84A uhsfl%da lkafg%da,rh iu. Ndú;d l, yel'kuq;a Tn úiska Ndú;dlrk l%uh l%u f,aLKh ,shk úgoS fyda uhsfl%da lkafg%da,rhg FLASH lrk úgoS fyda i|yka l, hq;=h ¡ ;jo by, ksrjoH;djhla n,dfmdfrd;a;= jk mrsm: i|yd wksjdrHfhkau ls%iag,hla Ndú;d l, hq;=h ¡ l%u f,aLKh ,shk úgoS Configuration bits ieliSu u.ska
19
FLASH lrk úgoS IC PROG ys Configuration bits ieliSu u.ska
INSTRUCTION CYCLE PIC 16 F84A IC tlg fhdok l%siag,fha fyda RC mßm:fha ixLHd;h tys wNHka;r fÞda,lh úiska y;frkA fnÞ mdúÉÑhg .kq ,nhs' Tn úiska 4MHz l%siag,A tlla mdúÉÑ lf,d;a uhsfl%da lkafg%da,fha fÞda,lfha m%;sodk ixLHd;h 1MHz fõ' fuúg tys INSTRUCTION CYCLE tlla 1/ 10 -6 = 1 µS fuu w.h .;aúg ld, .kkhg b;d myiq fõ'
20
rSfiÜ mrsm:h rSfiÜ mrsm:h u.ska is¥ lrkafka uhsfl%da lkafg%da,rfha tu wjia:dfõ ^ rSfiÜ lrk& mj;sk ;;ajfha isg kej; uq,a ;;ajhg f.k tauhs ' rSfiÜ ùfïoS uhsfl%da lkafg%da,rfha SFR frcsiag¾ mukla rSfiÜ jk w;r GPR frcsiag¾ ( R.A.M ) fkdfjkiaj mj;S' rSfiÜ jk wjia:d lsysmhls' 1 n,h imhk wjia:dfõ rSfiÜ ùu Power on reset (POR) n,h imhd uhsfl%da lkafg%da,rh ls%hd lsrSu wdrïN ùug fmr uhsfl%da lkafg%da,rfha we;s ish¿u frcsiag¾ uq,a ;;ajhg f.k tau fuu.ska is¥fõ' 2 rSfiÜ w.%h ( MCLR ) - ú¥,s w.%h fj; iïNkao lsrSfuka yosis ;;ajhla hgf;a uhsfl%da lkafg%da,rh l%uf,aLhla ;=, ysr ùula isÿ úh yel( STUCK)' fujka wjia:djloS MCLR w.%h - ú¥,s w.%h fj; iïNkao lsrSfuka uhsfl%da lkafg%da,rh kej; uq,a ;;ajh fj; f.k wd yel'
WATCH DOG TIMER msrS hdfïoS isÿ jk RESET ùu ( RESET AT WDT OVERFLOW) WATCH DOG TIMER tl 0000 0000 mgka f.k 1111 1111 ù kej; 0000 0000 jk úg (OVER FLOW) OUT PUT tlla we;s fõ' fuu ld,h ^isg olajd fjkia fõ& fu.ska we;s flfrk m%;sodkh uyska uhsfl%da lkafg%da,r tl RESET ;;ajhg m;a lrhs' fuu.ska uhsfl%da lkafg%da,r tl hï PROGRAM LOOP tll ysr ùfï (TRAP) wjodkfuka uqojd .; yel' n,h iemhqu hï uÜgulg jvd wvq jQ úg we;sjk RESET ùu ( BROWN OUT RESET ) uhsfl%da lkafg%da,rhg imhd we;s úÿ,s n,h hï uÜgulg jvd wvqjQ úg ls%hd;aul fjñka mj;sk l%uf,aLkfha wjq,a we;sù wkjYH m%;sÞk we;súh yel'fujeks ;;aj j,lajd .ekSu i|yd n,h iemhqu hï uÜgulg jvd wvq jQ úg we;sjk RESET ùu ( BROWN OUT RESET) y÷kajd oS we;' kuq;a uhsfl%da lkafg%da,rhg kej; úÿ,sh ,enqk ú.iu tys we;s foda,l mrsm: ilS%h fkdfõ' tys we;s X TAL tl fyda RC mrsm:h ia:dhSS ùug hï ld,hla .;fõ'tu ksid úÿ,sh kej; iemhSfuka miq foda,lh ia:dhS ùug m%udkj;a ld,hla (72mS) ,ndoSug Wml%uhla PIC 16F84A imhdoS we;'fuh POWER UP TIMER kñka ye|skafõ' fuu POWER UP TIMER ilS%h lsrSu CONFIGURATION BITS ieliSu u.ska l,yel' POWER UP TIMER ilS%h lsrSfuka we;s jk m%;sM,h my; rEmfha fmkajd we;' 21
POWER UP TIMER ilS%h lsrSfuka we;s jk m%;sM,h
foda,l mrsm:h ia:dhSS ùu
22
by; oelafjkafka 16F84A uhsfl%da lkafg%da,rhg wÞ, INSTRUCTION SET tlhs'
23
uhsfl%d Ñma tlla fm%da.%Eï lrkafka flfiao@ uhsfl%d Ñma tlla fm%da.%Eï lsrSu i|yd my; i|yka foa wjYH fõ' COM PORT 1 la iys; mrs.Khla ^fï i|yd 233MHz muK l=vd mrs.Klhla jqjo iEfya'& 1' 2' 3' 4'
uhsfl%da fldkafg%da,hla ( PIC 16FXXX) uhsfl%da fldkafg%da,hg l%uf,aL ,sùu i|yd jevigykla ^fuysoS MPLAB) uhsfl%da fldkafg%da,hg PROGRAMM FLASH lsrsu i|yd fm%d. a Eurh ^fuys lshfjk mrsos idod .;a JDM fm%da.%Euh fyda Tn úiska ñ, oS .;a PM II jeks tlla& JDM fm%da.Eurh iu. Ndú;d lsrSug IC PROG uDÿldx.h
óg wu;rj PROGRAM lr.;a Ñma tl iu. l%shdlrùug fmdf;a lshejk mrsos wuqKd.;a mrsm:hla yd l=vd u,aá ógrhla q'
l%u f,aLKhla ,shuqs fï jk úg Tn uhsfl%da lkafg%da,h yd ta wdY%S; frðiagr .ek iEfyk wjfndaOhla ,nd we;ehs is;uq' fï jk úg m%dfhda.sl l%shdldr ;uka lrkakg Tn mq, mq,d n,d isákjdg ielhla ke;' tu ksid wm úiska l=vd l%uf,aLhla ,shuq' wms úiskau uhsfl%da lkafg%da,r wdOdrfhka LED n,anhla ksú ksù oe,aùug fla; igykla ,shuq' fuúg wmsg PIC 16F84A COMMANDS tlska tl meyeos,s lr .; yel'
fuysoS Tng lsjhq;= fohla we;' tkï uhsfl%da lkafg%da,rhg f;afrk NdId we;af;a tll muKla hkakhs' tkï oajdhx.S fyj;a (BINARY) NdIdjhs' kuq;a tu NdIdfjka wmg l%uf,aL ,sùu b;d ÿIalr lreKls' tu ksid wmg f;afrk NdIdjlska l%uf,aLh ,shd th uhsfl%da lkafg%da,rhg f;afrk NdIdjg yerùu i|yd ASSEMBLER tlla jYfhka y÷kajk uDÿldx. wjYH lrhs' wms fuysoS ASSEMBLER tlla jYfhka MPLAB IDE Ndú;d lruq'
LED n,anhla ksú ksù oe,aùug .e,Sï igyk
ASSEMBLER tlla u.ska wmg f;afrk NdIdjlska ,shQ l%uf,aLh uhsfl%da lkafg%da,rhg f;afrk NdIdjg
yrjhs 24
Tn úiska m
bkamiqj File > new u.ska w¨;a WORK SHEET tlla újD; lr.kak' bkamiqj Configure >select device u.ska wjYH uhsfl%da lkafg%da,h SELECT lr .kak'
25
my; l%uf,aLkh tyS TYPE lr.kak'
26
TYPE lr.;a l%u f,aLkh BLINK.ASM hk kñka DESKTOP tfla SAVE lrkak' Tn úiska by; mshjrj,a ksjerosj wkq.ukh lf
oeka Tn úiska fuu ASM FILE tl ALT+F10 hk KEY COMBINATION tl fyda Project rel="nofollow"> quick build u.ska COMPILE lr .kak
27
id¾:lj COMPILE jQfha kï fujeks mKqjqvhla ,efnk qwe;'
oeka Tn úiska ASM FILE tl SAVE l< ;ek mrSCId lr ne¨fjd;aa BLINK.LST , BLINK.ERR ,BLINK.HEX hk kï j,ska FILES fuys ;sfnkq oel .;yel' fuhska wms wfma Ñma tl fm%da.%Eï lasru S g fhdod .kafka BLINK .HEX kï FILE tlhs' fuh lsrsu i|yd Tn úiska ilid .kakd ,o JDM fm%da.%Euh yd IC PROG uDÿldx.h wjYH fõ' m%:uj IC PROG Tnf.a mrs.Klfha INSTALL lr.kak' bka miqj JDM fm%da.%Euh Tnf.a mrs.Klhg rEmfha mrsos iïNkAo lr.kak'
CONNECTING THE UNIT TO THE COM ( RS232 ) PORT OF YOUR PC
28
bkamiqj IC PROG újD; lr.kak' rEmfha mrsos m%:uj újD; lr .;a IC PROG Tnf.a mrs.Klhg .e,fmk mrsos úkHdi.; lr.; hq;=hs' fï i|yd SETTINGS > HARDWERE fukqfjka f;dard .kak' bkamiqj Tnf.a mrs.Klfha COM PORT tl isf,laÜ lr.; hq;=hs' fuysoS Tnf.a mrs' we;af;a COM PORT tlla kï yeuúgu th COM 1 f,i SELECT ù we;' COM PORT tlg jeä .Kkla we;akï wjYH COM PORT tl MENU tflka SELECT l< hq;h'
WINDOWS XP iu. IC PROG .e,mSu i|yd Setting > Option f.dia Enable NT / 2000/XP DRVER fpla fndlaia tl il%Sh lrkak' fuh lsrSug m%:uj Tng imhd we;s WINDOWS XP DRIVE tl WINDOWS SYSTEM DIRECTRY tfla IC PROG we;s iaa:dkhgu COPY
lrkak' óg wu;rj fukqfjka DIRECT IO SELECT l< úg Tng fuu CHIP tl jeä fõ.hlska FLASH l< yel' fuh lsrSug Tnf.a mrs.Klfha fufyhqï moaO;sh bv fkdfohs kï rEmfha mrsos API il%sh lrkak'^fuysoS .;jk ld,h u|la jeäh'&
29
fufia IC PROG CONFIGURE lr.;a miq FILE > OPEN FILE u.ska BLINK.HEX FILE tl OPEN lr.kak' bkamiqj PIC IC tl Tn idod.;a JDM PROGRAMER tfla IC SOCKET tlg iú lr.kak' fuúg JDM PROGRAMER we;s LED tl oe,aúh hq;=h' bkamiq u.ska BLINK.HEX FILE tl OPEN lr.kak' bkamiq CLICK lsrsu u.ska PIC tl fm%da.E% ï ùu wdrïN lrhs' fm%d. a %Eï ùfuka miq fm%da.%Eï ùu ksis mrsos ù we;aoehs ne,Sug VERIFIICATION CYCLE tlla o IC PROG u.skau fufyhjhs' Bg wu;rj ksis f,i PROGRAM jQjd kï hk wdldrfha mKsjqvhla osiafõ'
Tng
wjYH kï
CLICK lsrsu u.ska PIC tl kej; READ l, yel'
30
fm%da.%Eï lr.;a CHIP tl Tnf.a mrsm:hg iú lsrSug m%:u mrsm:h ksjerosoehs fyd|ska mrSCId fldg ne,Su uekú' IC SOCKET tfla +yd - PIN w;rg 5v meñfKaoehs u,aá ógrhla wdOdrfhka mrSCId lr n,kak' ish,a, ksjeros nj fmfka kï úÿ,sh úikaê fldg mrsm:hg IC tl iúlrkak' bka wk;=rej kej; úÿ,s iemhqu igyka lr .kak' LED tl ksù ksù oe,afjkq we;'
mrsm: igyk
31
fla; igyk meyeos,s lr .ksuq'
COMMENTS PROCESSOR RADIX INCLUDE FILE CONFIGURATION BITS
START (RESET VECTOR )
LABLE
COMMANDS( BLUE COLOUR) LABLE
DIRECTIVE
COMMENTS ; ,l=Kska (SEMICOLON) fjka lr ,shk fïjd l%uf,aLkfha oS l%shdldrS fkdfõ' úOdk weiqrska flfrk ld¾hhka" l%uf,aLkh ms<sn| úia;r wdoS foa ,sùug mdúÉÑ lrhs' fïjd fld< meyefhka osiafõ' PROCESSOR fuh Tn Ndú;d lrkafka l=uk uhsfl%da lkafg%da,rho hkak COMPLIER tlg oekaùu msKsi Ndú;d lrhs'
32
INCLUDE uhsfl%d lkafg%da,rfha we;s ish¿u REGISTERS yd MEMORY LOCATIONS j, ADDRESS fuu INCLUDE FILE tfla wvx.= fõ' Tn fuh Ndú;d fkdlrkafka kï l%uf,aLkh i|yd Ndú;d lrk ish¿u REGISTER , ADDRESS l%uf,aLkh ;=< i|yka l< hq;=h' RADIX Tfí l%uf,aaLkfha Ndú;d lrk ixLHd mdoh olajhs' fuh idudkHfhka 16 mdoh ( HEX) fõ'
CONFIGURATION BITS fuh Tng uhsfl%da lkafg%da,rh Ndú;dfõ§ f;arSï /ilg u. mdohs' 1. fÞa,l j¾. 4 ls' XT, RC , HS, LP 2. POWER UP TIMER ON lrkafkao OFF lrkafkao hk j.' 3. WATCH DOG TIMER ON lrkafkao OFF lrkafkao hk j.' 4. CODE PROTECT ON lrkafkao OFF lrkafkao hk j.' ORG 0X00 ( RESET VECTOR) fm%da.%Eï ljqkagrh .ekSu wdrïN lrkafka fu;ek isgh' l%uf,aLkh wdrïN l< ú.iu PROGRAM COUNTER h 00000000 jk ksid thg wod< f,an,h fidhd f.dia th l%shdfõ fhdojhs' óg wu;rj l=uk fyda j._hl RESET tllska miqj jqjo PROGRAM COUNTER h 00000000 njg m;a fõ' LABEL fuh úOdk lKavhla" iíreàkhlaa jeks l%shdldrS fla; lKavhla kï lsrsug fhdod .kS' GOTO , CALL hk úOdkhka iu. fuu LABEL fhdod .kS' f,an,hlg úOdkj, kï fyda i,l=Kq yereK úg idudkHfhka ´kEu kula fhdod .; yel' GOTO fyda CALL hk úOdkh iu. f,an,a kula ÿgqúg PROGRAM COUNTER h tu f,an,fha ADDRESS tl ,ndf.k tu f,an,h fj;g fhduq ù t;ek isg PROGRAM tl EXECUTE lrhs' úOdk (COMMANDS) l%uf,aLkfha oS ienEjgu il%Sh fjñka l%shdlrkafka fïjdh' PIC16FXXX ldKavfha Ñmaia j, úOdk 35ls' END l%uf,aaLk i|yd w;HjYH DIRECTIVE tlls' PROGRAM tfla wjidkh olajhs'
BANKSEL DIRECTIVE tlls' BANK SELECT lsrsug fhdod .kS' BANKSEL úOdkhka iu. wjYH REGISTER tflA ku fhdod .kS' BANKSEL TRISA BANKSEL PORTA
33
COMMANDS meyeos,s lr .ksuq'
BSF PORTB, 0 fuu command tflka lshefjkafka PORT B tfla 0 jk BIT tl SET l< hq;= njhs' tkï fuh l%shdfõ fhoùfï oS PORT B tfla 0 jk PIN tlg iïnkaO FILE FLOP tl fiÜ ù (ON ù& thg iïnkaO FET tl yryd Odrdjla .,dhdu ksid LED n,anh oe,afõ' fï whqrska Tng ´kEu PORT tll PIN tll SET l< yel' Wod BSF PORTA,1
BCF PORTB, 0 fuu COMMAND tflka lshefjkafka PORT B tfla jk BIT tl CLEAR l< hq;= njhs' fuu úOdkh l%shdfõ fhoùfï oS PORT B tfla jk PIN tlg iïnkaO FILE FLOP tl CLEAR ù FET tl yryd Odrdjla .,dhdu kej;sSu ksid LED n,anh OFF fõ'
CALL fuu úOdkh BRANCHING INSTRUCTION .khg .efkk SUBROUTINES le|ùu i|yd Ndú;d lrk úOdkhls' l%u f,aLkhg ks;r Wjukd jk fla; lKavhka ks;r ks;r ,sùu j,lajd .ekSug iírEáka tllsa jYfhka ;ekl ,shd ;nd wmg wjYH jQ úg CALL l< yel' CALL hk úOdkh iu. f,an,a kula^ fuysoS DELAY) ÿgqúg PROGRAM COUNTER h tu f,an,fha ADDRESS tl ,ndf.k tu f,an,h fj;g fhduq ù t;ek isg PROGRAM tl EXECUTE
lrhs' iírEákh RETURN kï úOdkfhka wjika fõ' fuu RETURN úOdkh ÿgq úg iíreàkh le| jQ úOdkhg my, úOdkfha isg fm%da.%Euh kej; l%shdlrf.k hhs' 34
CALL úOdkh l%shdlrk whqre
GOTO fuu úOdkho
úOdkh fukau BRANCHING INSTRUCTION .khg .efkk úOdkhls'fuys we;s fjki kï CALL tllg fuka RETURN tllA fkdue;s ùuhs'GOTO úOdkh yuqjQ úg PROGRAM COUNTER tl GOTO úOdkh iu. we;s f,an,fha^ fuysoS BLINK) ADRESS tl UPLOAD lr f.k tu f,an,h fj;g fhduq ù t;ek isg PROGRAM tl EXECUTE lrhs' CALL
35
Delay iíreàkhla jYfhka le|jd we;s fuu fla; lKavh Ndú;d lr we;af;a hï lsis ld,hla f.jd oeóu i|yd h' Tn fuu DELAY tl ke;sj l%u f,aLkh l%shd;aul lf
36
CLRF
CLEAR FILE
fuu úOdkfhka lshfjkafka kï lrk DATA FILE tll ish¿u BIT RESET l, hq;= njh' CLRF TRISB KNIGHT RIDER l%uhg n,anh oe,aùu (BSF iy BCF hk úOdk weiqrska)
;************************************************************ ; LED RUN (using bsf & bcf commands) . ;written by achala samapriya( micro house ) ;started on 2007/01/30 ;************************************************************** processor PIC16F84A ;Set the processor radix hex ;Set the radix #include ;Include header file __CONFIG _RC_OSC & _PWRTE_OFF & _CP_OFF & _WDT_OFF Start
ORG 0x00
BANKSEL TRISA ; SELECT BANK 1 CLRF TRISA ; MAKE PORTA AN OUTPUT CLRF TRISB ; MAKE PORTB AN OUTPUT BANKSEL PORTA ; SELECT BANK 1 MAIN BSF PORTB,0 ;B0 ON CALL DELAY ;WAIT BCF PORTB,0 ;B0 OFF BSF PORTB,1 CALL DELAY BCF PORTB,1 BSF PORTB,2 CALL DELAY BCF PORTB,2 BSF PORTB,3 CALL DELAY BCF PORTB,3 BSF PORTB,4 CALL DELAY BCF PORTB,4 BSF PORTB,5 CALL DELAY BCF PORTB,5 BSF PORTB,6 CALL DELAY BCF PORTB,6 BSF PORTB,7 CALL DELAY BCF PORTB,7 BSF PORTB,6 37
CALL DELAY BCF PORTB,6 BSF PORTB,5 CALL DELAY BCF PORTB,5 BSF PORTB,4 CALL DELAY BCF PORTB,4 BSF PORTB,3 CALL DELAY BCF PORTB,3 BSF PORTB,2 CALL DELAY BCF PORTB,2 BSF PORTB,1 CALL DELAY BCF PORTB,1 GOTO MAIN
; LOOP AGAIN
DELAY MOVLW 0X29 ;DELAY FOR 10mS ( These timing were based on 4Mhz x'tal) MOVWF 0CH S2 DECFSZ 0CH,1 ; GOTO DELAY2.1 RETURN DELAY2.1 MOVLW 52H MOVWF 0DH S1 DECFSZ 0DH,1 GOTO S1 GOTO S2 END
38
KNIGHT RIDER l%uhg n,anh oe,aùu (MOVLW iy MOVWF hk úOdk weiqrska)) ************************************************************ ; LED BLINK. ;written by achala samapriya ;started on 2006/04/08 ;************************************************************** processor PIC16F84A ;Set the processor radix hex ;Set the radix #include ;Include header file __CONFIG _RC_OSC & _PWRTE_OFF & _CP_OFF & _WDT_OFF Start
ORG 0x00
BANKSEL TRISA ; SELECT BANK 1 CLRF TRISA ; MAKE PORTA AN OUTPUT CLRF TRISB ; MAKE PORTB AN OUTPUT BANKSEL PORTA ; SELECT BANK 1 BLINK MOVLW B'00000000' MOVWF PORTB CALL DELAY2 MOVLW B'00000001' MOVWF PORTB CALL DELAY2 MOVLW b'00000010' MOVWF PORTB CALL DELAY2 MOVLW B'00000100' MOVWF PORTB CALL DELAY2 MOVLW B'00001000' MOVWF PORTB CALL DELAY2 MOVLW B'00010000' MOVWF PORTB CALL DELAY2 MOVLW B'00100000' MOVWF PORTB CALL DELAY2 MOVLW B'01000000' MOVWF PORTB CALL DELAY2 MOVLW B'10000000' MOVWF PORTB CALL DELAY2 MOVLW B'01000000' MOVWF PORTB CALL DELAY2 MOVLW B'00100000' MOVWF PORTB 39
CALL DELAY2 MOVLW B'00010000' MOVWF PORTB CALL DELAY2 MOVLW B'00001000' MOVWF PORTB CALL DELAY2 MOVLW B'00000100' MOVWF PORTB CALL DELAY2 MOVLW B'00000010' MOVWF PORTB CALL DELAY2 MOVLW B'00000001' MOVWF PORTB CALL DELAY2 CLRF PORTB GOTO BLINK DELAY2 MOVLW 0X29 ;DELAY FOR 10mS ( These timing were based on 4Mhz x'tal) MOVWF 0CH S2 DECFSZ 0CH,1 ; GOTO DELAY2.1 RETURN DELAY2.1 MOVLW 52H MOVWF 0DH S1 DECFSZ 0DH,1 GOTO S1 GOTO S2 RETURN
END Tn fumuK fõ,d khsÜ rhsâ l%uhg n,an ±,aùug Ndú;d l, ùOdk .kkdjlska hq;= È. fÄ;hla fkao" fukak tA fjkqjg flá l%uhla RLF úOdkh' RLF ROTATE FILE LEFT fmda¾Ü frðiagrhg we;=,a lrk hï w.hla fuu.ska jdud¾:j p,kh lr .; yel' WÞ (- MOVLW 0X01 ; MOVE 00000001 BINARY TO W REGISTOR MOVWF PORTB ; MOVE THAT VALUE TO PORTB ROTATE RLF PORTB,1 ; ROTATE THE VALUE IN PORT B LEFT GOTO ROTATE ;DO THIS FOR EVER RRF úOdkh' fmda¾Ü frðiagrhg we;=,a lrk hï w.hla fuu.ska ol=Kg p,kh lr .; yel' RRF ROTATE FILE RIGHT WÞ (- MOVLW 0X80 ; MOVE 1000000 BINARY TO W REGISTOR MOVWF PORTB ; MOVE THAT VALUE TO PORTB ROTATE RRF PORTB,1 ; ROTATE THE VALUE IN PORT B LEFT GOTO ROTATE ;DO THIS FOR EVER 40
KNIGHT RIDER l%uhg n,anh oe,aùu (RLF iy RRF hk úOdk weiqrska))
;************************************************************ ; LED RUN (using rlf & rrf commands) ;written by achala samapriya( micro house ) ;started on 2007/01/30 ;************************************************************** processor PIC16F84A ;Set the processor radix hex ;Set the radix #include ;Include header file __CONFIG _RC_OSC & _PWRTE_OFF & _CP_OFF & _WDT_OFF Start
ORG 0x00
BANKSEL TRISA ; SELECT BANK 1 CLRF TRISA ; MAKE PORTA AN OUTPUT CLRF TRISB ; MAKE PORTB AN OUTPUT BANKSEL PORTA ; SELECT BANK 1 MOVLW 0X01 MOVWF PORTB LEFT CALL DELAY RLF PORTB,1 CALL DELAY BTFSS PORTB,7 GOTO LEFT GOTO RIGHT RIGHT CALL DELAY RRF PORTB,1 CALL DELAY BTFSS PORTB,0 GOTO RIGHT GOTO LEFT
DELAY MOVLW 0X29 ;DELAY FOR 10mS ( These timing were based on 4Mhz x'tal) MOVWF 0CH S2 DECFSZ 0CH,1 GOTO DELAY2.1 RETURN DELAY2.1 MOVLW 52H MOVWF 0DH S1 DECFSZ 0DH,1 GOTO S1 GOTO S2 END 41
KNIGHT RIDER SHADOW l%uhg n,anh oe,aùu (RLF iy RRF hk úOdk weiqrska) ;************************************************************ ; LED RUN (shadows using rlf & rrf commands) ;written by achala samapriya( micro house ) ;started on 2007/01/30 ;************************************************************** processor PIC16F84A ;Set the processor radix hex ;Set the radix #include ;Include header file __CONFIG _RC_OSC & _PWRTE_OFF & _CP_OFF & _WDT_OFF Start
ORG 0x00
BANKSEL TRISA CLRF TRISA CLRF TRISB BANKSEL PORTA MOVLW 0XFE MOVWF PORTB BSF STATUS,C LEFT CALL DELAY RLF PORTB,1 CALL DELAY BTFSC PORTB,7 GOTO LEFT GOTO RIGHT RIGHT CALL DELAY RRF PORTB,1 CALL DELAY BTFSC PORTB,0 GOTO RIGHT GOTO LEFT
; SELECT BANK 1 ; MAKE PORTA AN OUTPUT ; MAKE PORTB AN OUTPUT ; SELECT BANK 1
DELAY MOVLW 0X29 ;DELAY FOR 10mS ( These timing were based on 4Mhz x'tal) MOVWF 0CH S2 DECFSZ 0CH,1 GOTO DELAY2.1 RETURN DELAY2.1 MOVLW 52H MOVWF 0DH S1 DECFSZ 0DH,1 GOTO S1 GOTO S2 END 42
mrsm: igyk m%odk mrSCIdj Tn fuf;la fõ,d l, ish¨u l%uf,aLk uhsfl%d Ñma tl ;=<ska m%;sodkhkla (OUT PUT) ,nd.ekSug ie
oeka 0 jk ìÜ tfla iaúÉ tl TnoaoS LED tl oe,aùug o 1 ìÜ tlg iïnkaO o iaúÉ tl TnoaoS ksùug o i
TO PORTA,0
GND COMMAND BTFSC BIT TEST FILE SKIP IF CLEAR fuu úOdkfhka lshfjkafk kïlr we;s BIT tl CLEAR jQ úg fmA,shlA mekAkúh hq;= njh'
WAIT BTFSC PORTA , 0 GOTO WAIT BSF PORTB,0 END 44
PIC SIMIULATOR IDE
fuh o fm%da.%Eï lsrSfï oS b;d jákd uDÿldx.hls' Ñma tl fm%da.%Eï lr mrsm:hg iú lsrSug fmr fuu uDÿldx.h u.ska fla;h l%shdldrS jk wdldrh isñhqf,aÜ lr ne,sh yel' tu ksid hï jrolska Ñma tl oeù hdfï wjOdku fuu.ska j SELECT MICROCONTROLLER u.ska ,efnk fukqfjka PIC16F84A isf,laÜ lr .kak' bkamiqj FILE > LOAD PROGRAM u.ska BLINK.HEX *hs,a OPEN lr .kak' TOOLS > MICROCONTROLER VIEW u.ska Tng IC tfla PIN LAYOUT tl ,nd.; yel' bka wk;=rej SIMIULATION >1 START u.ska Tng l%uf,aLkh m%;sodkh ANIMATE lr n,d.; yel' ^fuysoS .;jk ienE ld,h fjkqjg b;d os.= ld,hla .;jk ksid Tnf.a l%uf,aLfha we;s ish¨u DELAY COMMENT lsrsu u.ska fyda fjkhï l%uhlska wl%h S lsrSug j.n,d.kak' tfiaa fkdue;s kï Tng oS¾> fõ,djla n,d isàug jkq we;' & 45
fuh ud úiska ,shQ rgd .Kkdjlska we;s LED mßm:hls' thg wka;¾.; ù we;af;a ud úiska Tng imhd we;s fuu úOdk lSmh mukS' Tn;a fujeks rgd msysgqjk l%u f,aLkhka ,sùug W;aiy lrkak' th id¾:l jQfha kï Tn fukau udo i;=gq jkq we;' ;************************************************************ ;various light patterns. ;written by achala samapriya ;started on 2006/04/08 ;************************************************************** processor PIC16F84A ;Set the processor radix hex ;Set the radix #include ;Include header file __CONFIG _RC_OSC & _PWRTE_OFF & _CP_OFF & _WDT_OFF ERRORLEVEL -302 Start ORG 0x00 INDEX EQU 0X0C LROOM EQU 0X0D HROOM EQU 0X0E COMP EQU 0X0F MAP EQU 0X10 GOTO MAIN MAIN BANKSEL TRISA CLRF TRISA CLRF TRISB BANKSEL PORTA CLRF PORTA CLRF PORTB LVE MOVLW 0X03 MOVWF INDEX L_RUN BCF STATUS,C MOVLW 0X01 MOVWF PORTB CALL DELAY2 ROT RLF PORTB,1 CALL DELAY2 BTFSS PORTB,7 GOTO ROT GOTO ECS ECS BCF STATUS,C DECFSZ INDEX,1 GOTO L_RUN GOTO RVE
;SET BOTH AS OUT PUTS
;RUNS LEFT
46
RVE MOVLW 0X03 MOVWF INDEX R_RUN BCF STATUS,C MOVLW 0X80 MOVWF PORTB CALL DELAY2 RRT RRF PORTB,1 CALL DELAY2 BTFSS PORTB,0 GOTO RRT GOTO RCS RCS BCF STATUS,C DECFSZ INDEX,1
;RUNS RIGHT
GOTO R_RUN GOTO KNT KNT MOVLW 0X03 MOVWF INDEX KL_RUN BCF STATUS,C MOVLW 0X01 MOVWF PORTB CALL DELAY2 KROT RLF PORTB,1 CALL DELAY2 BTFSS PORTB,7 GOTO KROT GOTO KECS KECS BCF STATUS,C GOTO KR_RUN
; BOTH DERECTIONS
KR_RUN BCF STATUS,C MOVLW 0X80 MOVWF PORTB CALL DELAY2 KRRT RRF PORTB,1 CALL DELAY2 BTFSS PORTB,0 GOTO KRRT GOTO KRCS KRCS BCF STATUS,C DECFSZ INDEX,1 GOTO KL_RUN GOTO FRILL
FRILL 47
MOVLW 0X03 MOVWF INDEX F1 ;FILL EFFECT MOVLW 0X00 MOVWF PORTB CALL DELAY2 MOVLW 0X01 MOVWF PORTB CALL DELAY2 MOVLW 0X03 MOVWF PORTB CALL DELAY2 MOVLW 0X07 MOVWF PORTB CALL DELAY2 MOVLW 0X0F MOVWF PORTB CALL DELAY2 MOVLW 0X1F MOVWF PORTB CALL DELAY2 MOVLW 0X3F MOVWF PORTB CALL DELAY2 MOVLW 0X7F MOVWF PORTB CALL DELAY2 MOVLW 0XFF MOVWF PORTB CALL DELAY2 MOVLW 0XFE MOVWF PORTB CALL DELAY2 MOVLW 0XFC MOVWF PORTB CALL DELAY2 MOVLW 0XF8 MOVWF PORTB CALL DELAY2 MOVLW 0XF0 MOVWF PORTB CALL DELAY2 MOVLW 0XE0 MOVWF PORTB CALL DELAY2 MOVLW 0XC0 MOVWF PORTB CALL DELAY2 MOVLW 0X80 MOVWF PORTB CALL DELAY2 CLRF PORTB CALL DELAY2 48
MOVLW 0X80 MOVWF PORTB CALL DELAY2 MOVLW 0XC0 MOVWF PORTB CALL DELAY2 MOVLW 0XE0 MOVWF PORTB CALL DELAY2 MOVLW 0XF0 MOVWF PORTB CALL DELAY2 MOVLW 0XF8 MOVWF PORTB CALL DELAY2 MOVLW 0XFC MOVWF PORTB CALL DELAY2 MOVLW 0XFE MOVWF PORTB CALL DELAY2 MOVLW 0XFF MOVWF PORTB CALL DELAY2 MOVLW 0X7F MOVWF PORTB CALL DELAY2 MOVLW 0X3F MOVWF PORTB CALL DELAY2 MOVLW 0X1F MOVWF PORTB CALL DELAY2 MOVLW 0X0F MOVWF PORTB CALL DELAY2 MOVLW 0X07 MOVWF PORTB CALL DELAY2 MOVLW 0X03 MOVWF PORTB CALL DELAY2 MOVLW 0X01 MOVWF PORTB CALL DELAY2 MOVLW 0X00 MOVWF PORTB CALL DELAY2 DECFSZ INDEX,1 GOTO F1 SHADOW SNT MOVLW 0X05
;SHADOW EFFECT
49
MOVWF INDEX SL_RUN CLRF PORTB BSF STATUS,C MOVLW 0XFE MOVWF PORTB CALL DELAY2 SROT RLF PORTB,1 CALL DELAY2 BTFSC PORTB,7 GOTO SROT GOTO SECS SECS BCF STATUS,C GOTO SR_RUN SR_RUN BSF STATUS,C MOVLW 0X7F MOVWF PORTB CALL DELAY2 SRRT RRF PORTB,1 CALL DELAY2 BTFSC PORTB,0 GOTO SRRT GOTO SRCS SRCS BCF STATUS,C DECFSZ INDEX,1 GOTO SL_RUN GOTO DOUBLE DOUBLE MOVLW 0X05 MOVWF INDEX DD MOVLW 0X81 MOVWF PORTB CALL DELAY2 MOVLW 0X42 MOVWF PORTB CALL DELAY2 MOVLW 0X24 MOVWF PORTB CALL DELAY2 MOVLW 0X18 MOVWF PORTB CALL DELAY2 MOVLW 0X24 MOVWF PORTB CALL DELAY2 MOVLW 0X42 MOVWF PORTB CALL DELAY2 MOVLW 0X81 MOVWF PORTB 50
CALL DELAY2 DECFSZ INDEX,1 GOTO DD GOTO D_FILL D_FILL MOVLW 0X05 MOVWF INDEX DF MOVLW 0X00 MOVWF PORTB CALL DELAY2 MOVLW 0X18 MOVWF PORTB CALL DELAY2 MOVLW 0X3C MOVWF PORTB CALL DELAY2 MOVLW 0X7E MOVWF PORTB CALL DELAY2 MOVLW 0XFF MOVWF PORTB CALL DELAY2 MOVLW 0XE7 MOVWF PORTB CALL DELAY2 MOVLW 0XC3 MOVWF PORTB CALL DELAY2 MOVLW 0X81 MOVWF PORTB CALL DELAY2 MOVLW 0X00 MOVWF PORTB CALL DELAY2 DECFSZ INDEX,1 GOTO DF GOTO REV_FILL REV_FILL MOVLW 0X05 MOVWF INDEX RF MOVLW 0X81 MOVWF PORTB CALL DELAY2 MOVLW 0XC3 MOVWF PORTB CALL DELAY2 MOVLW 0XE7 MOVWF PORTB CALL DELAY2 MOVLW 0XFF 51
MOVWF PORTB CALL DELAY2 MOVLW 0XE7 MOVWF PORTB CALL DELAY2 MOVLW 0XC3 MOVWF PORTB CALL DELAY2 MOVLW 0X81 MOVWF PORTB CALL DELAY2 CLRF PORTB CALL DELAY2 DECFSZ INDEX,1 GOTO RF GOTO SHIFT SHIFT MOVLW 0X10 MOVWF INDEX SS MOVLW 0XAA MOVWF PORTB CALL DELAY2 MOVLW 0X55 MOVWF PORTB CALL DELAY2 DECFSZ INDEX,1 GOTO SS BLINK MOVLW 0X0A MOVWF INDEX BB CLRF PORTB MOVLW 0XFF MOVWF PORTB CALL DELAY2 MOVLW 0X00 MOVWF PORTB CALL DELAY2 DECFSZ INDEX,1 GOTO BB LOAD CLRF PORTB CALL DELAY2 MOVLW 0X01 MOVWF LROOM MOVLW 0XFF MOVWF HROOM LD MOVLW 0XFF MOVWF PORTB CALL DELAY_PWM1 CLRF PORTB CALL DELAY_PWM2 52
MATH INCF LROOM,1 DECF HROOM,1 MOVLW 0X00 MOVWF COMP SUBWF HROOM,0 BTFSS STATUS,Z GOTO LD LUAD MOVLW 0XFF MOVWF LROOM MOVLW 0X01 MOVWF HROOM LE MOVLW 0XFF MOVWF PORTB CALL DELAY_PWM1 CLRF PORTB CALL DELAY_PWM2 BATH DECF LROOM,1 INCF HROOM,1 MOVLW 0X00 MOVWF COMP SUBWF HROOM,0 BTFSS STATUS,Z GOTO LE GOTO LVE DELAY_PWM1 MOVF LROOM,W ;DEALY FOR OUT PUT MOVWF 0X24 OS2 DECFSZ 0X24,1 GOTO DELAY2.10 RETURN DELAY2.10 MOVLW 0X10 MOVWF 0X25 OS1 DECFSZ 0X25,1 GOTO OS1 GOTO OS2
DELAY_PWM2 MOVF HROOM,W ;DEALY FOR OUT PUT MOVWF 0X26 S2 DECFSZ 0X26,1 GOTO DELAY2.10 RETURN DELAY2.1 MOVLW 0X10 MOVWF 0X27 S1 DECFSZ 0X27,1 53
GOTO S1 GOTO S2 GOTO OS2 REV DELAY2 MOVLW 0XFF ;DEALY FOR OUT PUT MOVWF 0X3A OIS2 DECFSZ 0X3A,1 GOTO IDELAY2.10 RETURN IDELAY2.10 MOVLW 0XFF MOVWF 0X3B OIS1 DECFSZ 0X3B,1 GOTO OIS1 GOTO OIS2
END
54
55
56
57
58