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.

Pro pls help me check this program

Status
Not open for further replies.

babboy12345

New Member
I cant build this program,got error occur,but the problems is i dono how to corrected it....pls help


LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_O

CHK1 EQU 0X21
CNT1 EQU 0CH
CNT2 EQU 0DH

count EQU 020;
org 0x000
nop ;

banksel TRISA
movlw b'00000000';
movwf TRISB;

banksel ADCON1
movlw b'10000000
movwf ADCON1

banksel ADCON0
movlw b'10000001
movwf ADCON0

getAD movlw 007
movwf count
down decfsz count
goto down

bsf ADCON0,GO
wait btfsc adcon0,GO
goto wait
return


start call getAD ; get adc result store at adresh
movlw 0xC8 ;
error here subwf adresh,1 ; adc result in adresh will minus....
btfsc adresh,0 ;...C8 and the answer store at adresh again..
goto start ; if answer in adresh is not 0....then the program will jump to start again...
btfsc adresh,1
goto start
btfsc adresh,2
goto start
btfsc adresh,3
goto start
btfsc adresh,4
goto start
btfsc adresh,5
goto start
btfsc adresh,6
goto start
btfsc adresh,7
goto start
bsf portb
call delay
end

delay MOVLW D'5'
MOVWF CNT2

CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
 
Try moving the END instruction to the end of the code.

Also, when posting code type
Code:
 before it and
after it so that it keeps it's formatting.

Mike.
 
