Difference between revisions of "Stm32f100 notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
(2018-05-08 - adding some investigative problem solving notes on STM32F100x demo start-up code - TMH)
m (The dot S File)
Line 143: Line 143:
 
       system_stm32f10x.c file
 
       system_stm32f10x.c file
 
     */
 
     */
 +
</pre>
  
 +
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 to how to do this . . .
  
</pre>
+
*  http://msoe.us/taylor/tutorial/ce2810/candasm
  
  

Revision as of 17:23, 8 May 2018

Overview

This article to hold notes on early works with STMicro's STM32F100VL Discovery Board . . .



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

$



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 to how to do this . . .



References

Some possible STM32F100RB demo projects and exercises . . .