Thanks, predja089. Spent the day fighting with it, but I have something that works. I tried typing it into PBP3 & looking at the ASM, but that didn't get me there. Now I'm able to take an ADC-12 read (0 >> 4095) and convert it into 4 decimal digits:
Code:MOVF ADRESH,W MOVWF b0 MOVF ADRESL,W MOVF b1 CALL DoMath MOVLW 0x30 ADDWF Dig1,W MOVWF Volts11 MOVLW 0x30 ADDWF Dig2,W MOVWF Volts12 MOVLW 0x30 ADDWF Dig3,W MOVWF Volts13 MOVLW 0x30 ADDWF Dig4,W MOVWF Volts14 CALL Display RETURN DoMath: BANKSEL Dig1 CLRF Dig1 CLRF Dig2 CLRF Dig3 CLRF Dig4 BCF STATUS, C BCF STATUS, DC Math2: ;Find the 1000,s Digit MOVLW 0x03 SUBWF b1, W BTFSS STATUS,C BRA Math3 MOVLW 0xE8 SUBWF b0, W BTFSS STATUS,C BRA Math2a MOVLW 0x03 SUBWF b1, F MOVLW 0xE8 SUBWF b0, F INCF Dig1 BRA Math2 Math2a: MOVLW 0x04 SUBWF b1,W BTFSS STATUS,C GOTO Math3 MOVLW 0x04 SUBWF b1,F MOVLW 0x18 ADDWF b0 INCF Dig1 BRA Math2 Math3: ;Find the 100,s Digit MOVLW 0x64 SUBWF b0, W BTFSS STATUS,C BRA Math4 MOVLW 0x64 SUBWF b0, F INCF Dig2 BRA Math3 Math4: ;Account for V1H Carry/Borrow DECF b1, W BTFSS STATUS,Z GOTO Math5 DECF b1,F MOVLW 0x9C ADDWF b0 INCF Dig2 BRA Math3 Math5: ;Find the 10,s Digit MOVLW 0x0A SUBWF b0, W BTFSS STATUS,C BRA Math6 MOVLW 0x0A SUBWF b0, F INCF Dig3 BRA Math5 Math6: MOVF b0,W MOVWF Dig4 RETURN




Bookmarks