cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S001J3 halt mode current is 4.5uA in datasheet, I get 1mA when tried

DBans.1569
Associate

1. Table 26 of STM8S001J3 page 49 of 85, shows current consumption in halt mode is 4.5uA typical, but when I put MCU in halt mode, i got current in 1mA range. Dont understand why?

2. I have broken small breakout board from stm8-so8-disco of STM8S001J3 so measuring its current only. Nothing else is connected on MCU. On Pin D6 an external 10K with pull up and 0.1uF decoupling capacitor is connected. Nothing else is on board,program once put by debugger and then it is disconnceted also. Please note its breakout board of STM8S001J3 from disco board not entire disco board, so no other component can consume current. On breakout board there are only three components: MCU, and two decoupling caps of vcap and vss.

3, Power supply is also very clean, its single cell lithium ion cell sitting at 3.7V around at the moment, no other noise source I see.

4. Below is code, dont understand what is consuming current so much? No switch toogling at the moment, switch toggle only when I press, currently measuring curent without any press also. Switch operation working correctly.

5. In code turned off all peripherals, put all pins in pull up or output low mode. Dont understand what is consuming current. Changed two boards also same result.

using IAR3.11.1 . Code put inside MCU is : Release, Optimization High speed.

6. 

#include "stm8s.h"

#ifdef _COSMIC_

#define ASM _asm

#endif

#ifdef _IAR_

#define ASM asm

#endif

/* This delay should be added just after reset to have access to SWIM pin

and to be able to reprogram the device after power on (otherwise the device

will be locked) */

#define STARTUP_SWIM_DELAY_5S \

{ \

ASM(" PUSHW X \n" \

" PUSH A \n" \

" LDW X, #0xFFFF \n" \

"loop1: LD A, #50 \n" \

\

"loop2: DEC A \n" \

" JRNE loop2 \n" \

\

" DECW X \n" \

" JRNE loop1 \n" \

\

" POP A \n" \

" POPW X " ); \

}

int main(void)

{

/* configure unbonded pins */

  GPIO_Init(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_2), GPIO_MODE_OUT_PP_LOW_SLOW);

  GPIO_Init(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7), GPIO_MODE_OUT_PP_LOW_SLOW);

  GPIO_Init(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7), GPIO_MODE_OUT_PP_LOW_SLOW);

  GPIO_Init(GPIOD, (GPIO_Pin_TypeDef)(GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_7), GPIO_MODE_OUT_PP_LOW_SLOW);

  GPIO_Init(GPIOE, (GPIO_Pin_TypeDef)(GPIO_PIN_5), GPIO_MODE_OUT_PP_LOW_SLOW);

  GPIO_Init(GPIOF, (GPIO_Pin_TypeDef)(GPIO_PIN_4), GPIO_MODE_OUT_PP_LOW_SLOW);   

  

/* delay for SWIM connection: ~5seconds */

  STARTUP_SWIM_DELAY_5S;  

  

  

/* configure all STM8S001 pins as input with pull up */

//  //GPIO_Init(GPIOA, GPIO_PIN_1, GPIO_MODE_IN_PU_IT); // pin 1

  GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_PU_IT); // pin 1

  

//  //GPIO_Init(GPIOA, GPIO_PIN_3, GPIO_MODE_OUT_OD_LOW_SLOW); // pin 1

   GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_OD_LOW_SLOW); // pin 6 (PB4 has no pull-up - configure it as output low)

  

   GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_OD_LOW_SLOW); // pin 6 (PB4 has no pull-up - configure it as output low)

  

//  //GPIO_Init(GPIOC, GPIO_PIN_3, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 7

//  //GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 7

   GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 7

  

//  //GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 8

//  //GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 8

//  //GPIO_Init(GPIOD, GPIO_PIN_1, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 8

  GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_OUT_PP_LOW_SLOW); // pin 8

  

/* disable peripherals clocks to decrease consumption */

  CLK->PCKENR1 = 0x00;

  CLK->PCKENR2 = 0x00;   

//configure D6 as input falling edge interrupt   

  __disable_interrupt();

  GPIOD->DDR &= ((u8_t)~REG8_BIT_6);

  GPIOD->CR1 |= (REG8_BIT_6);

  GPIOD->CR2 |= (REG8_BIT_6);   

  EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD, EXTI_SENSITIVITY_FALL_ONLY);

  __enable_interrupt();

  

   

/* control should not go out of main in any case */  

  while(1)

  {

    halt(); //wait for interrupt on D6

    

  /* run timer and do some tasks */

    CLK->PCKENR1 |= CLK_PCKENR1_TIM2;

    ENABLE_GENERAL_TIM_INT();

      

    //do_task

    

    DISABLE_GENERAL_TIM_INT();

    CLK->PCKENR1 &= ((u8_t)~CLK_PCKENR1_TIM2);

    

  }

  

} /* main ends here */

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
0 REPLIES 0