Hello,
I'm programming a PIC18LF26K22. I put it to sleep using:
OSCCONbits.IDLEN = 0; // Activate sleep mode bit
Sleep();
This reduces the power consumption of the board (Which contains other elements, but they are all shut down and consume a few nanoampers) from 1.5 mA to 700nA.
It is still a lot. When I change the primary oscillator, i noticed that the power also changes and goes up to for example 900nA, 1.1mA or 2mA with different oscillators.
In sleep mode oscillators and CPU must be shot down and the power conspumption shouldn't change. The PIC has to wake up when an I2C adress match occurs.
This is only realized with the internal oscillator INTIO67 and I2C does not work with other oscillators. Here are some configuration settins I did. I would appreciate
if someone could tell me what the problem could be.
// Unused Peripherals are shut down when CPU is on run mode
PMD0 = 0b10111101; // Needless peripherals are shut down
PMD2 = 0b11111111; // Needless peripherals are shut down
PMD1 = 0b10111110; // Only MSSP1 and CCP1 powered
/** C O N F I G U R A T I O N B I T S ******************************/
#pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF // CONFIG1H
#pragma config BOREN = OFF, PWRTEN = OFF // CONFIG2L
#pragma config WDTEN = OFF, WDTPS = 32768 // CONFIG2H
#pragma config PRICLKEN = OFF // Primary clock enable bit (Primary clock can be disabled by software)
#pragma config PBADEN = ON //, CCP2MX = PORTC // CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF // CONFIG4L
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF // CONFIG5L
#pragma config CPB = OFF, CPD = OFF // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF // CONFIG7L
#pragma config EBTRB = OFF