|
|
View previous topic :: View next topic |
Author |
Message |
John E. Guest
|
Problem with ADC in 18F4620 |
Posted: Sat Apr 09, 2005 5:04 pm |
|
|
Dear Friends,
I'm using CCS compiler, and I'm very satisfied. However we moved form 18f452 to 18F4620 and we recognized some problems. One of them is ADC. It was working perfectly in the 18F452, but it does not in the 18F4620. Currently modified little bit source code to make simple battery check, as follows. But it always returns 0.
Please note that we are making measurements on pin 24 of 18F4620 with name RA5/AN4/SS/LVDIN.
value is return 0.
Please also note that hardware is working, as we are using the same hardware for 18F452 and 18F4620.
Thank you for your reply.
Best regards
John E.
-----------------------------------------------------------
unsigned int16 battery_status(void)
{
unsigned int16 value;
setup_adc_ports(AN0_TO_AN5|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_20);
delay_ms(10);
set_adc_channel(4);
delay_ms(10);
value = read_adc();
setup_adc(ADC_OFF);
return value;
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Apr 10, 2005 2:38 pm |
|
|
Quite often, when CCS adds support for a new PIC, they will screw up
the A/D routines. The best way to see if this is happening is to look at
the .LST file of a test program. I don't have a version of PCH that
supports the 18F4620. If you want me to look at the problem for you,
then compile this test program with your compiler and post the .LST file.
When you post the .LST file, "X-out" your Reference Number for the sake
of privacy. CCS puts it at the top of the .LST file, after the version. Example:
CCS PCH C Compiler, Version 3.219, xxxxx
Code: | #include <18F4620.h>
#device adc=10
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, BORV42, PUT, NOLVP
#use delay(clock=20000000)
void main()
{
int16 value;
setup_adc_ports(AN0_TO_AN5 | VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_20);
set_adc_channel(4);
value = read_adc();
setup_adc(ADC_OFF);
while(1);
} |
|
|
|
John E. Guest
|
|
Posted: Sun Apr 10, 2005 3:14 pm |
|
|
Thank you for your help. Just solved by adding this line.
output_float(AD4);
now is working very well !!
Do you have any experience with FAST interrupt with CCS. We have also problem with it. In 452 is working perfectly in 6420 is not working at all.
Best Regards
John E. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
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
|