Reducing sleep current of PIC10F322 not possible - Page 1
Forum section: electronics / general

author: babolcs
author_rank: Newbie
timestamp: November 02, 2023, 06:51:32 pm
content: Hi,I try to reduce the sleep current of PIC10F322, but not possible to go below 10.5uA.Originally I have PWM, ADC, FVR, TMR2 in my project, but now I created an empty one and didn't added any of them.I use MCC, checked if all the register/service switched off, even the WDT and the BOR too.But the power usage is 10.5uA still.My code is extremly simple in that skeleton version:while (1){// Add your application codeIO_RA2_SetHigh();__delay_ms(2000);IO_RA2_SetLow();IO_RA1_SetLow();IO_RA0_SetLow();SLEEP();NOP();}WDT disabled and WDT enabled doesn't change the current usage neither.The device_config.c is the followingpragma config FOSC = INTOSC // Oscillator Selection bits->INTOSC oscillator: CLKIN function disabled#pragma config BOREN = OFF // Brown-out Reset Enable->Brown-out Reset disabled#pragma config WDTE = OFF // Watchdog Timer Enable->WDT disabled#pragma config PWRTE = OFF // Power-up Timer Enable bit->PWRT disabled#pragma config MCLRE = ON // MCLR Pin Function Select bit->MCLR pin function is MCLR#pragma config CP = OFF // Code Protection bit->Program memory code protection is disabled#pragma config LVP = ON // Low-Voltage Programming Enable->Low-voltage programming enabled#pragma config LPBOR = OFF // Brown-out Reset Selection bits->BOR disabled#pragma config BORV = LO // Brown-out Reset Voltage Selection->Brown-out Reset Voltage (Vbor), low trip point selected.#pragma config WRT = OFF // Flash Memory Self-Write Protection->Write protection offThere is only 1 lead on the pins (with a resistor to VDD, but If I remove it is the same.)only 1 10uF cap is there (if I remove it is the same.The current measure unit is an old voltcraft m-4650B which is 4.5 digits and quite punctual it has 200uA limit and capable to measure 0.1uA too.VDD=2.8V if I reduce to 2.3 it goes down to 9.5uA but not below 1uA.No other idea.Thanks,Szabolcs

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 02, 2023, 07:05:25 pm
content: And the init code? Gpio config plays a big role.

author: Andreas
author_rank: Super Contributor
timestamp: November 02, 2023, 07:10:17 pm
content: Quote from: babolcs on November 02, 2023, 06:51:32 pmI would switch all analog functions off.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 02, 2023, 07:16:37 pm
content: Quote from: Andreas on November 02, 2023, 07:10:17 pmIt is:Code:#pragma config BOREN = OFF // Brown-out Reset Enable->Brown-out Reset disabled

