Friday, July 4, 2014

BUJJI BUG PART 4

This is BUJJI BUG part 4 for semi electronic generating Dit and dash.



; BUJJI BUG
; CODE FOR DIT and DASH generation.
list p = 12F683 ; Selected 12F683
#include<p12F683.inc> ; Includeing the headerfile
; In this program we are generating DIT and DASH
; here GPIO 5 (pin no. 2 of IC) and GPIO 4 (pin no 3 of IC) is pulled to HIGH by the resistor
; home made paddle is connected to this pins,
; when it is pulled to one side (right side) The KEY OUT GPIO 1 (pin no 6 of IC) is sent to HIGH (5 Volts)
; and LOW (0 V) with a delay of 80 msec. It will continue till the paddle is released.
; when the paddle is pulled to otherside (left side) the KEY OUT GPIO 1(pin no 6 of IC) is sent to HIGH(5 Volts).
; During the IDLE state (middle) the GPIO 1(pin no 6 of IC) is sent to LOW(0 Volts).
; To verify we connect an LED from pin  no 6 with a resistor 2K7.
;..............................................................................................................................................................

; Till now we have not used any RAM which is also called GENERAL PURPOSE REGISTER
; in microprocessor/microcontroller world
                 CBLOCK 0X30 ; Starting Address/location of the registers
                 COUNT1 ; Location 0X30 is referred as COUNT1 in the program
                 COUNT2 ; Location 0X31 is referred as COUNT2 in the program
ENDC ; end the block
; ..............................................
                 ORG 0X00 ; Starting address for microcontroller program
                 CLRW ; Clearing the W register
CLRF COUNT1 ; Clearing the COUNT1 register at power ON time
CLRF COUNT2 ; Clearing the COUNT2 register at power ON time
                 NOP ; NO operation
  NOP ; This location is reserved for INTERRUPT and
; hence we always code the fifth line as NOP
                                                                                       ; Initialising the INPUT and OUTPUT PORTS

BSF STATUS,RP0 ; Selecting the bank 1
BCF OSCCON,IRCF0 ; Internal Oscillator frequency can be configured by
BCF OSCCON,IRCF1 ; enabling the appropriate registers in the OSCCON register
BSF OSCCON,IRCF2 ; IRCF0, IRCF1,IRCF2 are the bits to select the various                                                                                                    
                                                                  ; frequency ranges Here we have configured                                                                                                 ; 1MHz clock speed to reduce power consumption
BCF STATUS,RP0 ; changing to bank 0
CLRF GPIO ; Clearing the INPUT OUTPUT port registers
MOVLW 0X07 ; Moving the "7(HEX)" into the W register
MOVWF CMCON0 ; Comparators are disabled
BSF STATUS,RP0 ; Changing to bank 1
CLRF ANSEL ; please see BUJJI BUG part 1
MOVLW 0X38 ; moving "38(HEX)" value into W register
MOVWF TRISIO ; making the GP3,GP4,GP5(pin no 5 of IC)as a input and
; GP0,GP1(pin no 6 of IC),GP2,OUTPUTS
BCF STATUS,RP0 ; Changing to bank 0
GOTO begin ; Goto begin
pause MOVLW 0XFF ; move "FF(HEX)" value into the W register
MOVWF COUNT1 ; presetting COUNT1 register with the value of W register
MOVLW 0X15 ; move the "80(HEX)" value int the W register
MOVWF COUNT2 ; presetting COUNT2 register with the value of W register
wait DECFSZ COUNT1,F ; Decrement and check whether count1 register is zero, if zero                                                                                                                              ; skip next instruction
GOTO wait ;  otherwise go to wait
DECFSZ COUNT2,F ; Decrement and check whether count2 register is zero, if zero                                                                                                                            ; skip next instruction
GOTO wait ; go to wait
RETURN ; going back to the program code
; every CALL function should end with RETURN
;....................................
ditON BSF GPIO,1 ; when input is low(0 V)make the GPIO pin no 1 as high(LED                                                                                                                                              ; IS ON)
CALL pause ; Call delay
BCF GPIO,1 ; Clearing the GP1 pin (0 V) (LED is OFF)
CALL pause ; Call delay
GOTO check ; goto check to CHECK the condition and repeat the loop
dashON BSF GPIO,1 ; make the GPIO 1 (pin no 6 of IC) to HIGH
GOTO check ; goto check to CHECK the condition
OFF BCF GPIO,1 ; when the input is high(5 V) make the GPIO pin no 1 as                                                                                                                                         ; LOW(LED iS OFF)
GOTO check ; goto check to CHECK the condition and repeat the loop

begin NOP   ; NO Operation
check BTFSS GPIO,5 ; checking the input status of the GP5( pin no 2 of IC)
GOTO ditON ; if it is Clear(ZERO) goto dashON otherwise
BTFSS GPIO,4 ; checking the input status of the GP6( pin no 3 of IC)
GOTO dashON ; goto dashON
GOTO OFF ; goto OFF
END ; end of the program


; NOTE 1: This program is running with 1MHZ clock
; NOTE 2: program memory will begin from the address 0X00
; NOTE 3: we can configure the internal clock to work at various frequencies
; OSCCON register is used to select the frequencies
; NOTE 4: ANSEL Register is used to select the analog I/O.
; By clearing it we are making all pins as DIGITAL IO ports
; NOTE 5: we are not using any comparators in our program
; so we are disabling them by passing the value "7" into CMCON0
; NOTE 6: one instruction cycle consists of 4 oscillations, to execute one instruction
; it wil take 4 usec since clock is 1MHz
; DECFSZ and GOTO instruction will take 2 instruction cycle each
; 255usec* 16 = 4 mses
; repeating the loop for 20 times => 80 msec of delay.
; NOTE 7: 12 INSTRUCTIONS USED out of 35 INSTRUCTIONS
; 2 GENERAL PURPOSE REGISTER
; 6 SPECIAL FUNCTION REGISTER
; 20 bytes of data memory used out of 256 bytes.


Here is the HEX code for BUJJI BUG part 4

:020000040000FA
:100000000301B001B101000083160F168F120F1704
:10001000831285010730990083169F0138308500CF
:1000200083122228FF30B0008030B100B00B1628B8
:10003000B10B1628080085141220851012202328E1
:0C004000851023280000851E1B282028A6
:00000001FF

No comments:

Post a Comment