Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

small help in mplab

Status
Not open for further replies.

alalbeet

New Member
I wanted to make a program with pic 16f84 as follows :-

I will put to sensors out of door and two sensors in my house behind the door and the description of the circuit as follows :-

when any one move towards the door from out then the two sensors will send a signal to RB4 & RB5 then the door will open and when this person enters home the other two sensors will send a signal to RB6 & RB7 then the door will be closed and the opposite if this person wants to go out from home.

my assembly program is as follows please help me as there is errors

my program :-

PHP:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

W_TEMP EQU 4Bh
STATUS_TEMP EQU 4Ah
ORG 0H
goto MAIN
org 4H
goto ISR
MAIN
	bsf INTCON, GIE
	BSF INTCON, RBIE
	BSF STATUS, RP0
	MOVLW 0X0F
	MOVWF TRISB
	BSF STATUS, RP0
	CLRF PORTB
ISR
	MOVWF W_TEMP
	MOVF STATUS, W
	MOVF STATUS_TEMP
	BCF INTCON, RBIF
	BTFSS PORTB, 4
	GOTO MAIN
	BTFSS PORTB, 5
	GOTO SECOND_ISR
	CALL OPEN_DOOR
LOOP1
	BTFSS PORTB, 6
	GOTO LOOP1
LOOP2
	BTFSS PORTB, 7
	GOTO LOOP2
	CALL CLOSE_DOOR
SECOND_ISR
LOOP3
	BTFSS PORTB, 6
	GOTO LOOP3
LOOP4
	BTFSS PORTB, 7
	GOTO LOOP4
	CALL OPEN_DOOR
LOOP5
	BTFSS PORTB, 4
	GOTO LOOP5
LOOP6
	BTFSS PORTB, 5
	GOTO LOOP6
	CALL CLOSE_DOOR
END
OPEN_DOOR
	MOVLW 0X04
	MOVWF PORTB
	RETURN
CLOSE_DOOR
	MOVLW 0X08
	MOVWF PORTB
	RETURN

and the error was as follows :-

PHP:
----------------------------------------------------------------------
Debug build of project `D:\PIC\examples\door\door.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Sun Feb 08 04:50:01 2009
----------------------------------------------------------------------
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84 "door.asm" /l"door.lst" /e"door.err" /o"door.o" /d__DEBUG=1
Warning[205] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 7 : Found directive in column 1. (ORG)
Warning[203] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 8 : Found opcode in column 1. (goto)
Warning[205] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 9 : Found directive in column 1. (org)
Warning[203] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 10 : Found opcode in column 1. (goto)
Message[302] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 16 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[305] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 22 : Using default destination of 1 (file).
Error[113]   D:\PIC\EXAMPLES\DOOR\DOOR.ASM 28 : Symbol not previously defined (OPEN_DOOR)
Error[113]   D:\PIC\EXAMPLES\DOOR\DOOR.ASM 37 : Symbol not previously defined (CLOSE_DOOR)
Error[113]   D:\PIC\EXAMPLES\DOOR\DOOR.ASM 45 : Symbol not previously defined (OPEN_DOOR)
Error[113]   D:\PIC\EXAMPLES\DOOR\DOOR.ASM 52 : Symbol not previously defined (CLOSE_DOOR)
Warning[205] D:\PIC\EXAMPLES\DOOR\DOOR.ASM 53 : Found directive in column 1. (END)
----------------------------------------------------------------------
Debug build of project `D:\PIC\examples\door\door.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Sun Feb 08 04:50:05 2009
----------------------------------------------------------------------
BUILD FAILED
 
try this and see what you get
Code:
  LIST    P=PIC16F84
    #INCLUDE "P16F84.INC"
    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

	W_TEMP EQU 4Bh
	STATUS_TEMP EQU 4Ah
	ORG 0H
	goto MAIN
	org 4H
	goto ISR
MAIN
    	bsf INTCON, GIE
    	BSF INTCON, RBIE
    	BSF STATUS, RP0
    	MOVLW 0X0F
    	MOVWF TRISB
    	BSF STATUS, RP0
    	CLRF PORTB
ISR
    	MOVWF W_TEMP
    	MOVF STATUS, W
    	MOVF STATUS_TEMP
    	BCF INTCON, RBIF
   	 BTFSS PORTB, 4
    	GOTO MAIN
    	BTFSS PORTB, 5
    	GOTO SECOND_ISR
    	CALL OPEN_DOOR
