{"id":172,"date":"2009-11-17T22:35:20","date_gmt":"2009-11-18T03:35:20","guid":{"rendered":"http:\/\/elegans.uky.edu\/blog\/?p=172"},"modified":"2009-11-17T22:35:20","modified_gmt":"2009-11-18T03:35:20","slug":"pic-first-light","status":"publish","type":"post","link":"http:\/\/jimlund.org\/blog\/?p=172","title":{"rendered":"PIC first light!"},"content":{"rendered":"<p>Got my first PIC microprocessor program running on a PIC12F683.<\/p>\n<p>It has one light that is always on and a second that switches on\/off.<\/p>\n<p>PIC12F683 LED lighting movie:<br \/>\n <object width='480' height='360' id='flvPlayer'><param name='allowFullScreen' value='true'><\/param><param name='movie' value='player.swf?movie=pics\/PIC12F683_LED.flv&#038;bgcolor=0x051615&#038;fgcolor=0x13ABEC&#038;volume=80&#038;autoload=on&#038;autorewind=on&#038;clickurl=&#038;clicktarget=_self&#038;postimage='><embed src='player.swf?movie=pics\/PIC12F683_LED.flv&#038;bgcolor=0x051615&#038;fgcolor=0x13ABEC&#038;volume=80&#038;autoload=on&#038;autorewind=on&#038;clickurl=&#038;clicktarget=_self&#038;postimage=' width='480' height='360' allowFullScreen='true' type='application\/x-shockwave-flash'><\/embed><\/param><\/object><\/p>\n<p>The assembler code:<\/p>\n<pre>\n----------------------------------------------------------------------------\n;************************************\n;written by: Jim Lund\n;date: 11-09\n;version: 1.00\n;for PIC: PIC12F683\n;Memory: 2048=800h, RAM 128, EEPROM 256\n;clock frequency:\n;************************************\n; PROGRAM FUNCTION: Light one LED\n;\n;************************************\n\n        list      P = PIC12F683\n\n        include  &#47;usr&#47;local&#47;share&#47;gputils&#47;header&#47;p12f683.inc\n\n        __config _MCLRE_OFF &amp; _INTRC_OSC_NOCLKOUT &amp; _CP_OFF &amp; _WDT_OFF\n\n        errorlevel -302\n\n;------------------------\n;Declarations:\n        org     0x000\n        goto    Start\n\n;-----------------------\n;Subroutines:\n\nInit\n\n        clrf    STATUS;\n        clrf    GPIO ; resets input\/output ports\n\n        bsf     STATUS,RP0 ;Bank 1\n        ;movlw  b'00000000'\n        ;movwf  OSCTUNE\n\n        bcf     STATUS,RP0 ;Bank 0\n        movlw   b'00000111'     ;comparator off\n        movwf   CMCON0  ;digital IO\n        bsf     STATUS,RP0 ;Bank 1\n        clrf    ANSEL   ; digital IO\n\n        movlw   b'001111'      ; sets up which GPIO pins are inputs and which\n        movwf   TRISIO          ; are outputs\n\n        movlw   b'00000111'      ; option bits\n        movwf   OPTION_REG\n        bcf     STATUS,RP0 ;Bank 0\n        retlw   0\n;-------------------------\n;Program Start:\nStart\n        call   Init\nMain\n        bsf     GPIO, 4  ; turns on LED\n\n        btfss   GPIO, 0 ;test pin 7, next if pin is 0\n        goto LEDoff\n        bsf     GPIO, 5 ; turns on LED\n        goto Main\n\nLEDoff  bcf     GPIO, 5 ; turns off LED\n        goto Main\n\n        END\n----------------------------------------------------------------------------\n<\/pre>\n<p>Assembly of the .asm to a .hex:<br \/>\n>gpasm p12_led.asm<\/p>\n<p>Write it to the PIC12 using:<br \/>\nwine &#8220;C:\\Program Files\\PICPgm\\WinPICPgm.exe&#8221;<\/p>\n<p>and wire it up as shown in the video!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got my first PIC microprocessor program running on a PIC12F683. It has one light that is always on and a second that switches on\/off. PIC12F683 LED lighting movie: The assembler code: &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- ;************************************ ;written by: Jim Lund ;date: 11-09 ;version: 1.00 ;for PIC: PIC12F683 ;Memory: 2048=800h, RAM 128, EEPROM 256 ;clock frequency: ;************************************ ; PROGRAM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-172","post","type-post","status-publish","format-standard","hentry","category-hobbies"],"_links":{"self":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=172"}],"version-history":[{"count":0,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/172\/revisions"}],"wp:attachment":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}