MC9S08QE32CLC--Lpr MODE (FBELP) & STOP3 mode supply current

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08QE32CLC--Lpr MODE (FBELP) & STOP3 mode supply current

2,048 Views
mfv
Contributor I

Hi,

I'm working with MC9S08QE32CLC. The application it's battery powered and the power consumtion it's a critical point. So I'm trying to work in Low Power Run Mode (FBELP-external oscillator=32.678KHz) and STOP3 mode. The problem it's that I cannot achieve the supply current detailed on datasheet for these modes of operation. My supply current of uControler (out of BDM not active) is about 300uA increasing or decreasing in function of the temperature. I'm new in Freescale and it's possible I'm making some big mistake. Down there is part of the firmware used in assembler. On the board there is no other electronics, only 3Vcc power regulator. Many thanks in advance for your help! 

 

    LDA #%01100000          ; Watchdog disable, Stop Mode enabled, NO Background Pin, No Reset Pin
            STA SOPT1
            
            LDA #$00                  ; Pheriperal clocks disabled
            STA SCGC1
            STA SCGC2
                        
            LDA #%11111110                ; All ports outputs except PTA0 (input--Switch)
            STA PTADD
            LDA #$ff
            STA PTBDD
            STA PTCDD
            STA PTDDD
            LDA #$00
            STA PTAD
            STA PTBD
            STA PTCD
            STA PTDD
            
                       
            ; ICS mode----> FBE
            LDA #%00000100          ;External clock---->Oscillator (32.768KHz)
            STA ICSC2
            LDA #%10000000          ;External clock --->Bus clock
            STA ICSC1
OSCINITIAL0:                                            ;Wait for external oscillator initialization
            BRCLR ICSSC_OSCINIT,ICSSC,OSCINITIAL0
OSCINITIAL1:
            BRSET ICSSC_IREFST,ICSSC,OSCINITIAL1
OSCINITIAL2:
            BRCLR ICSSC_CLKST1,ICSSC,OSCINITIAL2
OSCINITIAL3:
            BRSET ICSSC_CLKST0,ICSSC,OSCINITIAL3
                        
                      
            ; ICS mode----> FBELP
            LDA #%00001100      ; FLL DISABLED
            STA ICSC2
            
                        
            ; Low Power Run Mode
            LDA SPMSC1
            ORA #%01000000   ;RESET FLAG DE LVD,LVDF=1--->NO RESET, LVD OFF  (also OFF in stop mode)
            AND #%01000000
            STA SPMSC1
            
            
            LDA #%01000000
            STA SPMSC3
            
            LDA #%01011000
            AND SPMSC2
            ORA #%00000110  ;STOP3 configuration
            STA SPMSC2
            ORA #%10000000   ;Low Power run mode
            STA SPMSC2

            STOP                   ;STOP3 mode

 

 

Appreciate,

mfv

Labels (1)
0 Kudos
Reply
7 Replies

679 Views
perri
Contributor I

Hello

Same problem here. I am using a mc9s08qe8, and when I enter low power mode, and been SPMSC2_LPRS set, my power consumption just with the microcontroller and 32Khz crystal goes up to 1mA @2V, 1,1ma@3V. After trying a lot of codes I've used the functions in the demoqe08 to enter low power run mode. Most perhiperals are clock gated, so I am lost.

 

//CODE/////////////////////////////////////////////////

  // enable STOP, BDM, RST and RSTO
  SOPT1 = SOPT1_STOPE_MASK|SOPT1_BKGDPE_MASK;  
 
  // Disable LVD
  SPMSC1 = 0x00;
 
  // Enable (but don't select) stop2 mode
  SPMSC2_PPDE = 1;       //PPDE is write once, so set during MCU initialization
 
  //ICS_Config(0x00,0x07,NVICSTRM,0x20);
 
  /*  System clock initialization */
  /* ICSC1: CLKS=2,RDIV=0,IREFS=0,IRCLKEN=0,IREFSTEN=0 */
  ICSC1 = 0x80;                        /* Initialization of the ICS control register 1 */
  /* ICSC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=1,ERCLKEN=0,EREFSTEN=0 */
  ICSC2 = 0x04;                        /* Initialization of the ICS control register 2 */
  while(!ICSSC_OSCINIT) {              /* Wait until the initialization of the external crystal oscillator is completed */
  }
  /* ICSSC: DRST_DRS=0,DMX32=0 */
  ICSSC &= (unsigned char)~0xE0;       /* Initialization of the ICS status and control */
  while((ICSSC & 0xC0) != 0x00) {      /* Wait until the FLL switches to Low range DCO mode */
  }
 
  //WaitNms(1);  
  /* SCGC1: TPM2=0,TPM1=0,ADC=0,IIC=0,SCI=0 */
  SCGC1 &= (unsigned char)~0x75;                     
  /* SCGC2: DBG=0,FLS=0,IRQ=0,KBI=0,ACMP=0,RTC=0,SPI=0 */
  SCGC2 &= (unsigned char)~0xFD;       

  ICS_Config(0x80,0x0F,NVICSTRM,0x20);
  WaitNms(1);
  SPMSC2_LPR = 1;                             // Enter LPRun Mode

 

