Tuesday, August 12, 2014

BUJJI BUG part 7A

Dear all,

Here the BUJJI BUG comes in a Nutcase.


The pictures and circuit diagram of Bujji Bug is given below.



Assembly code and HEX are given below for the BUJJI BUG
 BUJJI BUG
; CODE FOR automatic DIT and DASH generation along with sidetone @650Hz
; 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. 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).
; and LOW (0 V) with a delay of 3XDIT (3 times of the dit).
; During the IDLE state (middle) the GPIO 1(pin no 6 of IC) is sent to LOW(0 Volts) without any sidetone.
; To verify we connect an LED from pin  no 6 with a resistor of 2K7 and speaker is connected to GPIO 2 with LM386 for sidetone.
; GPIO 0 is pulled to high through a resistro when is connected during ON time the speed can be controlled.
;#################################################################################################################
;        Selecting the PIC12F683 Micro controller
;#################################################################################################################
         list p = 12F683            ; Selected 12F683 
         #include<p12F683.inc>      ; Includeing the headerfile
;#################################################################################################################
;         These general purpose registers used in the program.
;#################################################################################################################
         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
         COUNT3                     ; Location 0X32 is referred as COUNT3 in the program 
         COUNT4                     ; Location 0X33 is referred as COUNT4 in the program
         COUNT5                     ; Location 0X34 is referred as COUNT5 in the program
         COUNT6                     ; Location 0X35 is referred as COUNT6 in the program
         COUNT7                     ; Location 0X36 is referred as COUNT7 in the program
         ENDC                       ; end the block
;#################################################################################################################
;        Starting of our programe
;#################################################################################################################
         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
;#################################################################################################################
;         Setting the Internal clock frequency to 2MHz
;#################################################################################################################
         BSF         STATUS,RP0     ; Selecting the bank 1
         BSF         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 2MHz clock speed to reduce power consumption 
;#################################################################################################################
;       Setting the input and output ports       
;#################################################################################################################
         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, because the ANSEL,TRISIO,T2CON are in bank 1
         CLRF        ANSEL          ; please see BUJJI BUG part 1  
         MOVLW       0X39           ; moving "39(HEX)" value into W register
         MOVWF       TRISIO         ; making the GP0, GP3,GP4,GP5(pin no 5 of IC)as a input and
                                    ; GP1(pin no 6 of IC),GP2,OUTPUTS
;#################################################################################################################
;       Initialising the PWM for sidetone       
;#################################################################################################################
         MOVLW       0XC0           ; writing the value C0(HEX) into the W register
         MOVWF       PR2            ; passing the value into PR2 register
         BCF         STATUS,RP0     ; selecting the bank 0
         BSF         T2CON,T2CKPS0  ; TIMER2 prescalar value is initiaizing as 1:4 ratio by setting T2CKPS0 bit   
         BCF         T2CON,T2CKPS1  ; and clearing the T2CKPS1 bit in the T2CON register
         BSF         T2CON,TMR2ON   ; Enabling the TIMER2 by setting the bit TMR2ON
         MOVLW       0X0C           ; Writing the value "12" into the W register
         MOVWF       CCP1CON        ; Configuring the GP3 (pin no 5) as PWM OUTPUT
;#################################################################################################################
;       Reading the EEPROM data      
;#################################################################################################################             
         BSF         STATUS,RP0     ; Selecting the bank 0
         MOVLW       0X01           ; Writing value 01 (HEX) into W register
         MOVWF       EEADR          ; Selecting the address 1 in EEPROM to read
         BSF         EECON1,RD      ; Enabling the RD bit to Read the data from EEPROM
         MOVF        EEDATA,W       ; Moving the EEPROM data into the W register
wait_to_read1
         BTFSC       EECON1,RD      ; Varifying whether the data is written into EEPROM or not
         GOTO        wait_to_read1  ; If yes skip this line otherwise otherwise goto wait_to_read
         BCF         STATUS,RP0     ; Coming back to BANK 0
         MOVWF       COUNT6         ; Passing the value from W register to COUNT6
         MOVWF       COUNT7         ; Passing the value from W register to COUNT7
;#################################################################################################################
;       Verifying the EEPROM data is within the limit of 30 and 10      
;#################################################################################################################
         MOVLW       0X30           ; Passing the value into W register
         SUBWF       COUNT6,0       ; Substract the valu in count6 register with 30(HEX)
         BTFSC       STATUS,C       ; Check the status of the carry, if clesr skip the next line
         GOTO        value          ; Not clear goto value
         MOVLW       0X10           ; Passing the value into W register
         SUBWF       COUNT7,0       ; Substract the valu in count6 register with 10(HEX)
         BTFSS       STATUS,C       ; Check the status of the carry, if set skip the next line
         GOTO        value1         ; if clear goto value1
 
check1   BCF         STATUS,RP0     ; Changing to bank 0
         BTFSS       GPIO,0         ; Check the GPIO 1 is set or clear
         GOTO        write_EEPROM   ; if clear goto EEPROM write
         GOTO        begin          ; Otherwise goto begin
 
value    MOVLW       0X30           ; Passing the value into W register
         MOVWF       COUNT6         ; Passing the value from W register to COUNT6    
         GOTO        write_EEPROM   ; goto EEPROM_WRITE
