Thanks vinodstanur ,
I will try this, so far no luck with my lookup table
]/thanks,
---------- Post added at 21:10 ---------- Previous post was at 20:19 ----------
Here is my code, ADC and USART are working properly the only problem is the lookup table i need to test my output for 0-255 (0.5 increments) since it is an 8 bits register. i do need some negative readings but for now I like to solve the positive first.
Any ideas or suggestions
Thanks,
;*******************************************************************************
Lookup MACRO table,off_var
movlw HIGH (table+1) ; load PCLATH with base of table
movwf PCLATH
movlw LOW (table+1) ; add offset to base
addwf off_var,w
btfsc STATUS,C ; if overflow
incf PCLATH,f ; increment PCLATH
call table ; perform table lookup
ENDM
;********************************************************************************
MESSAGE:
; sample analog input
Delay10us ; wait 10 us for acquisition time
banksel ADCON0 ; start conversion
bsf ADCON0,GO
waitadc btfsc ADCON0,NOT_DONE ; wait until done
goto waitadc
banksel ADRESH ; copy high bits of result
swapf ADRESH,w
banksel digit
movwf digit
;copy results to LEDs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;banksel PORTC ; to low nybble of output port
;movwf PORTC
;copy results to USART;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;call delay10
banksel TXSTA
BTFSS TXSTA, TRMT
GOTO $-1
;call delay10
Lookup temp_value, digit ; lookup pattern for port A
banksel TXREG
MOVWF TXREG
GOTO MESSAGE
;lookup table;;;;;;;;;;;;;;;;;;;;;;;;;;;
temp_value addwf PCL,f
retlw '0'
retlw '1'
retlw '2'
retlw '3'
retlw '4'
retlw '5'
retlw '6'
retlw '7'
retlw '8'
retlw '9'
end