//////////////////////////////////////////////////////

 

////////////////////////////////////////

#define IREFS_INTERNAL     0x04

void ICS_Config(unsigned char CTL1, unsigned char CTL2,byte TrimValue, byte CTL3)
{
 if(CTL1 & IREFS_INTERNAL)
  {
   /* internal clock reference is */
  ICSC1  = CTL1;      /* init ISC control register 1 */
  ICSC2  = CTL2;      /* init ISC control register 2 */  
  ICSTRM = (unsigned char)TrimValue;           
  ICSSC  = CTL3;      /* init ISC control register 3 */
 
    if(ICSC1_CLKS == 0b01){
      /* FBI Mode wait for CLKST */
      while (ICSSC_CLKST != ICSC1_CLKS);
    }
    else {
      /* FEI Mode wait for CLKST and DRST */
      while (ICSSC_CLKST != ICSC1_CLKS);
      while ((ICSSC&ICSSC_DRST_DRS_MASK) != (CTL3&ICSSC_DRST_DRS_MASK) );   
    }
  }
 else
  {
    ICSC2           = CTL2;      /* init ISC control register 2 */  
    ICSC1           = CTL1;      /* init ISC control register 1 */
    ICSSC           = CTL3;
    /* wait for CLKST and OSCINIT */
    while (ICSSC_CLKST != ICSC1_CLKS);
    while (!ICSSC_OSCINIT);
  }
}

/////////////////////////////////////////////////////////////////////////

 

 

Any ideas or code would be greatly apreciated.

 

Thanks in advance to anyone who can help.

 

My code:

 

 

0 Kudos
Reply

679 Views
mfv
Contributor I

Hi perri,

 

In my case the problem was the non-blonded pins on port D and E: the uC package is 32-pin LQFP and for this package the port D has not implemented pins from 4 to 7. Try to configure this pins as output with low data value. Following there is the code in assembler. The same for full Port E. By default this all ports are inputs.

 

Also take general care with ports configuration and disable background mode (port A-4)

 

            LDA #%00001111          ;Port D non-blonded pins  low data
            AND PTDD
            STA PTDD
            LDA #%11110000          ;Port D non-blonded pins ouput
            ORA PTDDD
            STA PTDDD
            CLRA                    ;Port E low data
            STA PTED                ;Port E output
            LDA #$FF
            STA PTEDD

 

I hope this help you!!

 

0 Kudos
Reply

679 Views
peg
Senior Contributor IV

Hello,

 

While I have no direct experience with trying to reduce power consumption under STOP mode, it seems to me that this is the biggest culprit. Many reduced memory capacity or reduced package size versions within the same family (e.g. QE) have unbonded pins on the die. That is everything exists for that pin inside the device, only the actual pin is missing. Most of these will default to being inputs with nothing connected. These pins will consume excess current in this state. They should be configured as outputs and driven to the low state.

The datasheets do not make it very clear how to find these unbonded pins. The only real way to know is that they have control bits in the registers for them. i.e. data direction control bits, but the pin does not exist.

0 Kudos
Reply

679 Views
bigmac
Specialist III

Hello,

 

For devices that have unbonded I/O for reduced size packages, in many instances the main block diagram, occurring very early in the datasheet, will specifically indicate the I/O that will become unavailable, but must still be initialised.  An alternative to setting as output would be to enable the internal pullup.

 

Regards,

Mac

 

0 Kudos
Reply

679 Views
peg
Senior Contributor IV

IIRC others have found that setting unused pins to output and setting low uses less current than a pulled up input. It might only be a little bit but I can see no other reasons to go one way or the other.

0 Kudos
Reply

679 Views
KerryMac
Contributor III

Certainly setting all unused and unbonded pins to Output is a "must do" to avoid floating Inputs, but I have ran into the LC36 asserting IRQ while entering any STOP mode. Plus I seem to remember that the PE BDM was handling the code in a different fashion than if the target was stand alone. That added to my identifying what was happening, so I simply posted that to this thread in case it would help.

 

KM

 

An aside to Peg - Thanks a ton for your code on EEPROM emulation for storing data to FLASH. That saved a bunch of my time, and it worked very well!

0 Kudos
Reply

679 Views
KerryMac
Contributor III

Greetings,

 

You may want to review your IRQ setup. Some S08s assert IRQ active low, regardless of you settings, any time STOP is invoked. This could be triggering an IRQ interrupt and moving you out of STOP.

 

Hope this helps,

KM

0 Kudos
Reply