value1   MOVLW       0x30           ; Passing the value into W register
         MOVWF       COUNT6         ; Passing the value from W register to COUNT6
         GOTO        write_EEPROM   ; goto EEPROM_WRITE
;#################################################################################################################
;       Write the value into EEPROM and decrement the value based on the condition
;#################################################################################################################
write_EEPROM 
         BSF         STATUS,RP0     ; Changing to bank 1 
         MOVLW       0X01           ; Writing value 0 into W register
         MOVWF       EEADR          ; Selecting the Address 0 in EEPROM to write
         BCF         STATUS,RP0     ; selecting the bank 0 
         DECF        COUNT6,F       ; Decrement the COUNT6 register value by 1
         MOVF        COUNT6,W       ; pass the value into the W register
         BSF         STATUS,RP0     ; Selecting the bank 1 
         MOVWF       EEDATA         ; Selecting the value 10 (HEX) to write into EEPROM 
         BSF         EECON1,WREN    ; Enabling the WRITE cycle
         MOVLW       0X55           ; Writing value 55 (HEX) into W register
         MOVWF       EECON2         ; Passing the value into the EECON2 REGISTER
         MOVLW       0XAA           ; Writing value AA (HEX) into W register
         MOVWF       EECON2         ; Passing the value into the EECON2 REGISTER
                                    ; Without the above four step the data cannot read into the EEPROM 
         BSF         EECON1,WR      ; Enabling WR bit of EECON1 to write into the EEPROM 
wait_to_write 
         BTFSC       EECON1,WR      ; Varifying whether the data is written into EEPROM or not
         GOTO        wait_to_write  ; If yes skip this line otherwise goto wait 
         BCF         STATUS,RP0     ; Selecting the bank 0
         CALL        delay          ; call the delay 
         MOVLW       0X0A           ; pass the value A (HEX) into W register
         SUBWF       COUNT6,0       ; Substract the value in count6 register with A(HEX)  ; 
         BTFSS       STATUS,C       ; Check the status of the carry, if set skip the next line
         GOTO        value1         ; if clear goto value 1
         GOTO        check1         ; goto mo
;#################################################################################################################
;    Read the EEPROM data into count2 for the generation of DELAY
;#################################################################################################################
read_EEPROM
         BSF         STATUS,RP0     ; Changing to bank 1
         MOVLW       0X01           ; Writing value 55 (HEX) into W register
         MOVWF       EEADR          ; Selecting the address 0 in EEPROM to read
         BSF         EECON1,RD      ; Enabling the RD bit to Read the data from EEPROM
         MOVF        EEDATA,W       ; Moving the data into the W register
wait_read   
         BTFSC       EECON1,RD      ; Varifying whether the data is written into EEPROM or not
         GOTO        wait_read      ; If yes skip this line otherwise goto wait1
         BCF         STATUS,RP0     ; Coming back to BANK 0
         MOVWF       COUNT2         ; Writing the EEPROM DATA 
         MOVWF       COUNT6         ; Writing the EEPROM data into COUNT6
         RETURN                     ; Return to the function
;###################################################################################################################
;       Loop for geneation of 1 Sec DELAY
;###################################################################################################################
delay    MOVLW       0XFF           ; Pass the value into W register
         MOVWF       COUNT3         ; Pass the value from W register to COUNT3
         MOVWF       COUNT4         ; Pass the value from W register to COUNT4
         MOVLW       0X02           ; Pass the value into W register
         MOVWF       COUNT5         ; Pass the value from W register to COUNT4
L1       DECFSZ      COUNT3,F       ; decrement the value by 1 in COUNT3 register if zero skip next line
         GOTO        L1             ; Goto L1
         DECFSZ      COUNT4,F       ; decrement the value by 1 in COUNT4 register if zero skip next line
         GOTO        L1             ; Goto L1
         DECFSZ      COUNT5,F       ; decrement the value by 1 in COUNT5 register if zero skip next line
         GOTO        L1             ; Goto L1
         RETURN
;###################################################################################################################
;       Loop for the generation of 96 msec DELAY
;###################################################################################################################
pause    MOVLW       0XFF           ; move "FF(HEX)" value into the W register
         MOVWF       COUNT1         ; presetting COUNT1 register with the value of W register
         CALL        read_EEPROM    ; CALL the read_EEPROM  
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
;###################################################################################################################
;       Loop for DIT generation
;###################################################################################################################
ditON    BSF         GPIO,1         ; when input is low(0 V)make the GPIO pin no 1 as high(LED IS ON)
         MOVLW       0X60           ; Writing the value 60 (HEX) into W register
         MOVWF       CCPR1L         ; Passing the value into the CCPR1L register to SWITCH ON the tone
         CALL        pause          ; Call delay
         BCF         GPIO,1         ; Clearing the GP1 pin (0 V) (LED is OFF)
         CLRF        CCPR1L         ; Clear the CCPR1L register to remove the sidetone
         CALL        pause          ; Call delay
         GOTO        check          ; goto check to CHECK the condition and repeat the loop forever
