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

16LF18426 - ADC² module: Problem of PIC current consumption

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



Joined: 07 Oct 2009
Posts: 5

View user's profile Send private message

16LF18426 - ADC² module: Problem of PIC current consumption
PostPosted: Sat Oct 12, 2019 4:28 am     Reply with quote

It seems to me that it is not possible to shut down the ADC² module.

Is there a bug?

Code:

#include <16LF18426.h>
#device ADC=12

#FUSES NOCLKOUT
#FUSES NODEBUG
#FUSES NOEXTOSC
#FUSES NOLPBOR
#FUSES NOLVP
#FUSES NOPPS1WAY
#FUSES NOSTVREN
#FUSES NOWRT
#FUSES NOWDT
#FUSES NOPROTECT
#FUSES NOMCLR
#FUSES NOBROWNOUT
#FUSES NOFCMEN

#FUSES RSTOSC_HFINTRC
#use delay(internal=1000000)

void main()   {
   
      delay_ms(4000);    //  210 µA  @  3 volts
   
      SETUP_ADC(ADC_OFF);
   
      delay_ms(4000);    //  700 µA  @  3 volts
   
}


Consumption after startup : 210 µA
Consumption after instruction SETUP_ADC(ADC_OFF) : 700 µA

I use CCS C Complier version 5.090

Thank you so much for any help !
temtronic



Joined: 01 Jul 2010
Posts: 9255
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 12, 2019 4:50 am     Reply with quote

While I don't use that PIC or compiler version, the numbers are interesting.
My 'guess' is that the bit to turn on/ turn off the ADC is backwards.
Assuming the PIC starts up with ADC on, it consumes 210ua, then when adc is off, 700 ua.
I suggest dumping the listing and reading the datasheet (ADC section) to decode which bits are being controlled.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 12, 2019 4:57 am     Reply with quote

It's a bug in vs. 5.090. See below. They're moving 0x84 into ADCON0.
That turns the ADC on. See page 287 of the 16F18426 data sheet.
http://ww1.microchip.com/downloads/en/DeviceDoc/PIC16LF18426_46-Errata-70000799B.pdf
Quote:
.................... SETUP_ADC(ADC_OFF);
002C: MOVLW 08
002D: MOVLB 02
002E: MOVWF ADCON2
002F: CLRF ADCON3
0030: CLRF ADCLK
0031: CLRF ADACQH
0032: MOVLW FF
0033: MOVWF ADACQL
0034: MOVLB 01
0035: CLRF ADRPT
0036: MOVLW 84
0037: MOVLB 02
0038: MOVWF ADCON0
....................

Try the work-around shown in bold below:
Quote:

#byte ADCON0 = getenv("SFR:ADCON0")
void main() {

delay_ms(4000); // 210 µA @ 3 volts

SETUP_ADC(ADC_OFF);
ADCON0 = 0; // *** Bug fix in vs. 5.090. Turn ADC off.

delay_ms(4000); // 700 µA @ 3 volts

}


You should report this to CCS support.
Synthex



Joined: 07 Oct 2009
Posts: 5

View user's profile Send private message

PostPosted: Sat Oct 12, 2019 1:27 pm     Reply with quote

Yes, it works perfectly now.

I will report this bug to CCS support.

Thank you for your reactivity
and your commitment during all these years !
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Sun Oct 13, 2019 8:46 am     Reply with quote

Yes.
I've just done a little more testing, since normally a fault like this is just
a matter of the wrong value in the #define for ADC_OFF. However in this
case, none of the bits in this seem to stop the compiler from physically
enabling the ADC. So it looks as if the problem is fundamental in their
code.
So for now use PCM_Programmer's fix, and hopefully CCS will come back
with a compiler fix for this....
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