View previous topic :: View next topic |
Author |
Message |
championx
Joined: 28 Feb 2006 Posts: 151
|
Internal Vref 18F67j50 |
Posted: Sun Jul 07, 2019 5:28 pm |
|
|
Hi! im trying to configure the internal vref of a pic 18F67j50, but the adc reads always 1023.
Here is the config:
Code: |
setup_vref(VREF_high | 15);
setup_adc_ports(sAN0| VSS_VREF);
set_adc_channel(0);
|
but every time i read the ADC port, it returns 1023. If i test it without the VREF it works fine.
thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jul 07, 2019 7:27 pm |
|
|
The internal Vref generator is intended for the comparators, not the A/D. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Sun Jul 07, 2019 8:05 pm |
|
|
I was curious, so I looked at the datasheet.
While it can't be used 'internally connected', you can access the Vref generator on pin RF5. You can connect that to the ADC Vref+ input pin ( AN3). That 'should' work, HOWEVER be sure to read the ADC specs for the allowable value Vref+ can be. That'll be in the back of the datasheet ( electrical specs...) Also you'll probably need to buffer the Vref output (that's in the datasheet too....)
It might be worth the 1/2 day to 'work it out, on the bench' to see if it'll do what you want. That all depends on your application.
Jay |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Mon Jul 08, 2019 8:25 am |
|
|
Back when I used a couple of PIC16Fxxxx they had a fixed voltage reference (FVR) module that allowed selecting a 1.024, 2.048, or 4.096V internally generated reference for the ADC. It was convenient. I wonder why they didn't put that over to other PICs as well. |
|
|
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Thu Jul 11, 2019 8:17 pm |
|
|
Hi! thanks for your answers... yes, sadly, this pic does not have FVR... I can't use the external Vref pin because its already mapped on the board.
I guess i should make a capacitor discharge time measurement to use this pin as ADC.
Thanks! |
|
|
|