;###################################################################################################################
;       LOOP for DASH GENERATION
;###################################################################################################################
dashON   BSF         GPIO,1         ; make the GPIO 1 (pin no 6 of IC) to HIGH
         MOVLW       0X60           ; Writing the value 60 (HEX) into W register
         MOVWF       CCPR1L         ; Passing the value into the CCPR1L register to SWITCH ON the tone
         CALL        pause          ; call delay
         CALL        pause          ; call delay
         CALL        pause          ; call delay
         BCF         GPIO,1         ; Clearing the GP1 pin (0 V) (LED is OFF)
         CLRF        CCPR1L         ; Clearing the CCPR1L register to SWITCH OFF the side tone
         CALL        pause          ; call delay
         GOTO        check          ; goto check to CHECK the condition
;###################################################################################################################
;       Loop to IDLE STATE
;###################################################################################################################
OFF      BCF         GPIO,1         ; when the input is high(5 V) make the GPIO pin no 1 as LOW(LED iS OFF)
         CLRF        CCPR1L         ; Clear CCPR1L register to remove the sidetone
;....................................................................................................................
         GOTO        check          ; goto check to CHECK the condition and repeat the loop 
 
;###################################################################################################################
;       Main loop to check the DIT and DASH
;###################################################################################################################
begin    BCF         STATUS,RP0
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
;###################################################################################################################
;       END OF THE PROGRAM
;###################################################################################################################
 
  
  
; NOTE 1: This program is running with 2MHZ 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: The value in CCPR1L is used to set the DUTY CYCLE of PWM OUT OF PR2 value.
; NOTE 7: one instruction cycle consists of 4 oscillations, to execute one instruction
;   it wil take 2 usec since clock is 2 MHz
;   DECFSZ and GOTO instruction will take 2 instruction cycle each
;   255usec* 8 = 2 mses
;    repeating the loop for 48 times => 96 msec of delay.
; NOTE 8: 17 INSTRUCTIONS USED out of 35 INSTRUCTIONS
;   7 GENERAL PURPOSE REGISTER
;   14 SPECIAL FUNCTION REGISTER used out of 38
;   133 bytes of program memory used out of 256bytes.
Here is the HEX code
:020000040000FA :100000000301B001B101000083160F168F120F1704 :10001000831285010730990083169F0139308500CE :10002000C030920083121214921012150C309500F9 :10003000831601309B001C141A081C181D288312FB :10004000B500B6003030350203182E2810303602C5 :10005000031C31288312051C34287F283030B5005A :1000600034283030B5003428831601309B008312C9 :10007000B503350883169A001C1555309D00AA302B :100080009D009C149C184228831256200A30350289 :10009000031C31282A28831601309B001C141A08DF :1000A0001C1850288312B100B5000800FF30B200C0 :1000B000B3000230B400B20B5B28B30B5B28B40B67 :1000C0005B280800FF30B0004B20B00B6528B10B57 :1000D0006528080085146030930062208510930124 :1000E00062208028851460309300622062206220A4 :1000F0008510930162208028851093018028831247 :0A010000851E6A28051E72287C285F :00000001FF

Monday, August 11, 2014

Programming PIC using PICKIT2

Dear all,

Today we are going to give a brief introduction on how to download and programming  a PIC micro controller using standalone PICKIT2.
Search for Pickit2 download in the Google search.
Open the first link

Now click on Download image to download the software.

Extract/unzip the downloaded file into any folder and run the setup by clicking on the setup icon.

Follow these steps to complete the installation.

Enable the everyone icon and check the installation path.

Follow the procedure shown in the pictures to complete the installation.
Enable the I agree statement by clicking on it and click on next button.
Wait till the process completes.
Click on Close button to complete the installation.it will create a Pickit2 shortcut on the desktop.

Plugin the Pickit2 to the PC and open the Pickit2 software by double clicking on the shortcut icon.
observe the points 1 & 2 in the picture.
Insert the PIC micro controller into the ZIP socket. Make sure that you have inserted into the correct pins. Now follows these steps
Go to tools à Check communication.

It will display the PIC micro controller name as shown in the picture.
Now open the File menu and click on Import icon.
Give the path of the HEX file to import
Observe the below picture. The HEX values has changed from 3FFF to other. If not Import the Hex file again.
Now click on the Write icon to dump the code into PIC micro controller. and observe the screen it will change to green with displaying programming successful.


Wednesday, July 30, 2014

BUJJI PADDLE

Dear all,

The dimensional sketches of the BUJJI PADDLE is given below.

Base



Brackets

Thursday, July 24, 2014

LM35 THERMOMETER USING PIC16F88

Dear all,

A simple thermometer using PIC16F88 and LM35.

Here we are  using TWO common anode 7 segment display for the OUTPUT indication.

The two 7 segment displays are multiplexed. Switching of the displays are happening with the help of two BC547 transistor. 
Lm35 sensor is connected to the AN1(18 th pin of IC). 
The connections of the seven segment display is shown in the below fig.




