PIC12F675 - Trying to turn a LED ON with a Push Button

Hello all, could someone look over this simple counting pic project of trying to turn a led on via a push button please. I have no problem doing this with a PIC16F84 but i'm trying to use a PIC12F675.

Actually as is was neatening up the txt that i pasted in, i noticed i may be doubling up on the 'COUNT' register, as i'm using it in the delay routines maybe thats why the LED won't turn on???

I'll try it....

;****************************************************************************************************
TMR0 EQU 1 ;TMR0 is FILE 1.
TRISIO EQU 85H
TRISIO EQU 85H
GPIO EQU 5 ;GPIO is FILE
STATUS EQU 3 ;STATUS is FILE 3.
ZEROBIT EQU 2 ;ZEROBIT is Bit 2.
GO EQU 1
ADSEL EQU 9EH
ADCON0 EQU 1FH
ADRESH EQU 1EH
OPTION_R EQU 81H
CMCON EQU 19H
OSCCAL EQU 90H
COUNT EQU 20H ;USER RAM LOCATION.
;**********************************************************************
LIST P=12F675
#INCLUDE <P12F675.INC> ; processor specific variable definitions

__CONFIG _INTRC_OSC_NOCLKOUT & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _BODEN_OFF

ORG 0
GOTO START
;**********************************************************************
;SUBROUTINE SECTION.
;==================
;1/100 SECOND DELAY
DELAY CLRF TMR0 ;START TMR0
LOOPA MOVF TMR0,W ;READ TMR0 IN W
SUBLW .39 ;TIME-W
BTFSS STATUS,ZEROBIT ;CHECK TIME-W=0
GOTO LOOPA
RETLW 0 ;RETURN AFTER TMR0 = 39
;P1 SECOND DELAY
DELAYP1 MOVLW .10
MOVWF COUNT
TIMEB CALL DELAY
DECFSZ COUNT
GOTO TIMEB
RETLW 0
;P5 SECOND DELAY
DELAYP5 MOVLW .50
MOVWF COUNT
TIMEC CALL DELAY
DECFSZ COUNT
GOTO TIMEC
RETLW 0
;1 SECOND DELAY
DELAY_1SEC MOVLW .100
MOVWF COUNT
TIMED CALL DELAY
DECFSZ COUNT
GOTO TIMED
RETLW 0
;*********************************************************
;CONFIGURATION SECTION.
;======================
START BSF STATUS,5 ;BANK1
MOVLW B'00010000' ;All I/O are digital (12F675 only)
MOVWF ADSEL

MOVLW B'00101000' ;Bit3 is IP
MOVWF TRISIO

MOVLW B'00000111'
MOVWF OPTION_R ;PRESCALER is /256

CALL 3FFH
MOVWF OSCCAL ;Calibrates 4MHz oscillator

BCF STATUS,5 ;BANK0

MOVLW .7
MOVWF CMCON ;Turns off comparator
CLRF GPIO ;Clears GPIO
CLRF ADCON0
CLRF COUNT
;**********************************************************
;Program starts here.
BEGIN MOVLW .5
MOVWF COUNT

PRESS BTFSS GPIO,5 ;Is Sw currently being pressed?
GOTO PRESS
CALL DELAYP5 ;P/buttton has been pressed, wait for 0.1sec.

BCF GPIO,0

RELEASE BTFSC GPIO,5 ;Is Sw still being presssed?
GOTO RELEASE
CALL DELAYP5 ;P/button has not been presssed,Wait for 0.1sec.

DECFSZ COUNT
GOTO PRESS

BSF GPIO,0 ;Restart.
GOTO BEGIN

END

Blog entry information

Author
ErnieH
Views
22
Last update

More entries in General

Share this entry

Top