first i am sorry my english is not the best..
i am having trouble wit this simple program.
with a pic 16f877a it works.
with a pic18f452 it compiles but returns only zero (adc_read) if i import it to oshonsoft simulator IT WORKS (maybe a problem with the simulator ?)
with pic18f4523 it will not compile (would be nice with the 12bit adc)
will not compile with pic16f886
will not compile with pic16f887
here is the program.
---------------------------------------------------------------------------
'
' commandas are:
' adc_init()
' adc_read()
'
'
'***************************initiating ADC port starts ************************
sub adc_init()
trisa = ( 00000001b )
trisa = ( 00000011b ) 'pin A0 is for analog input
adcon1 = ( 10001110b ) 'setting for only AN0 and ref of vss and vdd, Fosc/8
adcon0 = ( 01000001b ) 'setting for channel AN0 and Fosc/8 for 4Mhz, start AD
end sub
'***************************initiating ADC port ends **************************
'****************** getting the value from the ADC port starts ****************
function adc_read() as integer
adcon0.2 = 1
call delay_ms(1)
adcon0.2 = 0
call delay_ms(1)
adc_read = adresh*256
adc_read=adc_read+adresl
end function
'****************** getting the value from the ADC port ends ******************
------------------------------------------------------------------------------------------------------------------
all the best from
oz1lqb / Claus
Edited by oz1lqb, 25 September 2008 - 03:39 PM.