ASM code :
    LIST  P=16F88
    #INCLUDE <P16F88.INC>
  
    CBLOCK  0X30
    COUNT
    COUNT4
        COUNT6
        COUNT3
        D1
        RES1
          RES2
        RES3
        RES4
        A1
        A2
        B1
        B2
        NEG_FLAG
        SHIFTH
        SHIFTM
        SHIFTL
        BCOUNT
        NRATORH 
        NRATORM
        NRATORL
        DENOMH
        DENOMM
        DENOML
        REMAINH
        REMAINM
        REMAINL
        LOWBYTE
        HIGHBYTE
        HUNS
        TENS
        ONES
        ENDC
       
       
        ORG   0X0000
        NOP
        NOP
        NOP
        NOP
       
        CLRF   PORTA
        CLRF   PORTB
        BSF   STATUS,RP0    ; SELECT BANK 1
        BCF   STATUS,RP1
        BSF   OSCCON,6      ; SETUP THE INTERNAL OSCILLATOR  
        BSF   OSCCON,5      ; TO USE 4MHZ 
        MOVLW   H'07'         ; TURN OFF THE COMPARATORS
        MOVWF   CMCON  
        MOVLW   B'00000011'    
        MOVWF   TRISA
        MOVLW   B'00000000'   
        MOVWF   TRISB
        MOVLW   B'00000011'  
        MOVWF   ANSEL
        BCF   STATUS,RP0    ; SELECT BANK 0
        BCF   STATUS,RP1
        GOTO   START
        
         
      
        
ADC_INITIALISE
        BCF   STATUS,RP0    ; SELECT BANK 0
        BCF   STATUS,RP1
        BCF   ADCON0,GO      
        BCF   ADCON0,ADCS1   ; SELECTING THE FOSC FOR THE A/D
        BSF   ADCON0,ADCS0   ; HERE WE HAVE SELECTED FOSC/16
        BCF   ADCON0,CHS2    
        BCF   ADCON0,CHS1    
        BSF   ADCON0,CHS0  
      
        BSF   STATUS,RP0    ; SELECT BANK 1
        BCF   STATUS,RP1
        BCF   ADCON1,ADFM    
        BSF   ADCON1,ADCS2   
        BCF   ADCON1,VCFG1   ; SELECT THE SOURCE OF THE VREF
        BCF   ADCON1,VCFG0   
      
        BCF   STATUS,RP0    ; SELECT BANK 0
        BCF   STATUS,RP1
        BSF   ADCON0,ADON    ; TURN ON THE A/D MODULE
      
      ;  CALL   DELAY         ; WAIT FOR THE AQUISTION TIME
        BSF       ADCON0,GO      
      ;  CALL   DELAY         ; WAIT FOR SOME TIME
    
HERE            BTFSC   ADCON0,GO      
        GOTO   HERE       
        MOVF   ADRESH,0     
        MOVWF   LOWBYTE
        CLRF     HIGHBYTE   
        RETURN
      
MULTIPLY:
        CLRF      RES4
        CLRF   RES3
        CLRF      RES2
        MOVLW   0X80
        MOVWF   RES1  
      
        CLRF   NEG_FLAG
    
        BTFSS     A2,7
        GOTO      A_POS
        COMF      A2,F
        COMF   A1,F
        INCF   A1,F
        BTFSC   STATUS, Z
        INCF      A2,F
        INCF   NEG_FLAG, F
A_POS
        BTFSS     B2,7
        GOTO      NEXTBIT
        COMF      B2,F
        COMF      B1,F 
        INCF      B1,F 
        BTFSC     STATUS, Z
        INCF      B2,F
        INCF   NEG_FLAG, F
NEXTBIT
        RRF   A2,F
        RRF   A1,F
       
        BTFSS   STATUS, C
        GOTO   NOBIT_L
        MOVF   B1,W
        ADDWF   RES2,F
       
        MOVF   B2, W
        BTFSC   STATUS, C
        INCFSZ   B2, W 
        ADDWF   RES3, F 
        BTFSC   STATUS, C
        INCF   RES4, F
        BCF   STATUS, C
NOBIT_L 
        BTFSS   A1, 7
        GOTO   NOBIT_H
        MOVF   B1,W
        ADDWF   RES3,F
        BTFSC   STATUS, C
        INCF   RES4,F
        MOVF   B2,W  
        ADDWF   RES4,F
NOBIT_H
        RRF   RES4,F
        RRF   RES3,F
        RRF   RES2,F
        RRF   RES1,F
       
        BTFSS     STATUS, C
        GOTO   NEXTBIT
        BTFSS     NEG_FLAG, 0
        GOTO    NO_INVERT  
       
        COMF      RES4,F
        COMF      RES3,F
        COMF      RES2,F
        COMF   RES1,F
       
        INCF      RES1,F
        BTFSC     STATUS,Z
        INCF   RES2,F
        BTFSC     STATUS,Z
        INCF      RES3,F
        BTFSC     STATUS,Z
        INCF      RES4,F
NO_INVERT
        RETURN
 
DIVIDE:  MOVLW    .24
         MOVWF    BCOUNT
         MOVF    NRATORH,W
         MOVWF    SHIFTH
         MOVF    NRATORM,W
         MOVWF    SHIFTM
         MOVF    NRATORL,W
         MOVWF    SHIFTL
         CLRF    NRATORH
         CLRF    NRATORM
         CLRF    NRATORL
 
         CLRF    REMAINH
         CLRF    REMAINM
         CLRF    REMAINL
DLOOP     BCF    STATUS,C
         RLF    SHIFTL,F
         RLF    SHIFTM,F
         RLF      SHIFTH,F
         RLF    REMAINL,F
         RLF    REMAINM,F
         RLF      REMAINH,F
         MOVF     DENOMH,W
         SUBWF    REMAINH,W
         BTFSS    STATUS,Z
         GOTO    NOCHK
 
         MOVF    DENOMM,W
         SUBWF  REMAINM,W
         BTFSS  STATUS,Z
         GOTO    NOCHK
 
         MOVF    DENOML,W
         SUBWF    REMAINL,W
