Wednesday, March 2, 2011

PIC 12F1822 current draw at different frequencies

Because the datasheet for the PIC 12F1822 lists the supply current for only a select number of internal oscillator frequencies I went and measured the current draw for all of them under various I/O settings.

The MCU was programmed and powered by a PICkit2 whose VDD was set to 5.0VDC when programming. It was set to either 5.0V or 3.0V when logging maximum, minimum and average current draw. The only thing connected to the MCU was the PICkit 2. The two were mated throughout the test. No resistors, capacitors, etc. were used. Ambient temperature during tests was 27° to 29° Celsius.

A Fluke 87V digital multimeter was set to read µA, with Min-Max feature enabled. The DMM was hooked up in series with the MCU's VSS and PICkit2's VSS. The meter was given between half a minute to a minute to gather data.

In the MCU configuration words, INTOSC with I/O function on CLKIN pin was selected. MCLRE, WDTE and PLLEN were disabled. Note that with the MCLR inoperative, RA3/MCLR pin is floating. Leaving an input floating increases current draw. In the tests below weak pull-ups were either enabled or disabled to record this difference. All peripherals (ADC, comparators, etc.) were left at their default settings, which I believe are off.  

The various firmware used are provided below. C compiler employed was the mikroC Pro v4.60

A1.
// FOR MEASURING CURRENT AT VARIOUS INTERNAL OSCILLATOR FREQUENCIES
// All I/O pins are all digital outputs in sinking current mode (grounded) 
// RA3/MCLR pin weak pull-up is enabled (MCU automatically disables pull ups for pins configured as output)
void main()
{
  PORTA = 0;
  TRISA = 0;
  ANSELA = 0;
  NOT_WPUEN_bit = 0;    // global pull-up enable
  WPUA = 0XFF;          // individual pull-up enable
  OSCCON = 0b0;         // change OSCCON value to set various internal oscillator frequencies
  while(1) ;
}

A2.
// FOR MEASURING SLEEP CURRENT
// All I/O pins are all digital outputs in sinking current mode (grounded) 
// RA3/MCLR pin weak pull-up is enabled (MCU automatically disables pull ups for pins configured as output)
void main()
{
  PORTA = 0;
  TRISA = 0;
  ANSELA = 0;
  NOT_WPUEN_bit = 0;    // global pull-up enable
  WPUA = 0XFF;          // individual pull-up enable
  asm sleep
  while(1) ;
}

B1.
// FOR MEASURING CURRENT AT VARIOUS INTERNAL OSCILLATOR FREQUENCIES
// All I/O pins are by default analog inputs 
// All weak pull-ups are enabled
void main()
{
  NOT_WPUEN_bit = 0;    // global pull-up enable
  WPUA = 0XFF;          // individual pull-up enable
  OSCCON = 0b0;         // change OSCCON value to set various internal oscillator frequencies
  while(1) ;
}

B2.
// FOR MEASURING SLEEP CURRENT
// All I/O pins are by default analog inputs 
// All weak pull-ups are enabled
void main()
{
  NOT_WPUEN_bit = 0;    // global pull-up enable
  WPUA = 0XFF;          // individual pull-up enable
  asm sleep
  while(1) ;
}

C1.
// FOR MEASURING CURRENT AT VARIOUS INTERNAL OSCILLATOR FREQUENCIES
// All I/O pins are by default analog inputs 
// All weak pull-ups are by default disabled
void main()
{
  OSCCON = 0b0;         // change OSCCON value to set various internal oscillator frequencies
  while(1) ;
}

C2.
// FOR MEASURING SLEEP CURRENT
// All I/O pins are by default analog inputs 
// All weak pull-ups are by default disabled
void main()
{
  asm sleep
  while(1) ;
}

Open this Google spreadsheet to see the test results. As can be clearly seen, the lowest power consumption is obtained with I/O pins set as output. The worst configuration as expected is that with floating inputs. It was discovered that having analog instead of digital inputs just slightly decreases current draw.

Below are screenshots of the pertinent table from the datasheet:


Compared to the datasheet, the results I obtained shows the 12F1822 (at least the chip I tested) performs  better than specification, although I hardly duplicated Microchip's test conditions exactly.

According to the specs the LF version draws a maximum of 1.1µA during sleep @85°C, compared to the F version's 45µA. The astronomical difference probably implies the F version employs a low drop out voltage regulator to supply the MCU core with 3.6V (see the datasheets for the PIC 16F193X series for notes on the LDO).

No comments:

Post a Comment