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

10F320 Analog Pins on Power on Reset

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



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

10F320 Analog Pins on Power on Reset
PostPosted: Wed Mar 06, 2013 8:39 pm     Reply with quote

10F320
Version 4.141

I'm a little confused here and my [very] cursory search of the forum didn't find anything related.

Per the data sheet Section 10.1.2:
Quote:
The ANSELA bits default to the Analog
mode after Reset. To use any pins as
digital general purpose or peripheral
inputs, the corresponding ANSEL bits
must be initialized to ‘0’ by user software.


I get that.
And my current project doesn't utilize anything analog. So CCS gives us the easy to use function of:
Code:
setup_adc_ports(NO_ANALOGS);


Only thing is that when I look at my .lst file of generated code I see that only a couple instructions after "main" it is writing 0 to the ANSELA register. I was attempting to save any precious words that I could so I removed my setup_adc_ports(NO_ANALOGS) line. Sure enough, it still says it is is writing 0 to ANSELA. To test if there was something else in my code that caused this I went ahead and made as small a program as I could get to compile.
Code:
#include <10F320.h>
#fuses INTRC, NOBROWNOUT, NOWDT, PUT, NOMCLR, NOPROTECT, NOLVP, NOLPBOR, NOWRT, NODEBUG
void main(void)
{
  ;
}


And the resulting .lst:

Code:
CCS PCM C Compiler, Version 4.141, 2020               06-Mar-13 20:13

               Filename:   C:\Users\Dan\Desktop\compile test\ansela_test.lst

               ROM used:   7 words (3%)
                           Largest free fragment is 249
               RAM used:   4 (6%) at main() level
                           4 (6%) worst case
               Stack:     0 locations

0000:  MOVLW  00
0001:  MOVWF  PCLATH
0002:  GOTO   main
0003:  NOP
.................... #include <10F320.h>
.................... //////// Standard Header file for the PIC10F320 device ////////////////
.................... #device PIC10F320
.................... #list
.................... 
.................... #fuses INTRC, NOBROWNOUT, NOWDT, PUT, NOMCLR, NOPROTECT, NOLVP, NOLPBOR, NOWRT, NODEBUG
.................... void main(void)
.................... {
0004:  MOVLW  00
0005:  MOVWF  ANSELA
....................   ;
.................... }
0006:  SLEEP

Configuration Fuses:
   Word  1: 3C80   INTRC NOBROWNOUT NOWDT PUT NOMCLR NOPROTECT NOLVP NOLPBOR BORV19 NOWRT NODEBUG



I'm not complaining [now] because for my purpose, I don't want any analog pins and this is saving me two lines of code. But curiousity begs to know why it is that the ANSELA register is being written to? I didn't tell it to, and the behavior is not as the data sheet describes. Is this a bug in the compiler?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 9:43 pm     Reply with quote

The default behavior of the compiler is to initialize PortA to be all digital.
It's been that way for years.
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 9:50 pm     Reply with quote

Thank You
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 9:55 pm     Reply with quote

On second thought, is it possible to change this default behavior?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 06, 2013 10:36 pm     Reply with quote

I don't think there's an option to do that. It would be either a #device
or a #build option and I don't see one available.
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