NOCHK           BTFSS    STATUS,C
         GOTO    NOGO
 
         MOVF    DENOML,W
         SUBWF    REMAINL,F
         BTFSS    STATUS,C
         DECF    REMAINM,F
         MOVF    REMAINM,W
         XORLW    0XFF
         BTFSC    STATUS,Z
         DECF    REMAINH,F
         MOVF    DENOMM,W
         SUBWF    REMAINM,F
         BTFSS    STATUS,C
         DECF    REMAINH,F
         MOVF    DENOMH,W
         SUBWF    REMAINH,F
         BSF    STATUS,C
NOGO:
         RLF    NRATORL,F
         RLF    NRATORM,F
         RLF    NRATORH,F
         DECFSZ    BCOUNT,F
         GOTO    DLOOP
      RETURN
 
HEX2DEC  INCF      LOWBYTE                 ; PRE-LOAD TEMPHI + 1
         CLRF      HUNS                    ; HUNS = 0000 0000
         MOVLW     D'246'                  ; MOVE DECIMAL'246' TO W
         MOVWF     TENS                    ; TENS GPR = 1111 0101
         MOVWF     ONES                    ; ONES GPR = 1111 0101
         DECFSZ    LOWBYTE, F              ; DECREMENT TEMPHI REGISTER
         GOTO      $+D'2'                  ; NOT 0, SKIP NEXT INSTRUCTION
         GOTO      $+D'7'                  
         INCFSZ    ONES, F                 
         GOTO      $-D'4'                 
         INCFSZ    TENS, F                
         GOTO      $-D'7'                  
         INCF      HUNS, F                
         GOTO      $-D'10'                
    
         SUBWF     TENS, F                 
         SUBWF     ONES, F 
 
         RETURN



DELAY
        MOVLW   0XFF
        MOVWF   COUNT3
        MOVLW   0X0A
        MOVWF   COUNT4
WAIT            DECFSZ   COUNT3,F
        GOTO   WAIT
        DECFSZ   COUNT4,F
        GOTO   WAIT
        RETURN



DISPLAY 
        MOVLW   0X30
        MOVWF   COUNT6
HERE1          BSF    PORTA,3
        BCF   PORTA,2
        MOVF   TENS,0
        CALL   TABLE1
        MOVWF   PORTB
        CALL   DELAY
        BCF   PORTA,3
        BSF   PORTA,2
        MOVF   ONES,0
        CALL   TABLE1
        MOVWF   PORTB
        CALL   DELAY
        DECFSZ   COUNT6,F
        GOTO   HERE1
        RETURN
        
      
      
       

TABLE1  ADDWF   PCL,F
         RETLW   B'00010001'       ; 0
         RETLW   B'11010111'       ; 1
         RETLW   B'00110010'       ; 2
         RETLW   B'10010010'       ; 3
         RETLW   B'11010100'       ; 4
         RETLW   B'10011000'       ; 5
         RETLW   B'00011000'       ; 6
         RETLW   B'11010011'       ; 7
         RETLW   B'00010000'       ; 8
         RETLW   B'10010000'       ; 9

  
START         NOP
        CALL   ADC_INITIALISE
                 ; 2000 = H'7D0'
        CLRF   A2
        MOVLW   0X3C
        MOVWF   A1
        MOVF   HIGHBYTE,W
        MOVWF   B2
        MOVF   LOWBYTE,W
        MOVWF   B1
        CALL   MULTIPLY      ; 125*ANALOG READ
      
        MOVF   RES3,W
        MOVWF   NRATORH
        MOVF   RES2,0
        MOVWF  NRATORM
        MOVF   RES1,0
        MOVWF   NRATORL
      
        CLRF   DENOMH
        MOVLW   H'00'                     ; 256 = H'FF'
        MOVWF   DENOMM
        CLRF   DENOML
        MOVLW   0XFF
        MOVWF   DENOML
        CALL   DIVIDE
      
        MOVF   NRATORM,0
        MOVWF   HIGHBYTE                  ; TENTHS DEGREES 
        MOVF   NRATORL,0
        MOVWF   LOWBYTE                   ; TENTHS 
        CALL   HEX2DEC
        CALL   DISPLAY
        GOTO   START
        END

 
HEX file:
 
:020000040000FA
:100000000000000000000000850186018316031334
:100010000F178F1607309C000330850000308600D4
:1000200003309B0083120313D828831203131F117C
:100030009F131F179F121F129F15831603139F13E1
:100040001F179F121F12831203131F141F151F194E
:1000500027281E08CB00CC010800B801B701B60163
:100060008030B500BD01BA1F3B28BA09B909B90AE9
:100070000319BA0ABD0ABC1F4328BC09BB09BB0A45
:100080000319BC0ABD0ABA0CB90C031C50283B0862
:10009000B6073C0803183C0FB7070318B80A03104B
:1000A000B91F58283B08B7070318B80A3C08B80717
:1000B000B80CB70CB60CB50C031C43283D1C6B28C0
:1000C000B809B709B609B509B50A0319B60A03197B
:1000D000B70A0319B80A08001830C1004208BE0068
:1000E0004308BF004408C000C201C301C401C801E5
:1000F000C901CA010310C00DBF0DBE0DCA0DC90D47
:10010000C80D45084802031D8B2846084902031DF7
:100110008B2847084A02031C9C284708CA02031C74
:10012000C9034908FF3A0319C8034608C902031C5A
:10013000C8034508C8020314C40DC30DC20DC10B8A
:100140007A280800CB0ACD01F630CE00CF00CB0BC9
:10015000AA28B028CF0FA728CE0FA628CD0AA528F9
:10016000CE02CF020800FF30B3000A30B100B30B5B
:10017000B728B10BB72808003030B200851505113B
:100180004E08CD208600B320851105154F08CD20DF
:100190008600B320B20BBE28080082071134D73482
:1001A00032349234D43498341834D33410349034F4
:1001B00000001520BA013C30B9004C08BC004B08C7
:1001C000BB002D203708C2003608C3003508C40024
:1001D000C5010030C600C701FF30C7006C204308CE
:0C01E000CC004408CB00A220BC20D82892
:00000001FF
 

