PIC first light!

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:

;written by: Jim Lund
;date: 11-09
;version: 1.00
;for PIC: PIC12F683
;Memory: 2048=800h, RAM 128, EEPROM 256
;clock frequency:

        list      P = PIC12F683

        include  /usr/local/share/gputils/header/p12f683.inc

        __config _MCLRE_OFF & _INTRC_OSC_NOCLKOUT & _CP_OFF & _WDT_OFF

        errorlevel -302

        org     0x000
        goto    Start



        clrf    STATUS;
        clrf    GPIO ; resets input/output ports

        bsf     STATUS,RP0 ;Bank 1
        ;movlw  b'00000000'
        ;movwf  OSCTUNE

        bcf     STATUS,RP0 ;Bank 0
        movlw   b'00000111'     ;comparator off
        movwf   CMCON0  ;digital IO
        bsf     STATUS,RP0 ;Bank 1
        clrf    ANSEL   ; digital IO

        movlw   b'001111'      ; sets up which GPIO pins are inputs and which
        movwf   TRISIO          ; are outputs

        movlw   b'00000111'      ; option bits
        movwf   OPTION_REG
        bcf     STATUS,RP0 ;Bank 0
        retlw   0
;Program Start:
        call   Init
        bsf     GPIO, 4  ; turns on LED

        btfss   GPIO, 0 ;test pin 7, next if pin is 0
        goto LEDoff
        bsf     GPIO, 5 ; turns on LED
        goto Main

LEDoff  bcf     GPIO, 5 ; turns off LED
        goto Main


Assembly of the .asm to a .hex:
>gpasm p12_led.asm

Write it to the PIC12 using:
wine “C:\Program Files\PICPgm\WinPICPgm.exe”

and wire it up as shown in the video!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>