|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 26, 2006 6:25 pm |
|
|
Make a simple program and run it at 10 MHz. See if it works OK.
This will tell you if the problem is related to running at 40 MHz, or
if maybe the problem is in the external circuit which provides the
analog signal. Try this program:
Code: |
#include <18F4525.h>
#device adc=10
#fuses HS, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//==============================
void main()
{
int16 CurrentValue;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(10);
while(1)
{
CurrentValue = read_adc();
printf("%lx", CurrentValue);
delay_ms(1000);
}
} |
|
|
|
prayami
Joined: 22 Dec 2004 Posts: 78
|
|
Posted: Wed Apr 26, 2006 9:28 pm |
|
|
It is working for 10MHz. Can you please let me know, what should be
the Tad and Fosc etc settings for 40Mhz. I tried as per I understand but sometimes reading unexpcted value.
Thanks... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 26, 2006 11:30 pm |
|
|
I would try it with the changes shown in bold below:
Quote: |
#include <18F4525.h>
#device adc=10
#fuses H4, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP
#use delay(clock=40000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//==============================
void main()
{
int16 CurrentValue;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_64);
set_adc_channel(0);
delay_us(10);
while(1)
{
CurrentValue = read_adc();
printf("%lx", CurrentValue);
delay_ms(1000);
}
} |
|
|
|
|
|
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
|