View previous topic :: View next topic |
Author |
Message |
nhamdtk4
Joined: 18 May 2009 Posts: 8 Location: Việt Nam
|
ADC of PIC18F4431, help me. Please! |
Posted: Sat Sep 26, 2009 10:44 am |
|
|
I have a project and it use module A/D converter with PIC18F4431. But I can't use config ADC. Can you help me. Thank! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
nhamdtk4
Joined: 18 May 2009 Posts: 8 Location: Việt Nam
|
|
Posted: Sun Sep 27, 2009 6:58 am |
|
|
I have tried it but it is false with 18F4431. So I don't understand what must I do if I use 18F4431. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 27, 2009 12:57 pm |
|
|
Use the program shown below. It works. I turned the 10K trimpot
on Pin A0 so it goes from the lower limit to the upper limit. Here is
the output. It's correct.
Quote: |
0000
0000
0056
00A9
0104
0169
01AF
02BC
0335
03E3
03FF
03FF
03FF
|
Here is the test program. It's running on a PicDem2-Plus board and
was compiled with PCH vs. 4.099:
Code: |
#include <18F4431.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//=================================
void main()
{
int16 result;
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(0);
delay_us(15);
while(1)
{
result = read_adc();
printf("%LX \n\r", result);
delay_ms(500);
}
} |
|
|
|
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
|
Posted: Sun Sep 27, 2009 2:59 pm |
|
|
nhamdtk4 wrote: | I have tryed it but it is false with 18F4431. So I don't understand what must i do if i use 18F4431. |
Are the AVdd and AVss pins connected?
AVdd to Vdd, and AVss to Vss. |
|
|
nhamdtk4
Joined: 18 May 2009 Posts: 8 Location: Việt Nam
|
|
Posted: Fri Oct 02, 2009 4:07 am |
|
|
Thank PCM programmer, thank Kenny very much. I have resolved my problem. |
|
|
|