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.

what wrong with my coding

Status
Not open for further replies.
Code:
	list		p=16F887
	#include	<p16F887.inc>

	__CONFIG	_CP_OFF&_WDT_OFF&_PWRTE_ON&_LVP_OFF&_HS_OSC


		ORG		0x000
		goto 	main

main

		banksel	TRISA
		movlw	0xFF
		movwf	TRISA
		clrf	TRISC
		clrf	TRISD
		banksel	ADCON0

		movlw	b'10000001'
		movwf	ADCON0
		banksel	ADCON1
		movlw	b'10001110'
		movwf	ADCON1
		banksel	ADCON0


		bsf	ADCON0,2
		btfsc	ADCON0,2
		goto	$-1
		movf	ADRESH,0
		andlw	b'00000011'
		movwf	PORTC
		banksel	ADRESL
		movf	ADRESL,0
		banksel	ADRESL
		movwf	PORTD

	return

	end

have error
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F887 "as.asm" /l"as.lst" /e"as.err"
Error[126] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 4 : Argument out of range (not a valid config register address)
Message[302] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 14 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 15 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 16 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 23 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] D:\USERS\GH0STSHIFT\DOCUMENTS\STUDY\PROGRAM\CNTH\AS.ASM 34 : Register in operand not in bank 0. Ensure that bank bits are correct.
Halting build on first failure as requested.
 
Last edited:
You have a redundant bankswitching for ADRESL and you're writing literal values to ADCON and then setting bits in it which appear redundant as well.

I have altered the config and suppressed the bank warnings but I have not changed the coding..not sure what is going on other than some type of repeated initialisation.
Code:
	list		p=16F887
	#include	<p16F887.inc>

	__CONFIG    _CONFIG1,  _IESO_OFF & _FCMEN_OFF & _PWRTE_ON  & _WDT_OFF & _INTOSCIO & _BOR_ON & _LVP_OFF & _CP_OFF &_CPD_OFF & _MCLRE_OFF &_INTRC_OSC_NOCLKOUT
	__CONFIG    _CONFIG2,	_WRT_OFF & _BOR40V
	
	errorlevel -302 ; suppress message 302 from list file


		ORG		0x000
		goto 	main

main

		banksel	TRISA
		movlw	0xFF
		movwf	TRISA
		clrf	TRISC
		clrf	TRISD
		banksel	ADCON0

		movlw	b'10000001'
		movwf	ADCON0
		banksel	ADCON1
		movlw	b'10001110'
		movwf	ADCON1
		banksel	ADCON0


		bsf	ADCON0,2
		btfsc	ADCON0,2
		goto	$-1
		movf	ADRESH,0
		andlw	b'00000011'
		movwf	PORTC
		banksel	ADRESL
		movf	ADRESL,0
		banksel	ADRESL
		movwf	PORTD

	return

	end
 
It's only part of a program, you have a spurious return at the end (which will crash it), and no ending to the program, so it will over-run and start from the beginning continually.
 
Status
Not open for further replies.

Latest threads

Back
Top