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

Problem with ADC in 18F4620

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
John E.
Guest







Problem with ADC in 18F4620
PostPosted: Sat Apr 09, 2005 5:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 10, 2005 2:38 pm     Reply with quote

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







PostPosted: Sun Apr 10, 2005 3:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 10, 2005 3:25 pm     Reply with quote

Quote:

Do you have any experience with FAST interrupt with CCS.

No. That would be Ttelmah and ckielstra and maybe a few others.
http://www.ccsinfo.com/forum/viewtopic.php?t=19498
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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