You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: targets/TARGET_STM/README.md
+17-25Lines changed: 17 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -383,14 +383,11 @@ Sometimes, pin is explicitly removed by default to avoid issues (but you can unc
383
383
384
384
#### System clock
385
385
386
-
System Core Clock is based on an high-speed clock.
387
-
388
-
- the HSI is the high-speed internal (MCU) clock with low accuracy
389
-
- the HSE is the high-speed external clock with higher accuray
386
+
System Core Clock is based on the high-speed clock, which is selected by the `target.clock_source` option.
390
387
391
388
For each target, a default choice has been made in the "clock_source" config settings in the targets.json file.
392
389
393
-
For main targets, it is something like:
390
+
By default, it is set to something like:
394
391
395
392
```
396
393
"clock_source": {
@@ -401,33 +398,28 @@ Meaning that:
401
398
- PLL with the external HSE clock is first configured
402
399
- if it fails, PLL with HSI is then configured
403
400
401
+
The specific choice of oscillator for your custom board is outside the scope of this README. However, in general, using a crystal for the clock will provide good accuracy, but uses a bit more power and requires an external component. Additionally, crystals can require careful design and tuning of the circuit board for best reliability and accuracy. To make the PCB simpler, a logic level oscillator can be used instead, though this is slightly more expensive.
404
402
405
-
#### Low power clock
403
+
If you wish to omit a high speed oscillator, then all STM32 parts can run from their internal oscillators (HSI). However, the clock accuracy of this oscillator is limited -- it can be as bad as +-10% over the full temperature range! So, if you are trying to do anything that relies on accurate clock speed, like USB, then you might run into trouble. To solve that issue, some STM32 parts (L4, L5, U5) provide an MSI oscillator. This works like the HSI oscillator, but trims itself using the 32kHz LSE crystal to stay at an accurate frequency. So, if you want USB but would prefer to have a 32kHz crystal than a MHz crystal, the MSI may be for you.
406
404
407
-
Low power ticker and RTC are based on an low-speed clock.
405
+
The options for the `target.clock_source` option include:
408
406
409
-
- the LSI is the low-speed internal clock with low accuracy
410
-
- the LSE is the low-speed external clock connected to 32.768 kHz quartz crystal
407
+
-`USE_PLL_HSE` - Use the High Speed External clock, with a crystal attached. The frequency expected for the crystal depends on the target, check the value of the `HSE_VALUE` define.
408
+
-`USE_PLL_HSE_EXTC` - Same as above but expect a logic level square wave instead of a crystal. Nucleo boards mostly use this configuration because the ST-Link outputs a clock signal for the MCU to use.
409
+
-`USE_PLL_HSI` - Use the High Speed Internal clock. No external parts needed.
410
+
-`USE_PLL_MSI` - Use the MSI oscillator (L4/L5/U5 only). If a 32kHz crystal is present, then this will be more accurate than HSI.
411
411
412
-
In targets.json file, it is supposed that a LSE is provided in the board
412
+
#### Low power clock
413
413
414
-
```
415
-
"config": {
416
-
"lse_available": {
417
-
"value": "1"
418
-
```
414
+
The low power ticker and the RTC are based on a low-speed (32kHz) clock. This clock source is designed to stay on even when most of the CPU is in sleep mode.
419
415
420
-
You can change this in you local mbed_app.json:
421
-
```
422
-
{
423
-
"target_overrides":
424
-
{
425
-
"XXXX": {
426
-
"target.lse_available": "0"
427
-
}
428
-
}
429
-
}
416
+
By default, Mbed expects a 32kHz crystal to be present on the LSE (Low Speed External) oscillator pins. If your board does not have such a crystal, you should set the `target.lse_available` option to 0 in mbed_app.json. This will switch Mbed to use the internal oscillator instead. Just be aware that the timing accuracy of the RTC, as well as of some Mbed RTOS operations like thread sleeps and LowPowerTimer, will be reduced to +-10%.
417
+
418
+
Note that, by default, Mbed uses low drive strength for the LSE crystal. This can be a problem on custom boards, where the LSE might need a bit more oomph to get started. If your LSE is not starting, or it's taking a long time to start, try adding
to your mbed_app.json and see if that fixes the issue. If so, you might need to revisit your board design or just keep the LSE drive at a higher setting. Be careful because this setting may require a complete power cycle (not just a reset!) of the target to take effect.
Copy file name to clipboardExpand all lines: targets/targets.json5
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1219,6 +1219,10 @@
1219
1219
"help": "Define if a Low Speed External xtal (LSE) is available on the board (0 = No, 1 = Yes). If Yes, the LSE will be used to clock the RTC, LPUART, ... otherwise the Low Speed Internal clock (LSI) will be used",
1220
1220
"value": "1"
1221
1221
},
1222
+
"lse_bypass": {
1223
+
"help": "Change to 1 to use a logic level oscillator (not a crystal) on 32k LSE",
1224
+
"value": "0"
1225
+
},
1222
1226
"rtc_clock_source": {
1223
1227
"help": "Define the RTC clock source. USE_RTC_CLK_LSE_OR_LSI, USE_RTC_CLK_LSI, USE_RTC_CLK_HSE. LPTICKER is not available for HSE and should be removed from the target configuration.",
1224
1228
"value": "USE_RTC_CLK_LSE_OR_LSI"
@@ -3626,10 +3630,6 @@
3626
3630
"value": "25000000",
3627
3631
"macro_name": "HSE_VALUE"
3628
3632
},
3629
-
"lse_bypass": {
3630
-
"help": "1 to use an oscillator (not a crystal) on 32k LSE",
3631
-
"value": "1"
3632
-
},
3633
3633
"usb_speed": {
3634
3634
"help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
0 commit comments