Ok, so I wrote up my first attempt at a program using assembly for the 16F268A (its what I've got). I was wondering if you could look over what I wrote and tell me if I made mistakes.
I should mention I hooked it up and its not operating properly, so I know there's got to be something wrong.
It is supposed to flash an LED on and off, on for 1/4 second (250ms) off for 1/4 second, repeat.
What its actually doing when hooked up: Keep LED on forever
Something to keep in mind: RB1 is going through THIS LL MOSFET before it goes to the LED. I'm doing this because I'm using an existing project as a prototype for the PIC in an effort to enhance the original project, and it will ultimately be flashing 2 banks of 30 LEDs alternately.
Pin RB1 to mosfet gate through resistor to ground.
MOSFET source to ground
MOSFET drain to LED cathode
LED anode to 9V
One more thing to keep in mind. I started trying to learn assembly and PICs a month ago having known nothing about either at all. My learning material consists of one book, one website, the uC datasheet and this forum. So if my mistakes are wretched, give me a smidge of credit and patience
I should mention I hooked it up and its not operating properly, so I know there's got to be something wrong.
It is supposed to flash an LED on and off, on for 1/4 second (250ms) off for 1/4 second, repeat.
What its actually doing when hooked up: Keep LED on forever
Something to keep in mind: RB1 is going through THIS LL MOSFET before it goes to the LED. I'm doing this because I'm using an existing project as a prototype for the PIC in an effort to enhance the original project, and it will ultimately be flashing 2 banks of 30 LEDs alternately.
Pin RB1 to mosfet gate through resistor to ground.
MOSFET source to ground
MOSFET drain to LED cathode
LED anode to 9V
Rich (BB code):
;************************************************************************
;LED Flasher
;4 MHZ XT OSC
;Ryan Goff
;************************************************************************
;
LIST p=PIC16F628A
INCLUDE p16f628A.INC
;
;************************************************************************
__CONFIG B'10000100000001' ;code protection off, low-voltage programming off,
;Brown-out reset off, MCLRE tied to Vdd, power-up timer on
;watch-dog-timer off, XT oscillator
;************************************************************************
COUNT1 EQU 11
;
ORG 0x00
GOTO START
;
ORG 0x04
GOTO START
;
;************************************************************************
;Subroutines
QUARTER MOVLW .5
MOVWF COUNT1
LOOP1 CALL DELAY2
DECFSZ COUNT1
GOTO LOOP1
RETLW 0
;
DELAY2 CLRF TMR0
LOOP2 MOVF TMR0,W
SUBLW .60
BTFSS STATUS,2
GOTO LOOP2
RETURN
;
;*************************************************************************
;Initialize
START BSF STATUS,5 ;SELECT BANK 1
MOVLW B'10010111'
MOVWF OPTION_REG ;SELECT TMR0 OPTIONS AND PRESCALER TO 256
MOVLW B'00000000' ;Select all portb pins as outputs
MOVWF TRISB ;Port B according to above
BCF STATUS,5 ;setting PR0 to 0 to select bank 0
;
;*************************************************************************
QUAD BSF PORTB,1 ;TURN ON LED
GOTO QUARTER ;FOR ONE QUARTER SECOND
BCF PORTB,1 ;TURN OFF LED
GOTO QUARTER ;FOR ONE QUARTER SECOND
GOTO QUAD ;LOOP FOREVER
end