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.

MPASMWIN and PIC 16F88 problem?

Status
Not open for further replies.

milosch

New Member
I have a small asm file which uses ADRESH and ADRESL. Once compiled by MPASMWIN, it appears that all references to ADRESHL (0x9E) have been changed to ADRESH (0x1E). I'm skeptical since this is from the perspective of a disassembler, but I've loaded this into PIC Simulator IDE as well and see some funny things happening to my A/D values.

I must be doing something wrong...

CLRF ADRESH ;clr result reg.
CLRF ADRESL

becomes:

CLRF 0x1E
CLRF 0x1E

CLRF NUMH
CLRF NUML
CALL SETUPDELAY ; acquisition time
BSF ADCON0,GO ; Start conversion
BTFSC ADCON0,GO_DONE
GOTO $-1 ; Loop up 1 until done
MOVF ADRESH,W
MOVWF NUMH
MOVF ADRESL,W
MOVWF NUML

becomes:

CLRF 0x2F
CLRF 0x30
CALL L18
BSF 0x1F,2
BTFSC 0x1F,2
GOTO L19
MOVF 0x1E,W
MOVWF 0x2F
MOVF 0x1E,W
MOVWF 0x30
 
Check the INCLUDE file, see what each word represents.

BUt aren't they in different banks?, and you need to change banks to access them - with each having the same address.
 
As Nigel points out, they are in different banks. To fix it switch banks around ADRESL.
Code:
		btfsc	ADCON0,GO_DONE
		goto	$-1		; Loop up 1 until done
		movf	ADRESH,W
		movwf	NUMH
		[COLOR="Blue"]bsf	STATUS,RP0	;bank 1[/COLOR]
		movf	ADRESL,W
		[COLOR="blue"]bcf	STATUS,RP0	;back to bank 0[/COLOR]
		movwf	NUML

Mike.
 
Code:
BSF ADCON1,ADFM  ;Set for right justify when using 10 bit a-d

POR for ADCON1 is ADFM=0, or left justify for an 8 bit a-d (ADRESL=0).
 
Last edited:
I am impressed. Thanks, guys. Adding the specific lines shown by Pommie above it now works. Before, I was limited to 771 +/- decimal, now I can go all the way to 1023 (doing 10-bit conversion, right-justified). Very glad you were willing to help me on such a basic headspace problem...
 
Status
Not open for further replies.

Latest threads

Back
Top