Saturday, July 19, 2014

SOME THOUGHTS ON PYTHON (high level language)


Nowadays we can see PYTHON as one of the emerging language in the industry because of ease of use. Python is a high level language and any one can understand very easily.

PYTHON IS AN "OPEN SOURCE" and can "FREELY DOWNLOAD" from the website.

We can start our programming in less than 2 Hrs of time. because it very easy to learn and practice. 

It does not require a compiler whereas it needs an interpreter. 

Many tutorials are available in the web, we have given below the way we are learning PYTHON step by step.
For more info on PYTHON please visit www.python.org

Installation of Python:

Download the latest version of PYTHON file from the website.


Click here for the direct download .

Double click on the .msi file for installation with default settings
C: / PythonXYZ
where XYZ is version

while installing check this step for enabling the path

Check on Finish button to complete the installation of PYTHON.

Click on the python shell/GUI icon created on the desktop




























Now we can write and check the program in the python shell.


print the hello world program
Write the code as follows
print ' hello world'
and press the enter button


We can you single quote, double quote also to print the string.

Till now we have seen output when we press the OUTPUT button .

If can change the procedure to check the output as follows

à Go to file and open a new file.


à  Save the file with an extension of .py/.pyw
à  Now write basic HELLO WORLD program and check the OUTPUT by compiling or by pressing the            F5 button.


à  We can see output in the GUI/SHELL window. 






Wednesday, July 16, 2014

80M-SDR

Greeting to all,

Our normal 40m SDR can be converted into 80m SDR with few modifications in the circuit,

1.Changing the crystal from 28.224 MHz to 14.318 MHz.
     The center frequency of 80m SDR is 3.5795 MHz

2. Band pass filter.

   The circuit diagram of modified band pass filter is given below.








Monday, July 14, 2014

BUJJI PADDLE VERSION-3

As per the suggestion from our well wisher we changed the base of the paddle from aluminium to MS.

Now the base is heavy and stable.

Friday, July 11, 2014

BUJJI PADDLE VERSION-2




Comparison of paddle's:


BUJJI BUG PART 6A

BUJJI KEYER for automatic generation of DIT and DASH.

BUJJI BUG is different from BUJJI KEYER.
In Bujji Bug DASH's are generated manually whereas in KEYER both DIT and DASH's are generated automatically.
; BUJJI KEYER
; CODE FOR automatic DIT and DASH generation along with sidetone @650Hz
; 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. 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).
; and LOW (0 V) with a delay of 3XDIT (3 times of the dit).
; During the IDLE state (middle) the GPIO 1(pin no 6 of IC) is sent to LOW(0 Volts) without any sidetone.
; To verify we connect an LED from pin  no 6 with a resistor of 2K7.
;...........................................................

           list p = 12F683              ; Selected 12F683 
           #include<p12F683.inc>        ; Includeing the headerfile

; These general purpose registers used in the delay function.

            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
;..................................................................................................................
; Setting the clock frequency 
            BSF          STATUS,RP0     ; Selecting the bank 1
            BSF          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 2MHz clock speed to reduce power consumption 
;...................................................................................................................
;Setting the input and output ports
;...................................................................................................................
            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, because the ANSEL,TRISIO,T2CON are in 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
            BSF          STATUS,RP0     ; Changing to bank 0
;...................................................................................................................
; Initialising the PWM for sidetone
;...................................................................................................................
            MOVLW        0XC0           ; writing the value C0(HEX) into the W register
            MOVWF        PR2            ; passing the value into PR2 register
            BCF          STATUS,RP0     ; selecting the bank 0
            BSF          T2CON,T2CKPS0  ; TIMER2 prescalar value is initiaizing as 1:4 ratio by setting T2CKPS0 bit   
            BCF          T2CON,T2CKPS1  ; and clearing the T2CKPS1 bit in the T2CON register
            BSF          T2CON,TMR2ON   ; Enabling the TIMER2 by setting the bit TMR2ON
            MOVLW        0X0C           ; Writing the value "12" into the W register
            MOVWF        CCP1CON        ; Configuring the GP3 (pin no 5) as PWM OUTPUT
;...................................................................................................................
            GOTO         begin          ; Goto begin
;...................................................................................................................
;delay loop
;...................................................................................................................
pause       MOVLW        0XFF           ; move "FF(HEX)" value into the W register
            MOVWF        COUNT1         ; presetting COUNT1 register with the value of W register
            MOVLW        0X30           ; 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