LOOP1
    	BTFSS PORTB, 6
    	GOTO LOOP1
LOOP2
    	BTFSS PORTB, 7
    	GOTO LOOP2
    	CALL CLOSE_DOOR
	SECOND_ISR
LOOP3
    	BTFSS PORTB, 6
   	 GOTO LOOP3
LOOP4
   	 BTFSS PORTB, 7
    	GOTO LOOP4
    	CALL OPEN_DOOR
LOOP5
    	BTFSS PORTB, 4
    	GOTO LOOP5
LOOP6
    	BTFSS PORTB, 5
    	GOTO LOOP6
    	CALL CLOSE_DOOR

OPEN_DOOR
   	 MOVLW 0X04
    	MOVWF PORTB
    	RETURN
CLOSE_DOOR
    	MOVLW 0X08
    	MOVWF PORTB
    	RETURN  
	END
end you put at the end and you can't have directive in column 1 the left side.
 
Last edited:
try this and see what you get
Code:
  LIST    P=PIC16F84
    #INCLUDE "P16F84.INC"
    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

	W_TEMP EQU 4Bh
	STATUS_TEMP EQU 4Ah
	ORG 0H
	goto MAIN
	org 4H
	goto ISR
MAIN
    	bsf INTCON, GIE
    	BSF INTCON, RBIE
    	BSF STATUS, RP0
    	MOVLW 0X0F
    	MOVWF TRISB
    	BSF STATUS, RP0
    	CLRF PORTB
ISR
    	MOVWF W_TEMP
    	MOVF STATUS, W
    	MOVF STATUS_TEMP
    	BCF INTCON, RBIF
   	 BTFSS PORTB, 4
    	GOTO MAIN
    	BTFSS PORTB, 5
    	GOTO SECOND_ISR
    	CALL OPEN_DOOR
LOOP1
    	BTFSS PORTB, 6
    	GOTO LOOP1
LOOP2
    	BTFSS PORTB, 7
    	GOTO LOOP2
    	CALL CLOSE_DOOR
	SECOND_ISR
LOOP3
    	BTFSS PORTB, 6
   	 GOTO LOOP3
LOOP4
   	 BTFSS PORTB, 7
    	GOTO LOOP4
    	CALL OPEN_DOOR
LOOP5
    	BTFSS PORTB, 4
    	GOTO LOOP5
LOOP6
    	BTFSS PORTB, 5
    	GOTO LOOP6
    	CALL CLOSE_DOOR

OPEN_DOOR
   	 MOVLW 0X04
    	MOVWF PORTB
    	RETURN
CLOSE_DOOR
    	MOVLW 0X08
    	MOVWF PORTB
    	RETURN  
	END
end you put at the end and you can only have directive in column 1 the left side.

oh thank you very much my dear friend the program now has been assembled successfully
 
I'm a very very very starter in micro controllers plz help me to know more about micro and I need only examples

thanks alot
 
Try this site **broken link removed** It's real good for starting
to lean picking Mike showed it to me.
 
Last edited:
Need urgently

Hello am new to programming, i am trying to get the hex file from the assembly file but i keep getting these errors, please can someone help me.

;********************************************************
;
; Program Template
;
; Author : Gerard Sequeira
; Date : 4th December,2004
; Project : Implementing RS232 transmission from PIC to PIC , PIC to temperature
; sensor TMP35 and ADC TLC549
;adc pic
;5 cs rb3 pin9
;6 do rb4 pin10
;7 clk rb5 pin11
;
;********************************************************




list p=pic16f84a
include p16f84a.inc
__config _xt_osc & _wdt_off & _pwrte_on & _cp_off
errorlevel -302 ;Eliminate bank warning
ERRORLEVEL -224 ; supress annoying message because of tris








;****************************Cblock******************************************************************************

