Difference between revisions of "Stm32f100 notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
m
m
Line 1: Line 1:
 +
 +
[[LPCXpresso|LPCXpresso 1114/1314 notes here]]
  
 
== Overview ==
 
== Overview ==

Revision as of 14:57, 15 May 2018

LPCXpresso 1114/1314 notes here

Overview

This article to hold notes on early works with STMicro's STM32F100VL Discovery Board. We're using arm-none-eabi-gcc and assember versions:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ arm-none-eabi-as --version
GNU assembler (2.25-5+5+b1) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `arm-none-eabi'.


^ STM32F microcontroller and dev board

This section of this LPCXpresso article is not very related to LPCXpresso but here to describe tools for compiling for, programming and debugging ST32F type processors and development boards. As of 2018-04-23 have on hand STMicro's development board model number STM32F1, also known as STM32FVLDISCOVERY. Overview page for this board at STMicro is:

The processor used in this dev board is an STM32F100 family part, described in the following PDF, and interestingly there appears to be no mention of 'fuse' or 'fuse bits' in this document:


References for reading and writing flash memory and other memory types on this board include the following pages:


- 2018-04-26 Thursday -


- STEP - Searching for tool chain components which provide gcc-arm-none-eabi compiler and related linking and library tools:

$ dpkg -c /var/cache/apt/archives/gcc-arm-none-eabi_4.8.4-1+11-1_i386.deb | grep gcc$
-rwxr-xr-x root/root    711032 2015-03-14 10:50 ./usr/bin/arm-none-eabi-gcc
hrwxr-xr-x root/root         0 2015-03-14 10:50 ./usr/bin/arm-none-eabi-gcc-4.8 link to ./usr/bin/arm-none-eabi-gcc

$


- STEP - building Texane's stlink programming utility for ST32F and related target processors:

Looks like there are a couple of extra steps to take to build developer or dev team Texane's stlink project. These steps include installing `cmake`, and then on Debian and Ubuntu systems invoking stlink's makefile as follows:

$ make clean && make release


- STEP - Noting memory map of the ST32F100xB family microcontrollers


- STEP - JTAG versus SWD (Serial Wire Debug)


- ASIDE - RCC stands for . . .

RCC in ST32F micro context appears to stand for Reset and Clock Control. See https://www.slideshare.net/GauravVerma3/programming-the-arm-cortex


With STM_COMMON=/opt/lib/STM32F4-Discovery_FW_V1.1.0 we find the following STM32F10xxx related library files . . . but having trouble finding file stm32f10x.h:

$ ls $STM_COMMON/Utilities/STM32F4-Discovery
MCD-ST Image SW License Agreement 19Jul2011 v0.1.pdf  stm32f4_discovery.c              stm32f4_discovery_audio_codec.h
Release_Notes.html                                    stm32f4_discovery.h              stm32f4_discovery_lis302dl.c
pdm_filter.h                                          stm32f4_discovery_audio_codec.c  stm32f4_discovery_lis302dl.h

$ ls $STM_COMMON/Libraries/CMSIS/Include
arm_common_tables.h  arm_math.h  core_cm0.h  core_cm3.h  core_cm4.h  core_cm4_simd.h  core_cmFunc.h  core_cmInstr.h

$ ls $STM_COMMON/Libraries/CMSIS/ST/STM32F4xx/Include
stm32f4xx.h  system_stm32f4xx.h

$ ls $STM_COMMON/Libraries/STM32F4xx_StdPeriph_Driver/inc
misc.h           stm32f4xx_cryp.h    stm32f4xx_dma.h    stm32f4xx_gpio.h  stm32f4xx_pwr.h  stm32f4xx_sdio.h    stm32f4xx_usart.h
stm32f4xx_adc.h  stm32f4xx_dac.h     stm32f4xx_exti.h   stm32f4xx_hash.h  stm32f4xx_rcc.h  stm32f4xx_spi.h     stm32f4xx_wwdg.h
stm32f4xx_can.h  stm32f4xx_dbgmcu.h  stm32f4xx_flash.h  stm32f4xx_i2c.h   stm32f4xx_rng.h  stm32f4xx_syscfg.h
stm32f4xx_crc.h  stm32f4xx_dcmi.h    stm32f4xx_fsmc.h   stm32f4xx_iwdg.h  stm32f4xx_rtc.h  stm32f4xx_tim.h
veris@alta-spare-6:~/docs/co2-pep/SCD30/Source$


^ Demo Firmwares from AN3268 Standard Peripherals Library

- 2018-05-03 Thursday -

Ted working to compile, program part and run STMicro's RCC example firmware project, targeted to the STM32F100 Discovery Value Line board. Working on a Linux platform with GCC toolchain. Using professor Geoffry Brown's STM32 project template as for the project makefile or project recipe basis.

Today's goal is to build and run STM32 library example named 'RCC', locally installed in /opt/lib/an3268/stm32vldiscovery_package/Project/Examples/RCC. Having trouble with the linker not finding where built library files, likely archive or shared object files are located . . .

main.o: In function `main':
  .
  .
  .
