CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Vref+/- pins in PIC18F4620 !?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Vref+/- pins in PIC18F4620 !?
PostPosted: Thu Dec 17, 2009 10:31 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 17, 2009 10:59 am     Reply with quote

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







PostPosted: Thu Dec 17, 2009 11:03 am     Reply with quote

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








PostPosted: Thu Dec 17, 2009 1:03 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 17, 2009 1:08 pm     Reply with quote

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








PostPosted: Thu Dec 17, 2009 1:35 pm     Reply with quote

ADR292 by the Voltage divider


Vref - and Vref+ is powered by the same ADR292...
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 17, 2009 2:44 pm     Reply with quote

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








PostPosted: Thu Dec 17, 2009 3:02 pm     Reply with quote

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








PostPosted: Thu Dec 17, 2009 5:49 pm     Reply with quote

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







PostPosted: Fri Dec 18, 2009 3:14 am     Reply with quote

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








PostPosted: Sun Dec 20, 2009 10:10 am     Reply with quote

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








PostPosted: Sun Dec 20, 2009 3:49 pm     Reply with quote

and I'm still getting strange values ;/
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 20, 2009 4:19 pm     Reply with quote

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








PostPosted: Sun Dec 20, 2009 4:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Dec 20, 2009 4:37 pm     Reply with quote

You're reading floating inputs. You don't want to do a real test.
I can't help you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group