cblock 0x20 ;start of general purpose registers
Temp ; a temporary variable
bin ; binary number to be converted to BCD
hundreds ; BCD hundreds result
tens_and_ones ; BCD tens and ones result
savetmr0 ; used to save value of tmr0
dispvalue ; used to hold temperature to be displayed
tableindex ; points to table value to display
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
templcd ;temp store for 4 bit mode
templcd2
lcdtmp
Xmit_Byte ;holds byte to xmit
Xmit_Byte2 ;holds byte to xmit for 232(2)
Rcv_Byte ;holds received byte
Bit_Cntr ;bit counter for RS232
Delay_Count ;delay loop counter
adc_count ;counting 8 bits for adc
adc_buffer ;adc value
countervar ;test counter for counter routine
radiocount1 ;count for radio preamble
endc



;*****************************Equates*******************************************************************


ser_port equ portB
;ser_tris equ TRISB
ser_in equ 0x07
ser_out equ 0x06
ser_port2 equ portA
ser_out2 equ 0x01
cs equ 0x03 ;ADC handshake lines
dataout equ 0x04
clk equ 0x05
raden equ 0x02

;***********************Program*************************************************************************
org 0x0000

clrf portA
clrf portB
call main


main
call initialise
loop call adc_value
movf adc_buffer,w
call Xmit_rs2322
;;bsf portA,raden
;;call radio_init
;;call radio
;;bcf portA,raden
call short_delay
call short_delay
;call counterinc
;call finishedcount
goto loop

;*****************************Initialise Routine *************************************************************

initialise
;bsf portA,raden
call ser_init ;initialise serial port
;;call radio_init ;initialise radio
;call adc_init ;initialise adc
return

;****************Initialise Routine End *************************************************************




;********************************************adc_init Routine ****************************************************************************************
adc_init ;adc initialisation
bsf portB,cs ;adc disable
bcf portB,cs ;adc enable
return
;*********************************adc_init Routine End**********************************************************





;**************************************ADC Routine ***********************************
adc_value
bcf portB,cs
clrf adc_buffer
movlw d'8'
movwf adc_count

loop2 btfsc portB,dataout
bsf status,c
btfss portB,dataout
bcf status,c
bsf portB,clk ;clock high
bcf portB,clk ;clock low
rlf adc_buffer,f
decfsz adc_count,f
goto loop2
return
;**************************************ADC Routine End******************************************



;*******************************************Count Routine ******************************************
counterinc
movlw 0xFF
movwf countervar
loop3 movf countervar,w
call XMIT_rs2322
call short_delay
decfsz countervar,f
goto loop3
return


finishedcount
movlw 'F'
call Xmit_rs2322
call long_delay
return

;********************************************Count Routine End***************************************************


;****************************************Serial routines****************************************

ser_init
bsf status,RP0 ;select bank 1


movlw b'01111000' ;set portA
movwf TRISA

movlw b'00010111' ;set portB
movwf TRISB

bcf status,RP0 ;select bank 0
bsf portB,ser_out ;make B6 High
bsf portA,ser_out2
return
;*********************of Serial Routines*************************************

;******************************************RS 232(2) Transmit*******************************



xmit_rs2322
movwf xmit_byte2 ;move W to Xmit_Byte
movlw 0x08 ;set 8 bits out / bit_cntr is loaded with 08
movwf bit_cntr
bcf ser_port2,ser_out2 ; sending start bit / low on portB pin 6/high on max232 pin
call bit_delay



ser_loop2
rrf xmit_byte2 , f ;send one bit
btfss status , C ;if C is 1 then skip next instruct. and set portB pin 6 as MAX232 inverts signal
bcf ser_port2,ser_out2 ;if C is 0 then skip next instruct. and clear portB pin 6 as MAX232 inverts signal
btfsc status,C
bsf ser_port2,ser_out2
call bit_delay
decfsz bit_cntr,f ;test if all done
goto ser_loop2
bsf ser_port2,ser_out2
call bit_delay
return


start_delay movlw 0x0C
movwf delay_count
start_wait nop
decfsz delay_count , f
goto start_wait
return

bit_delay movlw 0x18
movwf delay_count
bit_wait nop
decfsz delay_count , f
goto bit_wait
return





;********************************************Delay *******************************************

radio_delay2
call Delay255
return
radio_delay
call Delay1
return

xraShort_delay
call Delay50
return

Short_delay
call Delay255
call delay255
call delay255

return


Long_Delay
call Delay255
call Delay255
call Delay255
call Delay255
return

