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 CCS Technical Support

Problem with 16F882

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 25, 2009 8:35 pm     Reply with quote

Your version has a bug in the start-up code and in the setup_adc_ports()
function. It doesn't set the ANSEL register. To fix this, you'll need to
do it manually. Add the lines shown in bold below:
Quote:

#byte ANSEL = 0x188


void main(void)
{
int8 iIndex;

Setup_adc_ports( NO_ANALOGS );
Setup_comparator(NC_NC_NC_NC);
ANSEL = 0x00; // Set A/D pins to all digital

// Here we set the default variable and output states....
output_low(Xbee_Reset); // hold the Xbee in reset
output_low(Pwr_LED);


---------
Edit: Removed fix for ANSELH. Only ANSEL needs a fix in vs. 4.050.


Last edited by PCM programmer on Thu Feb 26, 2009 4:20 pm; edited 1 time in total
Guest








PostPosted: Thu Feb 26, 2009 4:08 pm     Reply with quote

Has this been reported to CCS?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 4:17 pm     Reply with quote

It's a problem in vs. 4.050. It's not a problem in the current vs. 4.086.
Guest








PostPosted: Thu Feb 26, 2009 4:40 pm     Reply with quote

Thanks...
Guest








PostPosted: Fri Feb 27, 2009 5:16 pm     Reply with quote

PCM,

Thanks, that solved my problem! My applicaton is now working 100% with the new chip!

As a matter of good programming etiquette, should I be explicitly disabling things like the comparator and analog-to-digital modules in my programs if they are not used? What is the generally accepted convention?

Thanks,

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 27, 2009 5:35 pm     Reply with quote

Normally you don't have to. CCS puts in start-up code to disable
the comparators, the vref module, and also to make Port A into a
digital port. This code is in the .LST file, at the start of main().
You don't see it in your source code.

Often, when CCS updates the compiler with new PICs, some of these
things are not done correctly. In some cases it can be fixed by calling
the setup_comparator(), setup_vref(), and setup_adc_ports() functions
with 'disable' parameters. But sometimes those don't work, either.
They may have the same bug as the start-up code. That's the case
with setup_adc_ports() with your PIC in vs. 4.050. Then you have to
manually set things up by writing directly to register(s).
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