To set all free pins as analog via Arduino IDE

Post here all questions related to STM32 core if you can't find a relevant section!
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: To set all free pins as analog via Arduino IDE

Post by mebab »

I see the voltage across a 1 ohm resistor in series with my board (including STM32L476 without peripherals). A 3.3 volts power supply is used to power the system.
Measured by an oscilloscope, the minimum current (voltage across the resistor) is 6-7 mA.
Last edited by mebab on Thu May 27, 2021 8:33 pm, edited 1 time in total.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: To set all free pins as analog via Arduino IDE

Post by fpiSTM »

OK but this depends of your config.

L476_pwr.png
L476_pwr.png (71.14 KiB) Viewed 2368 times
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: To set all free pins as analog via Arduino IDE

Post by mebab »

Thanks
fpiSTM
My frequency is equal to 2 MHz and I don't have variable input voltage. My source voltage is 3.3 volts fixed. Then, I guess the only way is to disable some peripherals but I don't know how to do that in Arduino IDE.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: To set all free pins as analog via Arduino IDE

Post by ag123 »

mebab wrote: Thu May 27, 2021 3:09 pm Thanks
ag123
again for the useful link and comments!
Whatever I do with pins, clock frequency, etc. doesn't reduce the consumed power! I still have 6 mA (supplying 3.3 V with ST-Link) only for running STM32L476 in the full load situation!
It is hard for me to transfer whatever is needed from the following generated code in CubeIDE to Arduino code:

Code: Select all

  
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_I2C3_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();
  ....
  
I have included the contents of the SystemClock_Config in the Variant.cpp file. However, I cannot figure out how to deactivate peripherals in Arduino IDE. Would you mind please provide me a piece of Arduino code to disable for example I2C1 or SPI2?

Thanks again
'clocking the peripherals' isn't that difficult. what you need are, you need to review the reference manual for your soc under reset and clocks control *RCC". stm32duino turns on clocks for the common / popular ones so that 'newbies' won't be clueless of why things like 'gpio' didn't work. you would otherwise have to do that yourself if the core didn't turn on the clocks before hand.

you did not mention your soc so here is one for stm32f4xx. review the registers for peripheral clock enable.
https://www.st.com/resource/en/referenc ... ronics.pdf

then you can review the codes in SystemClock_Config() andn the MX_XXX_Init() codes to see how it is done. Instead of changing the codes there.
you could call functions to disable the pheriperial clocks in setup(). In that way you won't need to change the core codes directly. But if you insist, you could edit your local copy.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: To set all free pins as analog via Arduino IDE

Post by mebab »

ag123: 'clocking the peripherals' isn't that difficult. what you need are ...
fpiSTM: OK but this depends on your config.
Thanks a lot for all your helpful comments. Finally, I could turn off the unused clocks and got great results!
I couldn't find the 'Mark as answer' item to highlight your comments.
Post Reply

Return to “General discussion”