Status: Started Owner: sebastien.lelong Labels: Type-Defect Priority-Medium
New issue 114 by sebastien.lelong: ADC Vref selection http://code.google.com/p/jallib/issues/detail?id=114 Reported from jallist: """ [Noel] I'm using the new(ish) adc.jal library on a 16F887. I would like to know how the external reference voltages are programmed. My understanding is that if I set ADC_NVREF=0 then NO external voltages are used, but how do I choose to use only Vref- or only Vref+ or both? """ Current ADC libs don't handle Vref- only: """ [Seb] ADC_NVREF usage is somewhat naive: when =0, no Vref, when =1, use Vref+, when =2, use Vref+ and Vref-. You can't set Vref- without Vref+. That's a limitation. Or maybe... """ Maybe defining some constants (ADC_VREF_POS_NEG, ADC_VREG_POS, ADC_VREF_NEG, ...) would help setting this up. ADC libs code need to be modified, Noel did the following changes: """ procedure adc_vcfg() is ... var byte vcfg_shadow = ADC_NVREF if ADC_NVREF == 2 then vcfg_shadow = 3 -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2 end if -- NEW CODE to allow ONLY Vref- if ADC_NVREF == 3 then vcfg_shadow = 2 -- 0b_10 | 0b_00 => 0b_10 => one bit per VCFG bit*2 end if -- End of NEW CODE """ but "works for 16F887 (and any other chip that uses ADCON0_VCFG or ADCON1_VCFG), but won't if VCFG is split across registers." -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to jal...@googlegroups.com. To unsubscribe from this group, send email to jallib+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.