View previous topic :: View next topic |
Author |
Message |
Guest
|
Vref+/- pins in PIC18F4620 !? |
Posted: Thu Dec 17, 2009 10:31 am |
|
|
I've got problem with Vref+ and Vref- pins.
I'm working with PIC18F4620 and reference voltage pins are literally sinking all the reference voltage.
To make this situation clear:
I've got ADR292 (reference voltage) connected directly to the Vref+ PIC pin.
When ADR292 is connected to PIC the voltage on the ADR292 output pin is 0V (grounded by PIC? ? ?).
When disconnected the voltage on ADR292 is 4V...
When connected (and somehow grounded by PIC) the PIC is reading 0 (and so my voltometer)... |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Thu Dec 17, 2009 10:59 am |
|
|
One possibility is that you set that pin as an ouput and drove it low (accidentally I presumed) in your program so it sinks all the current from your reference voltage source. |
|
|
Ttelmah Guest
|
|
Posted: Thu Dec 17, 2009 11:03 am |
|
|
Obvious thing. What I/O mode are you using (standard_io, fast_io etc..), and do you at any point to a 'byte wide' output to Port A?.
If standard_io (the default) is selected, and you perfrom a byte wide output to Port A, it'll override the TRIS setting, making pins A2, and A3, into outputs, and potentially shorting out the reference....
Best Wishes |
|
|
Guest
|
|
Posted: Thu Dec 17, 2009 1:03 pm |
|
|
Code: | void main()
{
port_b_pullups(TRUE);
setup_adc_ports(ALL_ANALOG |VREF_VREF);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
set_adc_channel(0);
delay_ms(1);
adc_value=read_adc();
delay_ms(1000);
}
|
My code.... I did not switch TRIS's or make any pin output by output_low/high command....
As I just noticed all ADC pins sinks current. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Thu Dec 17, 2009 1:08 pm |
|
|
Anonymous wrote: | void main()
{
port_b_pullups(TRUE);
setup_adc_ports(ALL_ANALOG |VREF_VREF);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
set_adc_channel(0);
delay_ms(1);
adc_value=read_adc();
delay_ms(1000);
}
my code.... i did not switch TRIS's or make any pin output by output_low/high command....
As i just noticed all ADC pins sinks current. |
What do you have connected to the Vref- pin ? Is that pin just floating? |
|
|
Guest
|
|
Posted: Thu Dec 17, 2009 1:35 pm |
|
|
ADR292 by the Voltage divider
Vref - and Vref+ is powered by the same ADR292... |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Thu Dec 17, 2009 2:44 pm |
|
|
Anonymous wrote: | ADR292 by the Voltage divider
Vref - and Vref+ is powered by the same ADR292... |
Try this: ground the Vref- pin on the pin and connect the Vref+ pin to the Vout of your adr292 as before and see what you get.
PIC pins when configured as inputs provide a high impedance load to the source and cannot draw enough current to cause any significant droop in the output of your ADR292.
Post your entire program with valid fuses, maybe there is something there that is not cofigured correctly. |
|
|
Guest
|
|
Posted: Thu Dec 17, 2009 3:02 pm |
|
|
The point is this is the entire program : )
Fuses are:
Code: |
#include <18F4620.h>
#device ICD=TRUE
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV21 //Brownout reset at 2.1V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
//#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#use delay(clock=20000000,RESTART_WDT)
#define RTC_RST PIN_A4
#define RTC_SCLK PIN_A6
#define RTC_IO PIN_A7
|
|
|
|
Guest
|
|
Posted: Thu Dec 17, 2009 5:49 pm |
|
|
Ive got another problem.
When reading ADC port (AN8)...
I sometimes get reading 0000 and sometimes 512 .
The port (AN8) is grounded.... why im getting last bit lighted up (1) ?
512 is 0b: 1000000000 ... |
|
|
Ttelmah Guest
|
|
Posted: Fri Dec 18, 2009 3:14 am |
|
|
You have the LVP fuse selected. Are you actually using LVP?. 99.9% of programmers don't. If this fuse is selected, and pin RB5, is not pulled to 0v, then you will get random misbehaviour of the chip, as the line floats....
Best Wishes |
|
|
Guest
|
|
Posted: Sun Dec 20, 2009 10:10 am |
|
|
OK. I've removed LVP from FUSES...
I've manually set TRISA and TRISB to : 0xFF.
TRISA=0xFF;
TRISB=0xFF;
(I'm using AN0 to AN8 (port A and B).)
Now the Vref current is sinking no more... however all other
ADC pins are still... I do not know what to do now... ;x |
|
|
Guest
|
|
Posted: Sun Dec 20, 2009 3:49 pm |
|
|
and I'm still getting strange values ;/ |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 20, 2009 4:19 pm |
|
|
Try a simple program. Don't use Vref+ and Vref-. Put a trimpot on
pin AN0 and turn it, and see if you get the correct output.
This program assumes the PIC is running at +5 volts. It assumes the
trimpot is connected between +5v and ground, with the "tap" connected
to pin AN0:
http://www.ccsinfo.com/forum/viewtopic.php?t=32168&start=1 |
|
|
Guest
|
|
Posted: Sun Dec 20, 2009 4:31 pm |
|
|
I disconnect all ADC inputs and Read adc for channel 0-9.
I get: 0->0
1->0
2->0
3-> 1023 ... hmmm..?
4,5,6,7,8,9 ->0
:x
sorry for flood... can not edit my posts ;/ |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 20, 2009 4:37 pm |
|
|
You're reading floating inputs. You don't want to do a real test.
I can't help you. |
|
|
|