;.....................................................................................................................
;Loop for DIT ON
;.....................................................................................................................
ditON       BSF          GPIO,1         ; when input is low(0 V)make the GPIO pin no 1 as high(LED IS ON)
            MOVLW        0X60           ; Writing the value 60 (HEX) into W register
            MOVWF        CCPR1L         ; Passing the value into the CCPR1L register to SWITCH ON the tone
            CALL         pause          ; Call delay
            BCF          GPIO,1         ; Clearing the GP1 pin (0 V) (LED is OFF)
            CLRF         CCPR1L         ; Clear the CCPR1L register to remove the sidetone
            CALL         pause          ; Call delay
;.....................................................................................................................
            GOTO         check          ; goto check to CHECK the condition and repeat the loop forever
;.....................................................................................................................
;Loop for DASH ON
;.....................................................................................................................
dashON      BSF          GPIO,1         ; make the GPIO 1 (pin no 6 of IC) to HIGH
            MOVLW        0X60           ; Writing the value 60 (HEX) into W register
            MOVWF        CCPR1L         ; Passing the value into the CCPR1L register to SWITCH ON the tone
            CALL         pause          ; call delay
            CALL         pause          ; call delay
            CALL         pause          ; call delay
            BCF          GPIO,1         ; Clearing the GP1 pin (0 V) (LED is OFF)
            CLRF         CCPR1L         ; Clearing the CCPR1L register to SWITCH OFF the side tone
            CALL         pause
;....................................................................................................................
            GOTO         check          ; goto check to CHECK the condition
;....................................................................................................................
;Loop for OFF
;....................................................................................................................

OFF         BCF          GPIO,1         ; when the input is high(5 V) make the GPIO pin no 1 as LOW(LED iS OFF)
            CLRF         CCPR1L         ; Clear CCPR1L register to remove the sidetone
;....................................................................................................................
            GOTO         check          ; goto check to CHECK the condition and repeat the loop 
;....................................................................................................................
;Main function
;....................................................................................................................
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 2MHZ 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: The value in CCPR1L is used to set the DUTY CYCLE of PWM OUT OF PR2 value.
; NOTE 7: one instruction cycle consists of 4 oscillations, to execute one instruction
;   it wil take 2 usec since clock is 2 MHz
;   DECFSZ and GOTO instruction will take 2 instruction cycle each
;   255usec* 8 = 2 mses
;    repeating the loop for 48 times => 96 msec of delay.
; NOTE 8: 11 INSTRUCTIONS USED out of 35 INSTRUCTIONS
;   2 GENERAL PURPOSE REGISTER
;   10 SPECIAL FUNCTION REGISTER used out of 38
;   62 bytes of program memory used out of 256bytes.
Here is the HEX file:
:020000040000FA :100000000301B001B101000083160F168F120F1704 :10001000831285010730990083169F0138308500CF :100020008316C030920083121214921012150C30F5 :1000300095003828FF30B0003030B100B00B1E28DA :10004000B10B1E2808008514603093001A2085101B :1000500093011A2039288514603093001A201A2041 :100060001A20851093011A20392885109301392808 :0C0070000000851E2328051E2B283528C3 :00000001FF

Tuesday, July 8, 2014

BUJJI BUG PART 6


BUJJI BUG part 6 for semi electronic generating DIT and DASH along with sidetone @ 650 Hz .


; BUJJI BUG
; CODE FOR DIT and DASH generation along with sidetone @ 650 Hz.
           list p = 12F683                                      ; Selected 12F683
           #include<p12F683.inc>                         ; Including 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 of 2K7.
;..............................................
            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
            BSF               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 2 MHz 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, because the ANSEL, TRISIO,                                                                                                                             ; T2CON  are in 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
            BSF                STATUS,RP0                ; Changing to bank 0

; Initialising the PWM for sidetone

            MOVLW        0XC0                            ; writing the value C0(HEX) into the W register
            MOVWF        PR2                               ; passing the value into PR2 register
            BCF               STATUS,RP0                ; selecting the bank 0
            BSF                T2CON,T2CKPS0       ; TIMER2 prescalar value is initiaizing as 1:4 ratio by setting                                                                                                                              ; T2CKPS0 bit
            BCF                T2CON,T2CKPS1       ; and clearing the T2CKPS1 bit in the T2CON register
            BSF                T2CON,TMR2ON       ; Enabling the TIMER2 by setting the bit TMR2ON
            MOVLW        0X0C                            ; Writing the value "12" into the W register
            MOVWF        CCP1CON                   ; Configuring the GP3 (pin no 5) as PWM OUTPUT

            GOTO            begin                              ; Goto begin
pause   MOVLW        0X60                             ; 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 ON)
            MOVLW        0X60                             ; Writing the value 60 (HEX) into W register
            MOVWF        CCPR1L                       ; Passing the value into the CCPR1L register
            CALL             pause                             ; Call delay
            BCF               GPIO,1                          ; Clearing the GP1 pin (0 V) (LED is OFF)
            CLRF             CCPR1L                       ; Clear the CCPR1L register to remove the sidetone
            CALL             pause                            ; Call delay
            GOTO            check                            ; goto check to CHECK the condition and repeat the loop
