http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1848/PF254044?sc=stm32f3discovery is the STM32F3DISCOVERY evaluation board I purchased. http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/user_manual/DM00063382.pdf is Feb 2013 "UM1570 User manual STM32F3DISCOVERY Discovery kit for STM32F303xx microcontrollers".
STMicroelectronics offers a MS-Windows software named ST32CubeMX which enables a designer to configure a STM microprocessor and generates C and assembly code for driving it. http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00104712.pdf is the Jan 2015 "UM1718 User manual STM32CubeMX for STM32 configuration and initialization C code generation". In order to generate code for compilation with the Linux GCC toolchain, choose "TrueSTUDIO" as the toolchain.
When I purchased a STM32F3-discovery board last year, I downloaded ST32CubeMX version 1.0. There are several projects using the Linux GCC toolchain to compile for STM processors which I found online. But these projects use ST32CubeMX version 1.1.0; they are incompatible with the files generated by ST32CubeMX-1.0. So I downloaded the latest ST32CubeMX, which turned out to be version 1.1.1. The library functions have been renamed in ST32CubeMX-1.1.1 and the directories have been reorganized, so the code it generates is incompatible with both earlier versions.
STMicroelectronics has documentation for the microprocessor, the hardware abstraction layer (HAL), and "middlewares", but I can't figure how to navigate to them on their site. Google search comes to the rescue.
http://www.st.com/web/en/resource/technical/document/reference_manual/DM00043574.pdf is the Jan 2015 manual for everything in the STM32F303xB/C/D/E, STM32F303x6/8, STM32F328x8, STM32F358xC, STM32F398xE chips other than the CPU, memory layout, and interrupts, which are documented (for STM32F3 and STM32F4) in May 2014 "PM0214 Programming manual" http://www.st.com/web/en/resource/technical/document/programming_manual/DM00046982.pdf
http://www.st.com/web/en/resource/technical/document/datasheet/DM00058181.pdf is the electrical and timing specifications for STM32F303xB and STM32F303xC.
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00122016.pdf documents the hardware-abstraction-layer Feb 2015 "UM1786 User manual Description of STM32F3xx HAL drivers". It corresponds to ST32CubeMX version 1.1.1. Between this manual and the specifications, it should be possible to create firmware without starting from the ST32CubeMX (MS-Windows) program.
http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/user_manual/DM00063382.pdf is Nov 2014 "UM1734 User manual STM32Cube USB device library". It is not quite up-to-date with ST32CubeMX-1.1.1, referring to some function names (eg. Controllability()) which do not exist in version 1.1.1 or version 1.1.0. Perhaps the code is in transition. There are fields like _USBD_HandleTypeDef.dev_connection_status which are never referenced by the code and callbacks like HAL_PCD_ConnectCallback() which are never called.
The USB-CDC function CDC_Transmit_FS() is very useful; it
sends a message over the USB to /dev/ttyACM0. Its use has replaced the
on-board LEDs for debugging my real-time program.
The toolchain I use is gcc-arm-embedded. The version in Ubuntu-12.04 doesn't work with the STM32F3. https://launchpad.net/gcc-arm-embedded has instructions for installing the current version of gcc-arm-embedded (which does work).
Openocd "Open On-Chip Debugger" is used to program and run gdb on the STM32F3DISCOVERY board. The version of Openocd in Ubuntu-12.04 does not support the STM32F3DISCOVERY. I downloaded and compiled from http://openocd.sourceforge.net/getting-openocd/.
https://github.com/mblythe86/stm32f3-discovery-basic-template is a 1.1.0 demonstration project for STM32F3. It was helpful for creating Makefiles and gcc-arm-embedded linking.
Here is the process I used to port a project generated from the directory structure created by ST32CubeMX-1.1.1:
git clone https://github.com/cjheath/stm32f3-discovery-basic-template.git
In your project directory: Create "Device/ldscripts/" directory and copy "sections_flash.ld", "stm32f3discovery_def.ld", and "stm32f3.ld" from "stm32f3-discovery-basic-template/Device/ldscripts/" into "Device/ldscripts/".
Copy "Drivers/CMSIS/Device/ST/STM32F3xx/Source/Templates/gcc/startup_stm32f303xc.s" into "Device/".
Copy "Drivers/CMSIS/Device/ST/STM32F3xx/Source/Templates/system_stm32f3xx.c" into "Src/".
Copy Makefile from "stm32f3-discovery-basic-template/Libraries/Makefile" into directory "Drivers/". In it set SRCS = to a list of all the files in "Drivers/STM32F3xx_HAL_Driver/Src/"
Copy "stm32f3-discovery-basic-template/Makefile" into project directory and modify for your file locations.
I am undoubtedly forgetting some of the other changes which were necessary.
The callbacks (and some other functions) have "__weak" definitions. These are supposedly overridden by non-"__weak" function definitions. I found that this was sometimes not happening. Changing the link order did not fix the problem. Removing the "__weak" definitions fixed it.
Even with the documentation, I was unable to get a differential analog-to-digital converter (ADC) to work correctly. Instead, I convert the two channels separately and subtract.
Governance by those who do the work.
Sunday, March 22, 2015
Programming the STM32F3-Discovery
Posted by Aubrey Jaffer at 1:31 PM No comments:
Labels: gcc-arm-embedded, Openocd, stm32CubeMX, stm32f3, stm32f3discovery
Subscribe to: Posts (Atom)
- ▼ 2015 (17)
- ► 2011 (13)
- ► 2010 (13)