cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411RET6, current consumption varies depending on code size

florin
Associate
Posted on December 23, 2015 at 13:07

Hello,

I started to develop a device with STM32F411RET6, working on battery.

I saw, that the current consumption, varies with 0.8mA depending of code size or code alignment in MCU flash.

Does anyone know something about this?

I made a simple test:

MCU, 8MHz, HSI divided by 2, prefetch and cache  enabled.

I work in MikroPascal, Mikroelektronika.

code, first test, current 3.5mA

begin

  while true do     // 3.5 mA

    begin

//      nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

    end;

end.

ASM:

;Spera.mpas, 102 ::                 begin

0x05DC        0xF7FFFE4C  BL        632

0x05E0        0xF7FFFE22  BL        552

0x05E4        0xF000F812  BL        1548

0x05E8        0xF7FFFE34  BL        596

;Spera.mpas, 103 ::                 while true do

L__main2:

;Spera.mpas, 106 ::                 nop;nop;

0x05EC        0xBF00    NOP

0x05EE        0xBF00    NOP

;Spera.mpas, 107 ::                 nop;nop;

0x05F0        0xBF00    NOP

0x05F2        0xBF00    NOP

;Spera.mpas, 108 ::                 nop;nop;

0x05F4        0xBF00    NOP

0x05F6        0xBF00    NOP

;Spera.mpas, 109 ::                 nop;nop;

0x05F8        0xBF00    NOP

0x05FA        0xBF00    NOP

;Spera.mpas, 110 ::                 nop;nop;

0x05FC        0xBF00    NOP

0x05FE        0xBF00    NOP

;Spera.mpas, 111 ::                 nop;nop;

0x0600        0xBF00    NOP

0x0602        0xBF00    NOP

;Spera.mpas, 112 ::                 nop;nop;

0x0604        0xBF00    NOP

0x0606        0xBF00    NOP

;Spera.mpas, 113 ::                 end;

0x0608        0xE7F0    B        L__main2

;Spera.mpas, 114 ::                 end.

L_end_main:

L__main_end_loop:

0x060A        0xE7FE    B        L__main_end_loop

; end of _main

code, second test, 4.2mA

begin

  while true do     // 4.2 mA

    begin

      nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

      nop;nop;

    end;

end.

ASM:

_main:

;Spera.mpas, 102 ::                 begin

0x05DC        0xF7FFFE4C  BL        632

0x05E0        0xF7FFFE22  BL        552

0x05E4        0xF000F814  BL        1552

0x05E8        0xF7FFFE34  BL        596

;Spera.mpas, 103 ::                 while true do     // 4.2 mA

L__main2:

;Spera.mpas, 105 ::                 nop;

0x05EC        0xBF00    NOP

;Spera.mpas, 106 ::                 nop;nop;

0x05EE        0xBF00    NOP

0x05F0        0xBF00    NOP

;Spera.mpas, 107 ::                 nop;nop;

0x05F2        0xBF00    NOP

0x05F4        0xBF00    NOP

;Spera.mpas, 108 ::                 nop;nop;

0x05F6        0xBF00    NOP

0x05F8        0xBF00    NOP

;Spera.mpas, 109 ::                 nop;nop;

0x05FA        0xBF00    NOP

0x05FC        0xBF00    NOP

;Spera.mpas, 110 ::                 nop;nop;

0x05FE        0xBF00    NOP

0x0600        0xBF00    NOP

;Spera.mpas, 111 ::                 nop;nop;

0x0602        0xBF00    NOP

0x0604        0xBF00    NOP

;Spera.mpas, 112 ::                 nop;nop;

0x0606        0xBF00    NOP

0x0608        0xBF00    NOP

;Spera.mpas, 113 ::                 end;

0x060A        0xE7EF    B        L__main2

;Spera.mpas, 114 ::                 end.

L_end_main:

L__main_end_loop:

0x060C        0xE7FE    B        L__main_end_loop

Thanks in advance.

Best regards,

Florin.

3 REPLIES 3
Posted on December 23, 2015 at 13:45

The flash lines are quite wide, do you see the same variability if you run from SRAM?

Do you configure the flash, wait states, and prefetch before running this code?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
florin
Associate
Posted on December 23, 2015 at 21:30

Thanks for reply.

I investigate more and seems to be a problem with BRANCH (B) instruction.

If instruction are in sector0, depending of the instruction address (position on flash), the current consumption will grow...

I moved all the code, to start from sector1 and problem disappear...

Maybe ST team can investigate more.

Thanks. 

Posted on December 24, 2015 at 01:43

Maybe ST team can investigate more.

For that kind of thing to happen you'll have to provide significantly more complete test cases rather expect them to recreate your exact conditions.

Understand this is a User Forum, ST does not heavily participate here, so you might do better discussing your issue directly with an FAE.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..