View previous topic :: View next topic |
Author |
Message |
shs Guest
|
I need help on pic18f2550 |
Posted: Wed Jul 18, 2007 8:30 am |
|
|
hello everyone,i am new here,thank you for you help.
i am using 18f2550 as a usb instrument,because the usb voltage is not stable,so i use a 5v as the vref+,but when i connect the an3 to 5v,the pc can not recgnize the instrument,if i remove the 5v from an3,the instument work well,i use the code below to initlize the adc,is there anyone who can help me,thank you.
SETUP_ADC_PORTS(AN0_TO_AN3 | VSS_VREF);
|
|
|
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Wed Jul 18, 2007 11:32 am |
|
|
Can you post a circuit?
Sounds like the USB device detection mechanism (pull up resistors on D+/D-) is getting clobbered by your 5v connection? |
|
|
cnshs
Joined: 18 Jul 2007 Posts: 3
|
|
Posted: Wed Jul 18, 2007 9:21 pm |
|
|
i use the circuit below:except connect a 5v to an3
|
|
|
cnshs
Joined: 18 Jul 2007 Posts: 3
|
part of source code |
Posted: Wed Jul 18, 2007 9:31 pm |
|
|
SETUP_ADC_PORTS(AN0_TO_AN3 | VSS_VREF);
SETUP_ADC(ADC_CLOCK_DIV_64);
SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_1);
SETUP_TIMER_1(T1_DISABLED);
SETUP_TIMER_2(T2_DISABLED, 127, 1);
SETUP_TIMER_3(T3_INTERNAL | T3_DIV_BY_8);
SETUP_CCP1(CCP_OFF);
SETUP_CCP2(CCP_OFF);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
tempADC = READ_ADC(); |
|
|
cnshs
Joined: 18 Jul 2007 Posts: 3
|
i hnow part of the reason |
Posted: Thu Jul 19, 2007 7:13 am |
|
|
i have know some of the reason:the vref+ is high the vdd,and there is a diode in the pin that pass the current from vref+ to vdd.
thank you for you read my question. |
|
|
Bill Boucher
Joined: 04 Feb 2005 Posts: 34 Location: Chatham,ON,CA
|
|
Posted: Thu Jul 19, 2007 8:39 am |
|
|
Your PIC is at the end of a USB cable so you need to add decoupling caps such as 100nF to 1uF across the PIC power supply pins. Also, it might help to install 20 ohm resistors in the D+ line and the D- line. Also, try connecting your analog signal at AN3 through a 1k to 10k resistor. |
|
|
|