/home/veris/projects/stm32f/RCC/main.c:72: undefined reference to `RCC_GetClocksFreq'
/home/veris/projects/stm32f/RCC/main.c:75: undefined reference to `STM32vldiscovery_LEDInit'
/home/veris/projects/stm32f/RCC/main.c:76: undefined reference to `STM32vldiscovery_LEDInit'
/home/veris/projects/stm32f/RCC/main.c:79: undefined reference to `RCC_APB2PeriphClockCmd'
/home/veris/projects/stm32f/RCC/main.c:84: undefined reference to `GPIO_Init'
/home/veris/projects/stm32f/RCC/main.c:85: undefined reference to `RCC_MCOConfig'
/home/veris/projects/stm32f/RCC/main.c:90: undefined reference to `STM32vldiscovery_LEDToggle'
/home/veris/projects/stm32f/RCC/main.c:95: undefined reference to `STM32vldiscovery_LEDToggle'
stm32f10x_it.o: In function `RCC_IRQHandler':
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:155: undefined reference to `RCC_GetITStatus'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:158: undefined reference to `RCC_ClearITPendingBit'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:161: undefined reference to `RCC_GetFlagStatus'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:169: undefined reference to `RCC_PLLCmd'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:175: undefined reference to `RCC_GetITStatus'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:178: undefined reference to `RCC_ClearITPendingBit'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:181: undefined reference to `RCC_GetFlagStatus'
/home/veris/projects/stm32f/RCC/stm32f10x_it.c:184: undefined reference to `RCC_SYSCLKConfig'
collect2: error: ld returned 1 exit status
../Makefile.common:70: recipe for target 'RCC.elf' failed
make: *** [RCC.elf] Error 1

$


LED toggling code is located in an AN3268 source file, full local path /opt/lib/an3268/stm32vldiscovery_package/Utilities/STM32vldiscovery.c . . .

$ grep -n -r STM32vldiscovery_LEDToggle ./*
         
./Project/Examples/STANDBY Mode/stm32f10x_it.c:139:  STM32vldiscovery_LEDToggle(LED3);
./Project/Examples/IWDG/stm32f10x_it.c:141:  STM32vldiscovery_LEDToggle(LED4);
./Project/Examples/WWDG/stm32f10x_it.c:153:  STM32vldiscovery_LEDToggle(LED4);
./Project/Examples/EXTI/stm32f10x_it.c:157:     STM32vldiscovery_LEDToggle(LED3);
./Project/Examples/RCC/main.c:90:    STM32vldiscovery_LEDToggle(LED3);
./Project/Examples/RCC/main.c:95:    STM32vldiscovery_LEDToggle(LED4);
./Project/Examples/SysTick/main.c:71:    STM32vldiscovery_LEDToggle(LED3);
./Project/Examples/SysTick/main.c:77:   STM32vldiscovery_LEDToggle(LED4);
./Utilities/STM32vldiscovery.c:142:void STM32vldiscovery_LEDToggle(Led_TypeDef Led)
./Utilities/STM32vldiscovery.h:119:void STM32vldiscovery_LEDToggle(Led_TypeDef Led);


On the Discovery board LED3 is defined as pin . . .

/opt/lib/an3268/stm32vldiscovery_package$ grep -n -r LED3 ./*

./Utilities/STM32vldiscovery.h:53:  LED3 = 0,
./Utilities/STM32vldiscovery.h:82:#define LED3_PIN                         GPIO_Pin_9  
./Utilities/STM32vldiscovery.h:83:#define LED3_GPIO_PORT                   GPIOC
./Utilities/STM32vldiscovery.h:84:#define LED3_GPIO_CLK                    RCC_APB2Periph_GPIOC



^ STM32F10x device types LD, MD, HD and Value Line

In the file /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h there is a good explanation of the abbreviations LD, MD, HD attached to some STM32F10x microcontroller names:

  57 /*  Tip: To avoid modifying this file each time you need to switch between these
  58         devices, you can define the device in your toolchain compiler preprocessor.
  59 
  60  - Low density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
  61    where the Flash memory density ranges between 16 and 32 Kbytes.
  62  - Low-density value line devices are STM32F100xx microcontrollers where the Flash
  63    memory density ranges between 16 and 32 Kbytes.
  64  - Medium density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
  65    where the Flash memory density ranges between 64 and 128 Kbytes.
  66  - Medium-density value line devices are STM32F100xx microcontrollers where the
  67    Flash memory density ranges between 64 and 128 Kbytes.
  68  - High density devices are STM32F101xx and STM32F103xx microcontrollers where
  69    the Flash memory density ranges between 256 and 512 Kbytes.
  70  - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
  71    the Flash memory density ranges between 512 and 1024 Kbytes.
  72  - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
  73   */

This same header file has some pound includes which may be worth noting, about four hundred lines into this file:

 412 #include "core_cm3.h"
 413 #include "system_stm32f10x.h"
 414 #include <stdint.h>

Even with the value line controller there are just over nine hundred register definitions in STM's standard peripherals library main header file for the STM32F100RB part:

   $ /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x$ grep -n 'Bit definition for' ./*.h | grep register | wc
    902    6320   91086


Looks like there are fourteen GPIO registers defined . . .

$ grep -n 'Bit definition for' ./*.h | grep GPIO     
./STM32f10x.h:2209:/*******************  Bit definition for GPIO_CRL register  *******************/
./STM32f10x.h:2278:/*******************  Bit definition for GPIO_CRH register  *******************/
./STM32f10x.h:2347:/*!<******************  Bit definition for GPIO_IDR register  *******************/
./STM32f10x.h:2365:/*******************  Bit definition for GPIO_ODR register  *******************/
./STM32f10x.h:2383:/******************  Bit definition for GPIO_BSRR register  *******************/
./STM32f10x.h:2418:/*******************  Bit definition for GPIO_BRR register  *******************/
./STM32f10x.h:2436:/******************  Bit definition for GPIO_LCKR register  *******************/
./stm32f10x.h:2209:/*******************  Bit definition for GPIO_CRL register  *******************/
./stm32f10x.h:2278:/*******************  Bit definition for GPIO_CRH register  *******************/
./stm32f10x.h:2347:/*!<******************  Bit definition for GPIO_IDR register  *******************/
./stm32f10x.h:2365:/*******************  Bit definition for GPIO_ODR register  *******************/
./stm32f10x.h:2383:/******************  Bit definition for GPIO_BSRR register  *******************/
./stm32f10x.h:2418:/*******************  Bit definition for GPIO_BRR register  *******************/
./stm32f10x.h:2436:/******************  Bit definition for GPIO_LCKR register  *******************/


As we saw in compiler directive error messages a few days ago, a particular STM32F microcontroller part number needs be called out in order for conditional stuff in header files, including System Core Clock variable to be declared at compile time. Here are references to variable SystemCoreClock:

./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h:52:extern uint32_t SystemCoreClock;          /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h:79:extern void SystemCoreClockUpdate(void);
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:112:  uint32_t SystemCoreClock         = SYSCLK_FREQ_HSE;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:114:  uint32_t SystemCoreClock         = SYSCLK_FREQ_24MHz;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:116:  uint32_t SystemCoreClock         = SYSCLK_FREQ_36MHz;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:118:  uint32_t SystemCoreClock         = SYSCLK_FREQ_48MHz;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:120:  uint32_t SystemCoreClock         = SYSCLK_FREQ_56MHz;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:122:  uint32_t SystemCoreClock         = SYSCLK_FREQ_72MHz;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:124:  uint32_t SystemCoreClock         = HSI_Value;        /*!< System Clock Frequency (Core Clock) */
./CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c:167:  *         SystemCoreClock variable.



^ The dot S File

Somehow we need to include the 'dot s' file /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/arm/startup_stm32f10x_md_vl.s in our instance of STMicro's SysTick demo project. This file calls some processor-initializing code before routine int main() starts. This fact per comments in SysTick demo source file main.c . . .

int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */

Our challenge seems to be to direct gcc and related tools to bring together C sources and pre-existing assembly or 'dot s' files. Here is a reference which talks about coding syntax in C and assembly but is missing details of makefile syntax for GCC:

More a reference on crafting makefile to handle assembled files along with source files:

An article on bare metal programming of an ARM Cortex-M9 which gets closer to what we need, though assembly file is purely assembly here:

How to preprocess assembly files with C'ism:


2018-05-09 Searching via Google with phrase "STM32f compile demo project Linux .s file":

Searching with phrase "arm-none-eabi-gcc assembly .s file":


Our invocations of arm-none-eabi-gcc and arm-none-eabi-as so far, where .s files seem to not work at all and .S files trigger some processing:

  983  /usr/bin/arm-none-eabi-as -g -mcpu=cortex-m3 -mthumb startup_stm32f10x_md_vl.s -o startup_stm32f10x_md_vl.o
  987  /usr/bin/arm-none-eabi-as -g -mcpu=cortex-m3 -mthumb startup_stm32f10x_md_vl.S -o startup_stm32f10x_md_vl.o
  988  /usr/bin/arm-none-eabi-gcc -g -mcpu=cortex-m3 -mthumb startup_stm32f10x_md_vl.S -o startup_stm32f10x_md_vl.o
  989  /usr/bin/arm-none-eabi-gcc -x startup_stm32f10x_md_vl.S
  990  /usr/bin/arm-none-eabi-gcc -x assembler-with-cpp startup_stm32f10x_md_vl.S


^ edit point

On writing ARM assembly - looking for examples of assembly files with different comment styles:



^ GCC manual page

From gcc's manual page:

       Preprocessor Options
           -Aquestion=answer -A-question[=answer] -C  -dD  -dI  -dM  -dN -Dmacro[=defn]  -E  -H -idirafter dir -include file
           -imacros file -iprefix file  -iwithprefix dir -iwithprefixbefore dir  -isystem dir -imultilib dir -isysroot dir -M  -MM
           -MF  -MG  -MP  -MQ  -MT  -nostdinc -P  -fdebug-cpp -ftrack-macro-expansion -fworking-directory -remap -trigraphs  -undef
           -Umacro -Wp,option -Xpreprocessor option

       Assembler Option
           -Wa,option  -Xassembler option

-E tells gcc to stop after preprocessing. Says nothing about how default preprocessing of gcc handles given input files.



^ GNU assembler versus ARM assembler

Assembly files written in ARM assembler syntax won't assemble using GNU `as`, per Stack Overflow forum post 20301140:

Here is some work compiling an3268 SysTick demo source file main.c to the assembly stage, using GNU arm-none-eabi-gcc:

Systick main dot c to assembly Systick main dot c to assembly


Search for ARM assembler which is not GNU based, and available on Debian-like systems (also why QEMU needs code which ends which an infinite loop):



^ Startup and linker files in STCube1 libraries

About to examine following start-up assembly files for STM32F100xb type microcontrollers . . .

user@localhost:~/Downloads/stm/STM32Cube_FW_F1_V1.6.0$ find . -name 'startup_stm32f100*'

./Projects/STM32VL-Discovery/Templates/TrueSTUDIO/startup_stm32f100xb.s
./Projects/STM32VL-Discovery/Templates/EWARM/startup_stm32f100xb.s
./Projects/STM32VL-Discovery/Templates/MDK-ARM/startup_stm32f100xb.s
./Projects/STM32VL-Discovery/Templates_LL/EWARM/startup_stm32f100xb.s
./Projects/STM32VL-Discovery/Templates_LL/MDK-ARM/startup_stm32f100xb.s

Ah sure enough! Some of these start-up assembly files are written in GNU gcc syntax, just what we need! TrueSTUDIO instance of file startup_stm32f100xb.s is written and assembles properly via arm-none-eabi-as.

So we've been trying to build and run an AN3268 demo firmware, using a makefile template of two makefiles from Indiana State Geoffy Brown, which should be ok as `make` is a tool and not a mix of two different libraries. There is however also a matter of a linker script which sets out things like where object file code gets put into memory. We were referencing a GNU assember incompatible start-up file and changed that. May we also be referencing an incompatible linker script in our instance / copy of AN3268 SysTick demo firmwares? Here are the first linker scripts found, working up dir by dir from the location of the start-up file:

/opt/lib/an3268/stm32vldiscovery_package$ find . -name '*.ld'
./Project/Master Workspace/TrueSTUDIO/stm32_flash.ld
./Project/Demo/TrueSTUDIO/DISCOVER/STM32F100RB_FLASH.ld
./Project/Examples/STANDBY Mode/TrueSTUDIO/stm32_flash.ld
./Project/Examples/IWDG/TrueSTUDIO/stm32_flash.ld
./Project/Examples/Sleep Mode/TrueSTUDIO/stm32_flash.ld
./Project/Examples/JTAG Remap/TrueSTUDIO/stm32_flash.ld
./Project/Examples/WWDG/TrueSTUDIO/stm32_flash.ld
./Project/Examples/DMA/TrueSTUDIO/stm32_flash.ld
./Project/Examples/EXTI/TrueSTUDIO/stm32_flash.ld
./Project/Examples/GPIOToggle/TrueSTUDIO/stm32_flash.ld
./Project/Examples/Flash Program/TrueSTUDIO/stm32_flash.ld
./Project/Examples/STOP Mode/TrueSTUDIO/stm32_flash.ld
./Project/Examples/RCC/TrueSTUDIO/stm32_flash.ld
./Project/Examples/SysTick/TrueSTUDIO/stm32_flash.ld


^ Linker script syntax

Ok now that we can compile assembly files, those ending in .s which are written in GNU toolchain syntax we have a binary we've flashed to the dev board. But no action! Debugging is different and more constrained in a development board than in a PC with operating system environment. Could there be something wrong with our linker script? ^

Golden . . .

From Sourceware reference we learn that GNU linker `ld` can accept at least two linker files. We just wrote one and passed it to linker in an amendment in our local project makefile. Here is the linker script which defines a symbol that is in Geoffry's template linker script but not in STM AN3268 TrueSTUDIO template linker script. We named this linker file 'extra-linker-directives.ld' . . .

/* comment */

SECTIONS
{
     PROVIDE ( _exit = _ebss );
}

So we've modified out project to use a new linker script, and this second linker script which provides one additional variable assignment to `ld`. Still no visible working of SysTick AN3268 demo . . . tried some other things. Strangely calls to STMDiscovery.c routine ...LEDOff() seem to turn one or the other of LED3 (GPIOC_9) and LED4 (GPIOC_8) on rather than off. Now looking for beginner blink-LED programs for the STM32F100 Discovery board . . .

^ First Steps To GPIO 'Hello World'

The following article shows a couple things, a project which seems to omit any .s type start-up file. Also there's comment in the main.c file above a while(1) construct, that this infinite loop is important to keep the micro from running unintended code should some code be loaded beyond the end of the intended firmware:

In AN3268 SysTick demo in source file main.c it's not obvious where or whether GPIOC clock settings are taking place. Again there is mention in main.c of a call to SystemInit(), which doesn't appear as a function in the SysTick project directory, and doesn't appear to be a fully defined function in startup_stm32f10x_md_vl.s. In yesterday's May 10 tests to compile to the point of a .s file the source file main.c we had to include several other .h files which probably correspond at least some of them to .c files, one of which may hold the function SystemInit(). The files we needed to symbolically link to in that small work are:

~/projects/stm32f/assembly-tests$ ls -l
total 104
-rw-r--r-- 1 veris veris  1787 May  9 14:54 Makefile.common
lrwxrwxrwx 1 veris veris    99 May 10 11:04 STM32f10x.h -> /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h
lrwxrwxrwx 1 veris veris    69 May 10 11:03 STM32vldiscovery.h -> /opt/lib/an3268/stm32vldiscovery_package/Utilities/STM32vldiscovery.h
lrwxrwxrwx 1 veris veris    83 May 10 11:02 core_cm3.h -> /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/CoreSupport/core_cm3.h
-rw-r--r-- 1 veris veris 11834 May 10 11:48 main-dot-c-to-assembly.tar.bz2
-rw-r--r-- 1 veris veris  3810 May  8 08:11 main.c
-rw-r--r-- 1 veris veris  1695 May  8 11:05 main.h
-rw-r--r-- 1 veris veris 30218 May 10 11:04 main.s
-rw-r--r-- 1 veris veris  1768 May 10 11:47 notes.txt
-rw-r--r-- 1 veris veris  5204 May 10 14:12 startup_stm32f100xb.o
-rw-r--r-- 1 veris veris 11927 May 10 14:11 startup_stm32f100xb.s
lrwxrwxrwx 1 veris veris    99 May 10 11:01 stm32f10x.h -> /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h
lrwxrwxrwx 1 veris veris   106 May 10 11:03 system_stm32f10x.h -> /opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h
drwxr-xr-x 3 veris veris  4096 May  9 14:55 test-1

Yes, found it! . . .

/opt/lib/an3268/stm32vldiscovery_package/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x$ !grep    ( $ grep -n SystemInit ./* )
grep -n SystemInit ./*
grep: ./startup: Is a directory
./system_stm32f10x.c:153:  static void SystemInit_ExtMemCtl(void); 
./system_stm32f10x.c:172:void SystemInit (void)
./system_stm32f10x.c:216:    SystemInit_ExtMemCtl(); 
./system_stm32f10x.c:380:void SystemInit_ExtMemCtl(void) 
./system_stm32f10x.h:78:extern void SystemInit(void);

Looks like everything gets reset in this function, and there's a lot of registers and bit flags getting reset:

 172 void SystemInit (void)
 173 {
 174   /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
 175   /* Set HSION bit */
 176   RCC->CR |= (uint32_t)0x00000001;
 177 
 178   /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
 179 #ifndef STM32F10X_CL
 180   RCC->CFGR &= (uint32_t)0xF8FF0000;
 181 #else
 182   RCC->CFGR &= (uint32_t)0xF0FF0000;
 183 #endif /* STM32F10X_CL */
 184 
 185   /* Reset HSEON, CSSON and PLLON bits */
 186   RCC->CR &= (uint32_t)0xFEF6FFFF;
 187 
 188   /* Reset HSEBYP bit */
 189   RCC->CR &= (uint32_t)0xFFFBFFFF;
 190 
 191   /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
 192   RCC->CFGR &= (uint32_t)0xFF80FFFF;
 193  172 void SystemInit (void)
 173 {
 174   /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
 175   /* Set HSION bit */
 176   RCC->CR |= (uint32_t)0x00000001;
 177 
 178   /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
 179 #ifndef STM32F10X_CL
 180   RCC->CFGR &= (uint32_t)0xF8FF0000;
 181 #else
 182   RCC->CFGR &= (uint32_t)0xF0FF0000;
 194 #ifdef STM32F10X_CL 172 void SystemInit (void)
 173 {
 174   /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
 175   /* Set HSION bit */
 176   RCC->CR |= (uint32_t)0x00000001;
 177 
 178   /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
 179 #ifndef STM32F10X_CL
 180   RCC->CFGR &= (uint32_t)0xF8FF0000;
 181 #else
 182   RCC->CFGR &= (uint32_t)0xF0FF0000;
 195   /* Reset PLL2ON and PLL3ON bits */
 196   RCC->CR &= (uint32_t)0xEBFFFFFF;
 197 
 198   /* Disable all interrupts and clear pending bits  */
 199   RCC->CIR = 0x00FF0000;
 200 
 201   /* Reset CFGR2 register */
 202   RCC->CFGR2 = 0x00000000;
 203 #elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL)
 204   /* Disable all interrupts and clear pending bits  */
 205   RCC->CIR = 0x009F0000;
 206 
 207   /* Reset CFGR2 register */
 208   RCC->CFGR2 = 0x00000000;
 209 #else
 210   /* Disable all interrupts and clear pending bits  */
 211   RCC->CIR = 0x009F0000;
 212 #endif /* STM32F10X_CL */
 213 
 214 #if defined (STM32F10X_HD) || (defined STM32F10X_XL)
 215   #ifdef DATA_IN_ExtSRAM
 216     SystemInit_ExtMemCtl();
 217   #endif /* DATA_IN_ExtSRAM */
 218 #endif
 219 
 220   /* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
 221   /* Configure the Flash Latency cycles and enable prefetch buffer */
 222   SetSysClock();
 223 }

Function SetSystemClock() is defined:

 339 /**
 340   * @brief  Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers.
 341   * @param  None
 342   * @retval None
 343   */
 344 static void SetSysClock(void)
 345 {
 346 #ifdef SYSCLK_FREQ_HSE
 347   SetSysClockToHSE();
 348 #elif defined SYSCLK_FREQ_24MHz
 349   SetSysClockTo24();
 350 #elif defined SYSCLK_FREQ_36MHz
 351   SetSysClockTo36();
 352 #elif defined SYSCLK_FREQ_48MHz
 353   SetSysClockTo48();
 354 #elif defined SYSCLK_FREQ_56MHz
 355   SetSysClockTo56();
 356 #elif defined SYSCLK_FREQ_72MHz
 357   SetSysClockTo72();
 358 #endif


^ STM32F10x Demo Projects and Exercises



^ References



- - - top of page - - -