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

Compiler bug with setup_adc_ports in v4.109

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



Joined: 07 Dec 2004
Posts: 127
Location: Southampton, UK

View user's profile Send private message

Compiler bug with setup_adc_ports in v4.109
PostPosted: Tue Aug 03, 2010 8:52 am     Reply with quote

Hi all,

I just thought I would show you something that seems to be a bug. I suppose it doesn't strictly count as a compiler bug as it is with one of the supplied functions, setup_adc_ports();

The problem is that on an 18F87J11 (80 pins and includes port H) I want to use H7 as an input but it was always reading zero despite having turned off all the additional pin functions. I was using:

setup_adc_ports(NO_ANALOGS);

Expecting this to set all ANx pins to be digital IO but it misses H7. Here is the listing of what it does including my interpretation:

Code:


Work = 0xff

....................    setup_adc_ports(NO_ANALOGS);                             
1945A:  BSF    FC0.4    - Set the ADSHR bit to 1 accessing ANCONX not ADCONX
1945C:  MOVWF  FC1   - Move 0xFF to ANCON0 setting all pins to digital IO
1945E:  BCF    FC0.4   - Clear the ADSHR bit to 0 accessing ADCONX not ANCONX
19460:  BCF    FC2.6   - Set -Vref = AVss
19462:  BCF    FC2.7   - Set +Vref = AVdd
19464:  BSF    FC0.4   - Set the ADSHR bit to 1 accessing ANCONX not ADCONX
19466:  MOVF   FC2,W    - Move the ANCON1 register to work (ANCON1 = 0x00 on POR)
19468:  ANDLW  80       - Work AND 0x80 (0x00)
1946A:  IORLW  7F   - Work OR 0x7f (0x7F)
1946C:  MOVWF  FC2   - Put the work register back into the ANCON1 register (Sets ANCON1 0x7F from POR leaving AN15 as analogue)
1946E:  BCF    FC0.4   - Clear the ADSHR bit to 0 accessing ADCONX not ANCONX


So ANCON1 gets set to 0x7f from the power up value of 0x00 which leaves pin H7 (AN15) as an analogue input (bit 7 is set to 0) rather than digital IO (bit 7 set to 1).

Please let me know if you think I have got this right. I have not looked into it any closer, I just wrote my own setup_a2d_ports function.

Cheers

Ed
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2010 9:59 am     Reply with quote

Looks like you are right.
EdWaugh



Joined: 07 Dec 2004
Posts: 127
Location: Southampton, UK

View user's profile Send private message

PostPosted: Tue Aug 03, 2010 10:04 am     Reply with quote

Thanks!

I guess I should submit it as a proper bug report.
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