File tree Expand file tree Collapse file tree 5 files changed +82
-0
lines changed
samples/boards/stm32/backup_sram Expand file tree Collapse file tree 5 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ cmake_minimum_required (VERSION 3.13.1)
4+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
5+ project (stm32_backup_sram)
6+
7+ FILE (GLOB app_sources src/*.c)
8+ target_sources (app PRIVATE ${app_sources} )
Original file line number Diff line number Diff line change 1+ .. _stm32_backup_sram :
2+
3+ STM32 Backup SRAM
4+ #################
5+
6+ Overview
7+ ********
8+
9+ Multiple STM32 microcontrollers have a small backup SRAM that can be used as a
10+ NVM when VBAT pin is supplied with a voltage source, e.g. a coin button cell.
11+
12+ This example shows how to define a variable on the Backup SRAM. Each time the
13+ application runs the current value is displayed and then incremented by one. If
14+ VBAT is preserved, the incremented value will be shown on the next power-cycle.
15+
16+ .. note ::
17+
18+ On most boards VBAT is typically connected to VDD thanks to a jumper.
19+ To excercise this sample with an independent VBAT source, you will need to
20+ remove the jumper.
21+
22+ Building and Running
23+ ********************
24+
25+ In order to run this sample, make sure to enable ``backup_sram `` node in your
26+ board DT file.
27+
28+ .. zephyr-app-commands ::
29+ :zephyr-app: samples/memc/stm32_backup_sram
30+ :board: nucleo_h743zi
31+ :goals: build
32+ :compact:
33+
34+ Sample Output
35+ =============
36+
37+ .. code-block :: console
38+
39+ Current value in backup SRAM: 11
40+ Next reported value should be: 12
41+ Keep VBAT power source and reset the board now!
Original file line number Diff line number Diff line change 1+ CONFIG_STM32_BACKUP_SRAM=y
Original file line number Diff line number Diff line change 1+ sample :
2+ description : Usage of backup SRAM on STM32
3+ name : stm32_backup_sram
4+ tests :
5+ sample.boards.stm32.backup_sram :
6+ depends_on : backup_sram
7+ build_only : true
8+ filter : dt_compat_enabled("st,stm32-backup-sram")
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2021 Teslabs Engineering S.L.
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #include <zephyr.h>
8+ #include <sys/printk.h>
9+
10+ /** Value stored in backup SRAM. */
11+ __stm32_backup_sram_section uint32_t backup_value ;
12+
13+ void main (void )
14+ {
15+ printk ("Current value in backup SRAM: %d\n" , backup_value );
16+
17+ backup_value ++ ;
18+ #if __DCACHE_PRESENT
19+ SCB_CleanDCache_by_Addr (& backup_value , sizeof (backup_value ));
20+ #endif
21+
22+ printk ("Next reported value should be: %d\n" , backup_value );
23+ printk ("Keep VBAT power source and reset the board now!\n" );
24+ }
You can’t perform that action at this time.
0 commit comments