Delay255 movlw 0xff ;delay 255 mS
goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay10 movlw d'10' ;delay 10mS
goto d0
Delay1 movlw d'1' ;delay 1mS
goto d0
Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz clock)
d0 movwf count1
d1 movlw 0xC7
movwf counta
movlw 0x01
movwf countb
Delay_0 decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00


;********************************************Delay routine *************************************




end


Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_wdt_off)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_pwrte_on)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_cp_off)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 64 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 68 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 78 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 79 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 87 : Symbol not previously defined (Xmit_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 92 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 93 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 114 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 115 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 125 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 130 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 131 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 131 : Symbol not previously defined (c)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 132 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 133 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 133 : Symbol not previously defined (c)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 134 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 135 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 149 : Symbol not previously defined (XMIT_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 150 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 158 : Symbol not previously defined (Xmit_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 159 : Symbol not previously defined (long_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 168 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 177 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 178 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 179 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 188 : Symbol not previously defined (xmit_byte2)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 190 : Symbol not previously defined (bit_cntr)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 197 : Symbol not previously defined (xmit_byte2)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 198 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 200 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 203 : Symbol not previously defined (bit_cntr)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 211 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 213 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 218 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 220 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 243 : Symbol not previously defined (delay255)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 244 : Symbol not previously defined (delay255)


Any help would be appreciated.

Thanks
 
HEY.... dinabrar check typing errors(you defined in CAPs and calling in lower case)

Hello am new to programming, i am trying to get the hex file from the assembly file but i keep getting these errors, please can someone help me.

;********************************************************
;
; Program Template
;
; Author : Gerard Sequeira
; Date : 4th December,2004
; Project : Implementing RS232 transmission from PIC to PIC , PIC to temperature
; sensor TMP35 and ADC TLC549
;adc pic
;5 cs rb3 pin9
;6 do rb4 pin10
;7 clk rb5 pin11
;
;********************************************************




list p=pic16f84a
include p16f84a.inc
__config _xt_osc & _wdt_off & _pwrte_on & _cp_off
errorlevel -302 ;Eliminate bank warning
ERRORLEVEL -224 ; supress annoying message because of tris








;****************************Cblock******************************************************************************

cblock 0x20 ;start of general purpose registers
Temp ; a temporary variable
bin ; binary number to be converted to BCD
hundreds ; BCD hundreds result
tens_and_ones ; BCD tens and ones result
savetmr0 ; used to save value of tmr0
dispvalue ; used to hold temperature to be displayed
tableindex ; points to table value to display
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
templcd ;temp store for 4 bit mode
templcd2
lcdtmp
Xmit_Byte ;holds byte to xmit
Xmit_Byte2 ;holds byte to xmit for 232(2)
Rcv_Byte ;holds received byte
Bit_Cntr ;bit counter for RS232
Delay_Count ;delay loop counter
adc_count ;counting 8 bits for adc
adc_buffer ;adc value
countervar ;test counter for counter routine
radiocount1 ;count for radio preamble
endc



;*****************************Equates*******************************************************************


ser_port equ portB
;ser_tris equ TRISB
ser_in equ 0x07
ser_out equ 0x06
ser_port2 equ portA
ser_out2 equ 0x01
cs equ 0x03 ;ADC handshake lines
dataout equ 0x04
clk equ 0x05
raden equ 0x02

;***********************Program*************************************************************************
org 0x0000

clrf portA
clrf portB
call main


main
call initialise
loop call adc_value
movf adc_buffer,w
call Xmit_rs2322
;;bsf portA,raden
;;call radio_init
;;call radio
;;bcf portA,raden
call short_delay
call short_delay
;call counterinc
;call finishedcount
goto loop

;*****************************Initialise Routine *************************************************************

initialise
;bsf portA,raden
call ser_init ;initialise serial port
;;call radio_init ;initialise radio
;call adc_init ;initialise adc
return

;****************Initialise Routine End *************************************************************




;********************************************adc_init Routine ****************************************************************************************
adc_init ;adc initialisation
bsf portB,cs ;adc disable
bcf portB,cs ;adc enable
return
;*********************************adc_init Routine End**********************************************************





;**************************************ADC Routine ***********************************
adc_value
bcf portB,cs
clrf adc_buffer
movlw d'8'
movwf adc_count

loop2 btfsc portB,dataout
bsf status,c
btfss portB,dataout
bcf status,c
bsf portB,clk ;clock high
bcf portB,clk ;clock low
rlf adc_buffer,f
decfsz adc_count,f
goto loop2
return
;**************************************ADC Routine End******************************************



;*******************************************Count Routine ******************************************
counterinc
movlw 0xFF
movwf countervar
loop3 movf countervar,w
call XMIT_rs2322
call short_delay
decfsz countervar,f
goto loop3
return


finishedcount
movlw 'F'
call Xmit_rs2322
call long_delay
return

;********************************************Count Routine End***************************************************


;****************************************Serial routines****************************************

ser_init
bsf status,RP0 ;select bank 1


movlw b'01111000' ;set portA
movwf TRISA

movlw b'00010111' ;set portB
movwf TRISB

bcf status,RP0 ;select bank 0
bsf portB,ser_out ;make B6 High
bsf portA,ser_out2
return
;*********************of Serial Routines*************************************

;******************************************RS 232(2) Transmit*******************************



xmit_rs2322
movwf xmit_byte2 ;move W to Xmit_Byte
movlw 0x08 ;set 8 bits out / bit_cntr is loaded with 08
movwf bit_cntr
bcf ser_port2,ser_out2 ; sending start bit / low on portB pin 6/high on max232 pin
call bit_delay



ser_loop2
rrf xmit_byte2 , f ;send one bit
btfss status , C ;if C is 1 then skip next instruct. and set portB pin 6 as MAX232 inverts signal
bcf ser_port2,ser_out2 ;if C is 0 then skip next instruct. and clear portB pin 6 as MAX232 inverts signal
btfsc status,C
bsf ser_port2,ser_out2
call bit_delay
decfsz bit_cntr,f ;test if all done
goto ser_loop2
bsf ser_port2,ser_out2
call bit_delay
return


start_delay movlw 0x0C
movwf delay_count
start_wait nop
decfsz delay_count , f
goto start_wait
return

bit_delay movlw 0x18
movwf delay_count
bit_wait nop
decfsz delay_count , f
goto bit_wait
return





;********************************************Delay *******************************************

radio_delay2
call Delay255
return
radio_delay
call Delay1
return

xraShort_delay
call Delay50
return

Short_delay
call Delay255
call delay255
call delay255

return


Long_Delay
call Delay255
call Delay255
call Delay255
call Delay255
return

Delay255 movlw 0xff ;delay 255 mS
goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay10 movlw d'10' ;delay 10mS
goto d0
Delay1 movlw d'1' ;delay 1mS
goto d0
Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz clock)
d0 movwf count1
d1 movlw 0xC7
movwf counta
movlw 0x01
movwf countb
Delay_0 decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00


;********************************************Delay routine *************************************




end


Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_wdt_off)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_pwrte_on)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 21 : Symbol not previously defined (_cp_off)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 64 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 68 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 78 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 79 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 87 : Symbol not previously defined (Xmit_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 92 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 93 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 114 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 115 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 125 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 130 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 131 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 131 : Symbol not previously defined (c)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 132 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 133 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 133 : Symbol not previously defined (c)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 134 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 135 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 149 : Symbol not previously defined (XMIT_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 150 : Symbol not previously defined (short_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 158 : Symbol not previously defined (Xmit_rs2322)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 159 : Symbol not previously defined (long_delay)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 168 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 177 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 178 : Symbol not previously defined (portB)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 179 : Symbol not previously defined (portA)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 188 : Symbol not previously defined (xmit_byte2)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 190 : Symbol not previously defined (bit_cntr)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 197 : Symbol not previously defined (xmit_byte2)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 198 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 200 : Symbol not previously defined (status)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 203 : Symbol not previously defined (bit_cntr)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 211 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 213 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 218 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 220 : Symbol not previously defined (delay_count)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 243 : Symbol not previously defined (delay255)
Error[113] C:\USERS\ABRAR\DOCUMENTS\DOWNLOADS\COMPRESSED\PIC1\PIC1.ASM 244 : Symbol not previously defined (delay255)


Any help would be appreciated.

Thanks


Example:
You defined Delay255 and calling delay255 it makes diffrence in MPLAB
aand also it's good pratice always use UPPER CASE while defining and calling.
Also Type PORTA instead of portA..
Try this and build all...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top