dashONBSF               GPIO,1                         ; make the GPIO 1 (pin no 6 of IC) to HIGH
            MOVLW        0X60                            ; Writing the value 60 (HEX) into W register
            MOVWF        CCPR1L                      ; Passing the value into the CCPR1L register
            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
            CLRF             CCPR1L                       ; Clear CCPR1L register to remove the sidetone
            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 2MHZ 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: The value in CCPR1L is used to set the DUTY CYCLE of PWM OUT OF PR2 value.
; NOTE 7: 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* 8 = 2 mses
; repeating the loop for 20 times => 40 msec of delay.
; NOTE 8: 13 INSTRUCTIONS USED out of 35 INSTRUCTIONS
; 2 GENERAL PURPOSE REGISTER
; 10 SPECIAL FUNCTION REGISTER used out of 38
; 50 bytes of program memory used out of 256 bytes



Here is the HEX code:

:020000040000FA
:100000000301B001B101000083160F168F120F1704
:10001000831285010730990083169F0138308500CF
:100020008316C030920083121214921012150C30F5
:10003000950032286030B0001530B100B00B1E289A
:10004000B10B1E2808008514603093001A2085101B
:1000500093011A20332885146030930033288510CB
:10006000930133280000851E2328051E2B282F28E6
:00000001FF

Monday, July 7, 2014

PADDLE KEY

Single lever paddle key we can provide @  $ 19.95 :



For queries contact kiran@micronovaimpex.com,

Saturday, July 5, 2014

BUJJI BUG PART 5

Everyone would like to operate the BUJJI BUG at their individual speed. To INCREASE/DECREASE speed of the KEY we are using EEPROM.

For this we need to WRITE and READ the value from EEPROM. Hence we are giving a small tutorial on how to do.

This can be used  in other programs also to store the value after the POWER CUT .

; BUJJI BUG
; Code to WRITE and READ from the EEPROM

        processor 16F628A                             ; Selected 16F628A
        #include <P16F628A.INC>                 ; Including the headerfile

; In this program we writing into EEPROM and reading the value back to PORTB
; We are suppose to use EEPROM for INCREMENT/DECREMENT the KEY speed.
; For checking the working of EEPROM. we are giving a small example program.
; To varify we connected an LED's from PORTB through the resistor.

        ORG         0X00                                  ; Starting address for microcontroller program
        NOP                                                    ; NO operation
        NOP                                                    ; NO operation
        NOP                                                    ; NO operation
        NOP                                                    ; This location is reserved for INTERRUPT and
;Initialising the INPUT and OUTPUT ports

        CLRF             PORTB                         ; Clearing the PORTB registers
        MOVLW        0X07                             ; Moving the "7(HEX)" into the W register
        MOVWF        CMCON                       ; Comparators are disabled
        BSF               STATUS,RP0                ; Selecting BANK 1
        BCF               STATUS,RP1               ; Selecting BANK 1
        CLRF             TRISB                          ; Making PORTB as OUTPUT
; Writing into EEPROM
        MOVLW        0X00                             ; Writing value 0 into W register
        MOVWF        EEADR                         ; Selecting the Address 0 in EEPROM to write
        MOVLW        0X10                             ; Moving value 10 (HEX) in W register
        MOVWF        EEDATA                       ; Selecting the value 10 (HEX) to write into EEPROM
        BSF               EECON1,WREN         ; Enabling the WRITE cycle
;......................................................................................................
        MOVLW       0X55                             ; Writing value 55 (HEX) into W register
        MOVWF       EECON2                       ; Passing the value into the EECON2 REGISTER
        MOVLW       0XAA                            ; Writing value AA (HEX) into W register
        MOVWF       EECON2                       ; Passing the value into the EECON2 REGISTER
;......................................................................................................
;Without the above four step the data cannot read into the EEPROM
        BSF               EECON1,WR                ; Enabling WR bit of EECON1 to write into the EEPROM
wait    BTFSC        EECON1,WR               ; Varifying whether the data is written into EEPROM or not
        GOTO           wait                                ; If yes skip this line otherwise goto wait
; Reading from EEPROM
        MOVLW      0X00                            ; Writing value 55 (HEX) into W register
        MOVWF      EEADR                        ; Selecting the address 0 in EEPROM to read
        BSF               EECON1,RD              ; Enabling the RD bit to Read the data from EEPROM
        MOVF          EEDATA,W                 ; Moving the data into the W register
wait1   BTFSC      EECON1,RD               ; Varifying whether the data is written into EEPROM or not
        GOTO          wait1                             ; If yes skip this line otherwise goto wait1
        BCF              STATUS,RP0              ; Coming back to BANK 0
        BCF              STATUS,RP1              ; Coming back to BANK 0
        MOVWF      PORTB                        ; Writing the EEPROM DATA into PORTB
        END                                                  ; END of the program


; NOTE 1:  11 instruction are used out of 35
; NOTE 2:  9 SPECIAL FUNCTION REGISTER used 38
; NOTE 3:  31 Bytes of memory is used
; NOTE 4:  The program is running with internal oscillator at default 4MHz clock speed.

   
 HEX Code:

:020000040000FA
:100000000000000000000000860107309F008316FA
:100010000313860100309B0010309A001C155530E8
:100020009D00AA309D009C149C18142800309B0051
:0E0030001C141A081C181A28831203138600C9
:00000001FF