i try to put end there....bt still got error..wat u means by (Also, when posting code type
Code:
 before it and
after it so that it keeps it's formatting.)???
 
i try to put end there....bt still got error..wat u means by (Also, when posting code type
Code:
 before it and
after it so that it keeps it's formatting.)???

See what happened when you typed it into your post there? You created that blue 'code' block in your post. If you put those tags before and after any source code that you include in yours posts, then it will format the code and make it easier for everybody to read.

Another hint is that you should never just say 'I got an error' without also saying exactly what the error was. There was probably information in the error which would help determine exactly what the error was and why it occurred. That's why error messages are generated.


Regards,

Torben
 
the error say Symbol not previously defined (adresh)


code:/
LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_O

CHK1 EQU 0X21
CNT1 EQU 0CH
CNT2 EQU 0DH

count EQU 020;
org 0x000
nop ;

banksel TRISA
movlw b'00000000';
movwf TRISB;

banksel ADCON1
movlw b'10000000
movwf ADCON1

banksel ADCON0
movlw b'10000001
movwf ADCON0

getAD movlw 007
movwf count
down decfsz count
goto down

bsf ADCON0,GO
wait btfsc ADCON0,GO
goto wait
return


start call getAD
movlw 0xC8
error here subwf adresh,1
btfsc adresh,0
goto start
btfsc adresh,1
goto start
btfsc adresh,2
goto start
btfsc adresh,3
goto start
btfsc adresh,4
goto start
btfsc adresh,5
goto start
btfsc adresh,6
goto start
btfsc adresh,7
goto start
bsf portb
call delay
end

delay MOVLW D'5'
MOVWF CNT2

CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
end
/
 
another error say Missing argument(s)


code:/

LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_O

CHK1 EQU 0X21
CNT1 EQU 0CH
CNT2 EQU 0DH

count EQU 020;
org 0x000
nop ;

banksel TRISA
movlw b'00000000';
movwf TRISB;

clrf PORTB

banksel ADCON1
movlw b'10000000
movwf ADCON1

banksel ADCON0
movlw b'10000001
movwf ADCON0

getAD movlw 007
movwf count
down decfsz count
goto down

bsf ADCON0,GO
wait btfsc ADCON0,GO
goto wait
return


start call getAD ; get adc result store at adresh
movlw 0xC8 ;
subwf ADRESH,1 ; adc result in adresh will minus....
btfsc ADRESH,0 ;...C8 and the answer store at adresh again..
goto start ; if answer in adresh is not 0....then the program will jump to start again...
btfsc ADRESH,1
goto start
btfsc ADRESH,2
goto start
btfsc ADRESH,3
goto start
btfsc ADRESH,4
goto start
btfsc ADRESH,5
goto start
btfsc ADRESH,6
goto start
btfsc ADRESH,7
goto start
error here bsf PORTB
call delay
end

delay MOVLW D'5'
MOVWF CNT2

CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
code:/
 
If you edit your post and put code tags around the code we may be able to see the errors. As it is we are just guessing.

Mike.
 
another error say Missing argument(s)


code

LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_O

CHK1 EQU 0X21
CNT1 EQU 0CH
CNT2 EQU 0DH

count EQU 020;
org 0x000
nop ;

banksel TRISA
movlw b'00000000';
movwf TRISB;

clrf PORTB

banksel ADCON1
movlw b'10000000
movwf ADCON1

banksel ADCON0
movlw b'10000001
movwf ADCON0

getAD movlw 007
movwf count
down decfsz count
goto down

bsf ADCON0,GO
wait btfsc ADCON0,GO
goto wait
return


start call getAD ; get adc result store at adresh
movlw 0xC8 ;
subwf ADRESH,1 ; adc result in adresh will minus....
btfsc ADRESH,0 ;...C8 and the answer store at adresh again..
goto start ; if answer in adresh is not 0....then the program will jump to start again...
btfsc ADRESH,1
goto start
btfsc ADRESH,2
goto start
btfsc ADRESH,3
goto start
btfsc ADRESH,4
goto start
btfsc ADRESH,5
goto start
btfsc ADRESH,6
goto start
btfsc ADRESH,7
goto start
error here bsf PORTB
call delay
end

delay MOVLW D'5'
MOVWF CNT2

CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
/code
 
another error say Missing argument(s)


Code:
LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_O

CHK1 EQU 0X21
CNT1 EQU 0CH
CNT2 EQU 0DH

count EQU 020;
org 0x000
nop ;

banksel TRISA
movlw b'00000000';
movwf TRISB;

clrf PORTB

banksel ADCON1
movlw b'10000000
movwf ADCON1

banksel ADCON0
movlw b'10000001
movwf ADCON0

getAD movlw 007
movwf count
down decfsz count
goto down

bsf ADCON0,GO
wait btfsc ADCON0,GO
goto wait
return 


start call getAD ; get adc result store at adresh
movlw 0xC8 ; 
subwf ADRESH,1 ; adc result in adresh will minus....
btfsc ADRESH,0 ;...C8 and the answer store at adresh again..
goto start ; if answer in adresh is not 0....then the program will jump to start again...
btfsc ADRESH,1
goto start
btfsc ADRESH,2
goto start
btfsc ADRESH,3
goto start
btfsc ADRESH,4
goto start
btfsc ADRESH,5
goto start
btfsc ADRESH,6
goto start
btfsc ADRESH,7
goto start
error here bsf PORTB
call delay
end

delay MOVLW D'5'
MOVWF CNT2

CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
 
when you look at the error message, it also show you the line number

Ex: Warning[209] C:\ASM_PROG\TEST.ASM 23 : Missing quote

where 23 is the line number. In your case it's the BSF PORTB line.

You'll also have an "Symbol not previously defined (delay)" because your END statement is before the end of you program.

this section
Code:
		banksel TRISA
		movlw b'00000000';
		movwf TRISB;
		
		clrf PORTB
PORTB is not in the same BANK as TRISB, so you'll have to fix it.

What I suggest is to have a look at the datasheet, set register in BANK0, then move on BANK1 and so on

this section at the top of your code
Code:
wait 
        btfsc ADCON0,GO
		goto wait
		return

once it will hit the RETURN.. it return where as it haven't been called before? Stack underflow :( So, OR you move this routine elsewhere, OR you add a GOTO Start before getAD label.

Code:
count EQU 020;
You should make sure if it's correct, same for other GPRs.

Code:
...  _PWRTE_O
have to be _PWRTE_ON

There's also potential issue with this
Code:
here    bsf PORTB <--- missing something here
		call delay

delay 
		MOVLW D'5'
		MOVWF CNT2

What happen after the Call Delay, yup it process the delay routine again... and will hit another RETURN, another Stack underflow.

HTH
 
Last edited:
Code:
		banksel TRISA
		movlw b'00000000';
		movwf TRISB;
		
		clrf PORTB
(PORTB is not in the same BANK as TRISB, so you'll have to fix it.)

can any1 give me a solution for it pls
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top