Let us start learning to code BUJJI BUG.
Let us start with a simple program to generate a DASH or DAH.
We are using 12F683 as this is small footprint IC only 8 pins
Please see the circuit diagram and picture as given below:
Here is the code:
; BUJJI BUG
; CODE FOR DASH generation
list p = 12F683 ; Selected 12f683
#include <P12F683.inc> ; Including the headerfile
; In this program we are generating DAH(DASH)
; here GPIO 5 (pin no. 2) is pulled to HIGH by the resistor
; external paddle is connected to this pin,
; when it is pulled-down/grounded (pin no.2) The KEY OUT GPIO 1 is send to HIGH (5 volts).
; otherwise KEY OUT will be in the LOW state(0 volts).
; To verify we connect an LED from pin no 6 with a resistor 2K7.
;........................................................................................
ORG 0X00 ; Stating address for microcontroller
CLRW ; Clearing the W register.
NOP ; NO operation
NOP ; NO operation
NOP ; NO operation
NOP ; NO operation
goto START ; starting the program
START CLRF GPIO ; Clearing the INPUT OUTPUT Port register
MOVLW 0x07 ; Moving the "7" into the W register
MOVWF CMCON0 ; Disabling the comparators by passing "7" in the CMCON0 ; register
BSF STATUS,RP0 ; Changing to bank 1, because ANSEl is in Bank 1
CLRF ANSEL ; Initialising the IO ports as a Digital by clearing the ANSEL ; register
MOVLW 0x38 ; Moving "38" into the W register
MOVWF TRISIO ; Making the GP3,GP4,GP5(pin no 2 of IC) as INPUT and
NOP ; GP0,GP1(pin no 6 of IC),GP2 OUTPUTS by passing the ; value into TRISIO register
BCF STATUS,RP0 ; We have to come back to bank 0 then only program will ; run.
goto begin ; Goto begin
;...........................................................................................
dashON BSF GPIO,1 ; When the input is LOW(ZERO) make the GPIO pin 1 as ; HIGH (LED IS ON)
goto run ; goto Run to check the condition and repeat the loop for ; ever
dashOFF BCF GPIO,1 ; When the input is HIGH make the GPIO pin 1 as LOW ; LED is OFF)
goto run ; goto run to check the condition and repeat the loop
;............................................................................................
begin NOP
run BTFSS GPIO,5 ; Checking the Input status of the GP5 (PIN no 2 of IC)
goto dashON ; If it is Clear(ZERO) goto dashON otherwise
goto dashOFF ; goto DashOFF
end ; End of the program
Here is the HEX code:
:020000040000FA
:100000000301000000000000000006288501073001
:10001000990083169F0138308500831213288514B8
:0E0020001428851014280000851E0F281128B2
:00000001FF
Happy homebrewing!
Let us start with a simple program to generate a DASH or DAH.
We are using 12F683 as this is small footprint IC only 8 pins
Please see the circuit diagram and picture as given below:
Circuit Diagram |
Picture |
Here is the code:
; BUJJI BUG
; CODE FOR DASH generation
list p = 12F683 ; Selected 12f683
#include <P12F683.inc> ; Including the headerfile
; In this program we are generating DAH(DASH)
; here GPIO 5 (pin no. 2) is pulled to HIGH by the resistor
; external paddle is connected to this pin,
; when it is pulled-down/grounded (pin no.2) The KEY OUT GPIO 1 is send to HIGH (5 volts).
; otherwise KEY OUT will be in the LOW state(0 volts).
; To verify we connect an LED from pin no 6 with a resistor 2K7.
;........................................................................................
ORG 0X00 ; Stating address for microcontroller
CLRW ; Clearing the W register.
NOP ; NO operation
NOP ; NO operation
NOP ; NO operation
NOP ; NO operation
goto START ; starting the program
START CLRF GPIO ; Clearing the INPUT OUTPUT Port register
MOVLW 0x07 ; Moving the "7" into the W register
MOVWF CMCON0 ; Disabling the comparators by passing "7" in the CMCON0 ; register
BSF STATUS,RP0 ; Changing to bank 1, because ANSEl is in Bank 1
CLRF ANSEL ; Initialising the IO ports as a Digital by clearing the ANSEL ; register
MOVLW 0x38 ; Moving "38" into the W register
MOVWF TRISIO ; Making the GP3,GP4,GP5(pin no 2 of IC) as INPUT and
NOP ; GP0,GP1(pin no 6 of IC),GP2 OUTPUTS by passing the ; value into TRISIO register
BCF STATUS,RP0 ; We have to come back to bank 0 then only program will ; run.
goto begin ; Goto begin
;...........................................................................................
dashON BSF GPIO,1 ; When the input is LOW(ZERO) make the GPIO pin 1 as ; HIGH (LED IS ON)
goto run ; goto Run to check the condition and repeat the loop for ; ever
dashOFF BCF GPIO,1 ; When the input is HIGH make the GPIO pin 1 as LOW ; LED is OFF)
goto run ; goto run to check the condition and repeat the loop
;............................................................................................
begin NOP
run BTFSS GPIO,5 ; Checking the Input status of the GP5 (PIN no 2 of IC)
goto dashON ; If it is Clear(ZERO) goto dashON otherwise
goto dashOFF ; goto DashOFF
end ; End of the program
Here is the HEX code:
:020000040000FA
:100000000301000000000000000006288501073001
:10001000990083169F0138308500831213288514B8
:0E0020001428851014280000851E0F281128B2
:00000001FF
Happy homebrewing!
No comments:
Post a Comment