author: babolcs
author_rank: Newbie
timestamp: November 02, 2023, 08:07:59 pm
content: Hi, Since I haven't added and services, I didn't initialized anything from code just from MCC.So in main just there is the MCC generated code:void main(void){// initialize the deviceSYSTEM_Initialize();while(1) ....which is realized in the mcc.c: (also MCC generated code)void SYSTEM_Initialize(void){PIN_MANAGER_Initialize();OSCILLATOR_Initialize();WDT_Initialize();}void OSCILLATOR_Initialize(void){// LFIOFR 31.25KHz_osc_not_ready; HFIOFS unstable; HFIOFR 16MHz_osc_not_ready; IRCF 31KHz;OSCCON = 0x00;// CLKROE disabled;CLKRCON = 0x00;// SBOREN disabled; BORFS disabled; BORRDY BOR Circuit is inactive;BORCON = 0x00;}void WDT_Initialize(void){// WDTPS 1:262144; SWDTEN OFF;WDTCON = 0x1A;}/**End of File*/Adn this is in pin_manager.c :void PIN_MANAGER_Initialize(void){/**LATx registers*/LATA = 0x00;/**TRISx registers*/TRISA = 0x00;/**ANSELx registers*/ANSELA = 0x00;/**WPUx registers*/WPUA = 0x00;OPTION_REGbits.nWPUEN = 1;}void PIN_MANAGER_IOC(void){}/**End of File*/

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 02, 2023, 08:40:17 pm
content: Make use of the code tags!The adviced ultra low power is based on very specific settings, a simple GPIO being enabled can change it completely.Also the advertised 20nA are at 1.8V.If you really want low power consumption, then you must get the PIC10LF322.Since you're using MCC, you'll have to check what these functions do. My advice is to not use MCC, PIC10 are extremely easy to configure.Check datasheet page 44:QuoteSo, you might try this, connect nothing to the pins:Code:TRISA=0x0F; // All pisn as inputsANSELA = 0; // All pins as digitalWPUA = 0x0F; // Enable all pullupsOPTION_REGbits.nWPUEN = 0; // Enable pullupsYou can also try disabling the pullups and using external 100K pull-downs.Or setting all pins to analog, so the pin digital interfaces becomes disabled, might lower the power consumption:Code:ANSELA = 0x07; // All pins as analogRead:https://www.eevblog.com/forum/microcontrollers/help-reducing-sleep-current-in-pic10f322/https://www.electro-tech-online.com/threads/pic10f322-sleep-current-challenge.130596/Also, try disabling MCLRE:Code:#pragma config MCLRE = OFF

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 03, 2023, 08:26:42 pm
content: Any input pin left floating is indeed the #1 cause of excessive current draw with CMOS devices.Many MCUs, PIC10 included, have their GPIOs default to inputs on reset and will remain so unless you configure them as outputs. If there's no pull-up or pull-down on those pins, you'll have excess current draw, 99.99% guaranteed.Only a very few MCUs do have input pads on their GPIOs that can be disabled (and even fewer have these disabled by default on reset), with those you can afford not to care to configure them explicitely as they will draw no current when disabled even if left floating. But that's the exception rather than the norm.

author: babolcs
author_rank: Newbie
timestamp: November 04, 2023, 12:19:44 am
content: Hi Put to all input/output a resistor (1M to GND), power usage increase to 18uA (understandable, because some were output.) So it hasn't solved the issue. So still without any functions the PIC10F322 sleep current is minimum 10.5uA for me.Can anyone produce smaller? I strongly doubt that the <1uA can be achieved.

author: errorprone
author_rank: Contributor
timestamp: November 04, 2023, 12:23:55 pm
content: It may be worthwhile to try and leave OSCCON at its default value instead of changing it to the 31khz oscillator (0x00). The 31khz may still be operating.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 04, 2023, 12:32:42 pm
content: Quote from: babolcs on November 04, 2023, 12:19:44 amWhy you keep doing what you want? I'm out.

author: boz
author_rank: Regular Contributor
timestamp: November 05, 2023, 05:30:26 am
content: Quote from: babolcs on November 04, 2023, 12:19:44 amA pin set as an output driver with nothing connected would not consume any current as they are push/pull MOSFETs

author: cv007
author_rank: Frequent Contributor
timestamp: November 05, 2023, 11:35:42 pm
content: I have a 10LF322 as an ir remote, it draws 20na in sleep as the datasheet claims.There is nothing special to do to get there-https://github.com/cv007/2button_remote/blob/master/main.cnot my favorite code, but there is essentially nothing there other than setting 2 pins to digital in w/pullups (switches) and 2 as digital outputs (leds). Fuses not shown, but brownout is disabled, watchdog unused.If you have a 10F322 instead of a 10LF322, then you may be losing the XLP low power feature. I don't remember what the difference is, but I'm pretty sure the difference is not insignificant when low power is important.You should also disconnect the programmer when doing current measurements. Not sure if necessary in this particular case, but it can be a source of invalid measurements.