View previous topic :: View next topic |
Author |
Message |
Synthex
Joined: 07 Oct 2009 Posts: 5
|
16LF18426 - ADC² module: Problem of PIC current consumption |
Posted: Sat Oct 12, 2019 4:28 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Oct 12, 2019 4:50 am |
|
|
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
|
|
Posted: Sat Oct 12, 2019 4:57 am |
|
|
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
|
|
Posted: Sat Oct 12, 2019 1:27 pm |
|
|
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: 19538
|
|
Posted: Sun Oct 13, 2019 8:46 am |
|
|
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.... |
|
|
|