Missing ...
4 Errors found before compiling : ( between star lines ...)
DEFINE ADC_BITS 8 ' set number of bits in result
DEFINE ADC_CLOCK 3 ' set clock source
DEFINE ADC_SAMPLEUS 50 ' set sampling time for microseconds
ADCON0 = %10000000 'I think this formats the result
ADCON1 = %00000000 'I think this defines if ports are A or D. The first 0 may need to be a 1
trisa = %11111111 'Port A is input
AD_AN3 VAR PORTA.4
'************************************************* *********************
FUNCTION_BUTTON VAR PORTB.X ' TO BE DECLARED AS YOUR REQUIREMENTS !!!
'************************************************* ********************
AD_AN3_VALUE VAR byte
'************************************************* *********************
C2 VAR Byte 'TO BE DECLARED "
'************************************************* *********************
pause 500 'LCD's need to initialise before sending data
LCDOUT $FE, 1 ' Clear LCD screen
A_D_AN3:
PAUSEUS 50 ' wait 50 microsec
ADCIN 3, AD_AN3_VALUE ' read channel 3 to AD_AN3_VALUE
LCDOUT $FE, 1 ' Clear LCD screen
LCDOUT "A to D Value"
LCDOUT $FE, $C0, #AD_AN3_VALUE
PAUSe 100
'************************************************* ********************
C2 = 0 ' TO BE INITIALISED HERE !!!
'************************************************* ********************
BUTTON FUNCTION_BUTTON, 1, 255, 0, C2, 1, ON_TIME_FUNC
GOTO A_D_AN3
'************************************************* ********************
ON_TIME_FUNC: ' TO BE SOMEWHERE to be called !!!
' What is it supposed to do ???????????????????
'************************************************* *********************
END
NOW still hardware mix ... We continue : your LCD is "standard connected" ... so you MUST pass its RS pin to PORTB ( see defines list) to get RA4 free, as you want it an analog input. You also must declare ALL other PORTA pins as DIGITAL ( see ADCON bytes)
Sorry, I did not verify if defaults LCD connexions are the same for F687 or F84 ... but there's no reason for a difference in the pin names !!!
Now ... we will know if real ADC problems still exist ...
Alain
Last edited by Acetronics2; - 2nd July 2006 at 16:46.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks