View previous topic :: View next topic |
Author |
Message |
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
18LF25k40 does not go into full sleep mode |
Posted: Thu Apr 25, 2024 4:12 pm |
|
|
Good day, forum friends, I am making a control circuit with a 18LF25k40 in my hand. However, no matter what I did, I could not go below 400 uA. There is a value of 50 nA in the catalogue, but I could not get close to this figure. The circuit operates at 3 volts. What could be the reason why it does not go to full sleep?
Some of my codes are below
Code: | #include <18LF25k40.h> //oled V_2
#device ADC = 8
#FUSES PROTECT // kod koruması
#FUSES CPD
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin disabled
#FUSES NOLPBOR
#FUSES NOBROWNOUT
#FUSES NOLVP
#FUSES NOSTVREN
#FUSES NOFCMEN
#FUSES NOWRT
#FUSES NODEBUG
#fuses NOEBTRB
#fuses NOEBTR
#fuses NOEXTOSC
#FUSES NOCLKOUT
#use delay(internal = 64Mhz)
//
#OPT 9
//
//#use fast_io(ALL)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
.......................................
if(deep_sleep_timer == 1){
//
enable_interrupts(INT_IOC_b0_L2H);
enable_interrupts(INT_IOC_b1_L2H);
enable_interrupts(INT_IOC_b2_L2H);
enable_interrupts(INT_IOC_b3_L2H);
enable_interrupts(INT_IOC_b4_L2H);
enable_interrupts(INT_IOC_b5_L2H);
//
oled_command(displayoff); //oled ekran kapatılıyor
SCKP = 1; //uart low cekılıyor
//
output_low(dac_power);
output_low(power);
//
output_a(0x00);
output_b(0x00);
output_c(0x00);
//
deep_sleep_timer = 0;
sleep();
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Apr 25, 2024 5:09 pm |
|
|
to get real low power, you have to turn off any/all of the internal peripherals.
as well all pullups must be very high value (say 10M)
there's probably a few 'application notes' on Microchip's website (AN608 rings a bell..though old... ) |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Fri Apr 26, 2024 12:51 am |
|
|
I turned off all the peripherals except IOC. Why can't I go below 400uA? I couldn't find out which hardware this MCU draws current. I'm waiting for your help on this issue. Pullap 10k resistors. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Fri Apr 26, 2024 1:09 am |
|
|
Just one pullup at 10k and 3V is consuming 300uA |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Fri Apr 26, 2024 1:37 am |
|
|
The 10k resistor is not connected between VDD and GND, it is connected to the MCU input ports. |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Fri Apr 26, 2024 5:08 am |
|
|
I turned off all MCU peripherals and still could not go below 400 uA. I am waiting for your suggestions on this matter. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Apr 26, 2024 5:10 am |
|
|
Need to see your code...
It's easy to forget to disable a perhiperal, like.. 'weak pullups', the 'ADC', comparators. Are ALL I/O pins set either high or low ?
That PIC has 12-16 ? internals and ALL must be off to reduce current.
If this is a PCB be sure your clean it 3 times ,warm air dry for 2 minutes in between. Surface PCB leakage can be HIGH on 'dirty' PCBs ! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri Apr 26, 2024 9:32 am |
|
|
This is a classic 'evolution' one.
Historically on the early PIC's, when you went to sleep most peripherals
also stopped. Over the years people started wanting to have more
facilities to wake up, or to keep other parts of the chip running when
asleep, and so later chip have separate operation of just about all
peripherals. The data sheet points this out, with the notes in 38.3.3.
The comparator, low power brownout reset, fixed voltage reference,
High/Low voltage detect, WDT & secondary oscillator, all have separate
current specifications.
You need to look at Peripheral Module Disable (PMD). This allows individual
peripherals to be disabled. Key line in this section is the comment:
Important: All modules are ON by default following any system Reset.
So the consumption you get 'asleep', is the core 'sleep' current, plus
what is drawn by all the peripherals.
There are actually 30 separate parts that have to be disabled to get
down to the core current!.....
Section 7 in the data sheet, and the six PMD registers.
So even if not using things, or 'enabling' them, they are all actually
turned on by default, and drawing some power.
You need to write a '1', to each bit to disable the peripherals. |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Fri Apr 26, 2024 10:48 am |
|
|
PMD All closed. WDT is off, ADC is off, apart from these, I can't think of anything else. |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Fri Apr 26, 2024 5:37 pm |
|
|
bulut_01 wrote: | PMD All closed. WDT is off, ADC is off, apart from these, I can't think of anything else. |
After determining these, it went down to 100 uA. But my goal is to get down enough to reach nA Level. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Sat Apr 27, 2024 7:02 am |
|
|
The key at this point is what is being driven by the pins of the PIC?.
Understand that any pin driving something will draw power even when the
chip is 'asleep'. The outputs are still driving. In your case low, but if anything
connected to the pins draws power when the pins are low, then this
needs to be supplied.
You are setting the drivers low, but have not set the TRIS, You have set
FAST_IO, As such all the pins will actually be floating. A floating pin will
draw power, if it floats into the transition region between high and low.
For low power pins must not be left floating. They need to be driven either
internally or externally. |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Sat Apr 27, 2024 7:54 am |
|
|
I have separated all the components of the circuit and the sleep code of the MCU is below. In this case, this current has decreased to 100uA. This current is drawn by the MCU. The peripheral circuit elements draw around 20uA because their supply is provided by the transistor.
Code: | if(deep_sleep_timer == 1){
//
/*
enable_interrupts(INT_IOC_b0_L2H);
enable_interrupts(INT_IOC_b1_L2H);
enable_interrupts(INT_IOC_b2_L2H);
enable_interrupts(INT_IOC_b3_L2H);
enable_interrupts(INT_IOC_b4_L2H);
enable_interrupts(INT_IOC_b5_L2H);
*/
//
oled_command(displayoff); //oled ekran kapatılıyor
SCKP = 1; //uart low cekılıyor
//
output_low(dac_power);
output_low(power);
//
output_a(0x00);
output_b(0x00);
output_c(0x00);
//
/*
PMD0 = (0b00111110);
PMD1 = (0b11111110);
PMD2 = (0b11011111);
PMD3 = (0b11111111);
PMD4 = (0b10101111);
PMD5 = (0b11111111);
*/
//
pmd0 = 0xff; //bütün cevre birimler kapalı timer0 hariç
PMD1 = (0b11111110);
pmd2 = 0xff;
pmd3 = 0xff;
pmd4 = 0xff;
pmd5 = 0xff;
//
restart_wdt();
//
set_tris_A(0b00000011);
set_tris_B(0b00111111);
set_tris_C(0b10011000);
//
deep_sleep_timer = 0;
sleep(sleep_full);
} |
|
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Sat Apr 27, 2024 8:10 am |
|
|
I made a similar circuit to 16f1825, and then I went down to nA levels in sleep mode. This 18f25K40 MCU is bothering me. Putting it to sleep has turned into a state issue. What a strange MCU it is, I don't understand. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Apr 27, 2024 8:29 am |
|
|
hmm..
you have 'restart_wdt()' .....implies the WDT peripheral is enabled.
That will consume power.....
The I/O pin controlling the transistor will draw power..... |
|
|
bulut_01
Joined: 24 Feb 2024 Posts: 62
|
|
Posted: Sat Apr 27, 2024 9:06 am |
|
|
temtronic wrote: | hmm..
you have 'restart_wdt()' .....implies the WDT peripheral is enabled.
That will consume power.....
The I/O pin controlling the transistor will draw power..... |
Even if restart_wdt() is removed, the result does not change. I removed the transistor from the circuit and the result did not change. I cannot go below 100uA, the pic draws this current. |
|
|
|