Sunday, August 7, 2016
Saturday, August 6, 2016
Wednesday, August 3, 2016
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
Here the BUJJI BUG comes in a Nutcase.
The pictures and circuit diagram of Bujji Bug is given below.
Here is the HEX codeBUJJI 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.
: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.
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.
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.
Subscribe to:
Posts (Atom)
























