Hi Vasi, You should use adc_init for a proper setup, I think it should be called after enable_digital_io() in order to set the analog pins. As far as I recall, analog/digital settings are only affecting the inputs. Albert
----- Original Message ----- From: "funlw65" <[email protected]> To: "jallib" <[email protected]> Sent: Monday, October 19, 2009 11:58 AM Subject: [jallib] Re: Issue 99 in jallib: set_analog_pin does not generate code Thank you Sebastien, Then is weird, using previous libs and the following code, I was able to set A4 as analog input (a 10k potmeter) and A0 as digital output, making a LED to blink in 0 - 1023 (adc returned values) miliseconds interval. Note that first, all are digital and then from A0 to A4 are analog... I was able to use the same code on SDCC... It is possible to use an analog input as digital output? ADCON1 is set accordingly but TRIS is set as output for A0... this let me use any analog input as digital output? I made the tests few times (even now, my led is blinking on breadboard) -- this use previous ADC libs (without 18F2550/4550 defs) include 18f2550 -- target PICmicro pragma target clock 48_000_000 include delay -- enable_digital_io() alias led is pin_A0 pin_A0_direction = output const bit ADC_HIGH_RESOLUTION = true const byte ADC_NVREF = 0 -- const byte ADC_NCHANNEL = 4 include adc -- used code instead of set_analog_pin ADCON0 = 4 << 2; ADCON1 = 14 - 4; ADCON2 = 0xBD; set_analog_pin(4) var word measure forever loop measure = adc_read(4) led = on delay_1ms(measure) led = off delay_1ms(measure) end loop Vasi On Oct 18, 3:59pm, Sebastien Lelong <[email protected]> wrote: > Hi Vasi, > > With previous ADC lib versionb, it compiles, but no asm output for > set_analog_pin() procedure is generated. What is possible is all pins > become analog in your code, so at the end adc_read(4) does perform the > job. > > About dependent/independent pins, when you look at datasheet and see a > table > showing PCFG bits combination, it's dependent. > > Cheers, > Seb > > > > > Hi, > > > Now 18F2550/18F4550 have dependent adc pins? This code worked for me > > before for 18F2550: > > > include 18f2550 -- target PICmicro > > pragma target clock 48_000_000 > > include delay > > -- > > enable_digital_io() > > alias led is pin_A0 > > pin_A0_direction = output > > > const bit ADC_HIGH_RESOLUTION = true > > const byte ADC_NVREF = 0 > > > include adc > > adc_init() > > set_analog_pin(4) > > > var word measure > > forever loop > > measure = adc_read(4) > > led = on > > delay_1ms(measure) > > led = off > > delay_1ms(measure) > > end loop > > > -------- > > Vasi > > > On Oct 18, 1:28 am, "a.faber" <[email protected]> wrote: > > > Hi Seb, > > > The 18f4450 & 18f4450 and 18f4550 are OK now, while making the unit > > test, I > > > noticed that the 18f4458 does not work maybe you can check this one > > > too. > > > Albert > > -- > Sbastien Lelonghttp://www.sirloon.nethttp://sirbot.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
