View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 25, 2009 8:35 pm |
|
|
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
|
|
Posted: Thu Feb 26, 2009 4:08 pm |
|
|
Has this been reported to CCS? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 26, 2009 4:17 pm |
|
|
It's a problem in vs. 4.050. It's not a problem in the current vs. 4.086. |
|
|
Guest
|
|
Posted: Thu Feb 26, 2009 4:40 pm |
|
|
Thanks... |
|
|
Guest
|
|
Posted: Fri Feb 27, 2009 5:16 pm |
|
|
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
|
|
Posted: Fri Feb 27, 2009 5:35 pm |
|
|
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). |
|
|
|