Gayan Soyza
Active Member
I wrote a simple program in pic 12c508a to toggle a led with a push button.
*led is connected to GP0
*button is connected to GP3
*every time the button press the led toggles.
My ques is here i'm using an internal rc oscillator.i didn't calibarate the
oscillator value.is this coding correct.i need to calibarate this for 4mhz.
how the program comes?
all the time i used external rc oscillators in 16f84a this is my first with internal ones.I went through the PDF it just tells briefly,no codings given.
Start ORG 0x00
BSF 03,5 ;Go to page1 for setting-up the ports
MOVLW 3Eh ;Make GP3 Input
MOVWF 06h
BCF 03,5 ;Go to Page0 for programming
SwLoop1 BTFSC 06,3 ;Is switch A pressed?
GOTO SwLoop1 ;YES. Go to SwLoop1
CALL DELAY
SwLoop2 BTFSS 06,3 ;Is switch A pressed?
GOTO SwLoop2 ;NO. Go to SwLoop2
MOVLW 01 ;YES.
XORWF 06,1 ;Toggle the LED
CALL DELAY
GOTO SwLoop1
DELAY DECFSZ 1Bh,1
GOTO DELAY
DECFSZ 1Ch,1
GOTO DELAY
RETLW 00
END
*led is connected to GP0
*button is connected to GP3
*every time the button press the led toggles.
My ques is here i'm using an internal rc oscillator.i didn't calibarate the
oscillator value.is this coding correct.i need to calibarate this for 4mhz.
how the program comes?
all the time i used external rc oscillators in 16f84a this is my first with internal ones.I went through the PDF it just tells briefly,no codings given.
Start ORG 0x00
BSF 03,5 ;Go to page1 for setting-up the ports
MOVLW 3Eh ;Make GP3 Input
MOVWF 06h
BCF 03,5 ;Go to Page0 for programming
SwLoop1 BTFSC 06,3 ;Is switch A pressed?
GOTO SwLoop1 ;YES. Go to SwLoop1
CALL DELAY
SwLoop2 BTFSS 06,3 ;Is switch A pressed?
GOTO SwLoop2 ;NO. Go to SwLoop2
MOVLW 01 ;YES.
XORWF 06,1 ;Toggle the LED
CALL DELAY
GOTO SwLoop1
DELAY DECFSZ 1Bh,1
GOTO DELAY
DECFSZ 1Ch,1
GOTO DELAY
RETLW 00
END
Attachments
Last edited: