Discharging the battery for the FSE clock

Post here first, or if you can't find a relevant section!
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Discharging the battery for the FSE clock

Post by ag123 »

if you use an soc in the stm32f4xx or g4xx series e.g. stm32f401/f411
the ADC can read VBAT internally
https://www.st.com/resource/en/referenc ... ronics.pdf
11.10 Battery charge monitoring
The VBATE bit in the ADC_CCR register is used to switch to the battery voltage. As the
VBAT voltage could be higher than VDDA, to ensure the correct operation of the ADC, the
VBAT pin is internally connected to a bridge divider.
When the VBATE is set, the bridge is automatically enabled to connect:
• VBAT/4 to the ADC1_IN18 input channel
Note: The VBAT and temperature sensor are connected to the same ADC internal channel
(ADC1_IN18). Only one conversion, either temperature sensor or VBAT, must be selected
at a time. When both conversion are enabled simultaneously, only the VBAT conversion is
performed.
This feature is not there in the stm32f103. But that stm32f4 has a different RTC, and different structure for the registers.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

@ag123: your knowledge is immense!

Is it possible to do it with Arduino IDE?
Until now I found some LL-examples (that's "low level" instead of HAL)?
I think, one have to know the right struct, fill the necessary members and call a kind of Init()-method?


I take a look inside RM0440 (Reference Manual STM32G4 series)
There is a chapter 21.4.32 VBAT supply monitoring with the warning:
To prevent any unwanted consumption on the battery, it is recommended to enable the bridge divider only when
needed, for ADC conversion.
From AN5093 at the end of chapter 2.1.3:
VBAT battery charging
When VDD is present, It is possible to charge the external battery on VBAT through an
internal resistance.
The VBAT charging is done either through a 5 kOhm resistor or through a 1.5 kOhm resistor
depending on the VBRS bit value in the PWR_CR4 register.
The battery charging is enabled by setting VBE bit in the PWR_CR4 register. It is
automatically disabled in VBAT mode.
There is no recommendation for a rechargeable battery.

There are 3 versions of rechargeable coin cells:
- LIR2032 seems to be something like a Lithium-ion chemistry with 3,7 V nominal voltage - that would damage the MCU!
- ML2032 from Maxell. Nominal voltage is 3,0 V and nominal discharge current 200 µA. Capacity is poor. Only 65 mAh (comparing to 230 mAh of a CR2032). No more information, if you need a CCCV charging or a simple resistor ...
- IFR2032 from Renata, similiar to LiFePO4 with 3,2 V and 40 mAh, but I can't find a datasheet.

Renzo Mischianti charge a ML2032 simply by connecting it to 3,3 V:
https://mischianti.org/wp-content/uploa ... m.jpg.webp
A Schottky diode 1N5817 is made for 20 V and at this voltage it can have a reverse current of 1 mA.
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

ag123 wrote: Sun Jul 14, 2024 6:23 am ...This feature is not there in the stm32f103. But that stm32f4 has a different RTC, and different structure for the registers.
I've seen that there are STM32F411-based boards https://fr.aliexpress.com/item/10050061 ... ry_from%3A. They seem to be pin-to-pin compatible with Blue Pill. They can also be programmed with an ST Link V2. Are there any incompatibilities?

Sincerely.

Pierre.
Last edited by ChPr on Sun Jul 14, 2024 11:39 am, edited 1 time in total.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

ChPr wrote: Sun Jul 14, 2024 9:45 am I've seen that there are STM32F411-based boards. They seem to be pin-to-pin compatible with Blue Pill. They can also be programmed with an ST Link V2. Are there any incompatibilities?
Is this a serious question?
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

STM32ardui wrote: Sun Jul 14, 2024 10:08 am ... Is this a serious question?
did I say something wrong?

NOTA : I forgot to show the link https://fr.aliexpress.com/item/10050061 ... ry_from%3A

Sincerely.

Pierre.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

STM32F103 and STM32F411 are two different chips.
They are also from different generations.
You can take a look into datasheets.

Of course every MCU has ports - even an old Arduino UNO.
Otherwise they would be more or less useless, if you can't switch something HIGH/LOW or can't read anything.
But it depends, what is behind a port:
- an ADC channel
- a DAC output
- a RX/TX pin
- a pin for I²C or SPI ...
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Discharging the battery for the FSE clock

Post by ag123 »

ChPr wrote: Sun Jul 14, 2024 9:45 am
ag123 wrote: Sun Jul 14, 2024 6:23 am ...This feature is not there in the stm32f103. But that stm32f4 has a different RTC, and different structure for the registers.
I've seen that there are STM32F411-based boards https://fr.aliexpress.com/item/10050061 ... ry_from%3A. They seem to be pin-to-pin compatible with Blue Pill. They can also be programmed with an ST Link V2. Are there any incompatibilities?

Sincerely.

Pierre.

the RTC is at least different (check the 2 relevant ref manuals), then between stm32f4xx (e.g. f401/f411) vs stm32f103 there are many more differences.
e.g. stm32f4xx has that 'ART accelerator' (on chip cache lines that is used in modern cpu L1 or L2 cache) and FPU. single precision floating point math (fpu vs calc using arm codes) is like 10-100x faster than stm32f103 depending on what is calculated. overall stm32f4xx is (much, qualifier: if your codes can be 'ART accelerated' i.e. is in cache, the wait states drop from like assume 3-5 wait states to *zero* wait states in cache) faster for the same hz

and stm32f4xx tend to bundle more sram and flash, something which i consider important esp for mcus.

but that actually some benchmarks is needed to put things in perspective
ILI9341 SPI LCD library for STM32duino
https://github.com/ag88/Adafruit_ILI934 ... nd-results
Adafruit benchmark
stm32f401ccu libmaple 1123052 u seconds
stm32f103c libmaple 1632651 u secs
about 30% faster, for the rest of stuff IO is the bottleneck and it won't be faster either way. (e.g. if you run SPI at a particular Mhz, then that'd be the speed)
the excellence performance in libmaple core is (unfortunately) due to DMA
it (SPI with DMA) gives this type of performance
https://www.youtube.com/watch?v=7Ey1U36YtY0
i think this is partly what inspire many to play with stm32(duino)
the videos used to go this way:
https://www.youtube.com/watch?v=5mDnKBNl9sY

for 'newbies' I'd tend to suggest simply go with stm32f401/f411 boards
- more sram (vs 20k in the stm32f103c8 bluepills)
- more flash (most f4xx tend to have more than 64k, some are generous as to give 512k e.g. ceu6)
- fast ART accelerator
- fast fpu
- better hardware in nearly every aspect vs stm32f103
it tend to give that 'no nonsense' experience, big fat clumsy binaries 'just works',
on 'small squeezy' mcus e.g. stm32f030f4p6 4k sram 16k flash, g030f6p6 8k sram 32k flash, c031f6p6 12k sram 32k flash, you fight for every byte of the binary size, and often the lack of sram in small squeezy mcus is neglected to be mentioned
(aliX vendors sell them like 'candies' often going for < $1 for every piece of raw sop20 mcu excluding shipping,
a trouble is that sop20 e.g. stm32g030f6p6
https://www.st.com/resource/en/datashee ... g030f6.pdf
https://www.aliexpress.com/w/wholesale- ... 0f6p6.html
is often 'too cute' to ignore lol :D
the thinking goes just get spo20 'adapter boards' and solder them and you have a 'development board' :D
https://www.aliexpress.com/w/wholesale- ... apter.html
that has its own thread here
viewtopic.php?t=1848
)
with enough sram and flash, one can even run Adafruit's circuit python or Micropython rather than code in straight c/c++
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

Thank you for all this information, which clarifies the difference between these two circuits.

However, what I retain for a "newby" like me, is that the 411 can replace a 103 with more power, more speed and more memory.

Sincerely.

Pierre.
ozcar
Posts: 176
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: Discharging the battery for the FSE clock

Post by ozcar »

ChPr wrote: Sun Jul 14, 2024 9:45 am
I've seen that there are STM32F411-based boards https://fr.aliexpress.com/item/10050061 ... ry_from%3A. They seem to be pin-to-pin compatible with Blue Pill. They can also be programmed with an ST Link V2. Are there any incompatibilities?
There are some differences in the pinouts of the various "pill" boards.

I replaced a F103 blue pill board with a F411 black pill in one of my projects, and I did have to make some changes due to different pins.

From what I remember, there was a power or ground pin difference, but also one reason for me making the change was to make use of 32-bit timer on the F411 and I had to shuffle the usage of the timers to do that, which also meant changing some pins.
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: Discharging the battery for the FSE clock

Post by GonzoG »

ChPr wrote: Sun Jul 14, 2024 9:45 am
I've seen that there are STM32F411-based boards ...
No, they are not compatible. There are differences: Reset pin, GND/5V pins.

As to capabilities, F4 is a different chip, it's Cortex-M4 and F1 is Cortex-M0. Faster (not only frequency) and more capable. More interfaces, timers, memory and needs less power (about 50% less according to datasheet). But different F4 chips have different interfaces. F4x1 do not have CAN bus like F103. Also RTC in F4 has capability in to store date (time is stored in unix format), where in F1 it's 24h time only.

Generally F4s are newer and better then F1s. BUT there are also L series: L0, L1, L4, L5 (low power MCUs and in low power run mode they need <1mA), G4 (mixed signals chips, with DSP accelerator).
Post Reply

Return to “General discussion”