STM32

From ElectroDragon
Jump to: navigation, search

STM32

Hook up Guide

Stm32 serial wiring 02.jpg

STM32 Linux

Debugger OpenOCD

  • Help page.
  • Use either ST-LINK or OpenOCD, can work with ST-LINK2
  • For example OpenOCD, run command as follow to install
  1. install openocs: sudo apt-get install openocd
  2. setup up for usbdevice: sudo vi /etc/udev/rules.d/99-stlink.rules
  3. add conent: ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"
  4. reload setup: sudo udevadm control --reload-rules
  5. open board: openocd -f /usr/share/openocd/scripts/board/stm32f3discovery.cfg
  6. or use: /usr/share/openocd/scripts# openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg
  • If well connected, result will show:

Open On-Chip Debugger 0.7.0 (2013-05-15-17:44) Licensed under GNU GPL v2 For bug reports, read

http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v16 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : Target voltage: 2.915198
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoint
  • Run another terminal and telnet to the board: telnet localhost 4444
  • halt it into debug mode: reset halt or: reset init
  • Reflash bin into board:
flash write_image erase maple_mini_boot.bin 0x08000000
flash write_image erase /media/sf_VM_XP_share/LED.hex
  • Finall reset it to start up again: reset run

Toolchain

  • Install: sudo apt-get install gcc-arm-none-eabi

Firmware libopencm3 and test code

  • git clone the firmware and try stm32f103 demo blink code, the firmware works like arduino
git clone https://github.com/libopencm3/libopencm3-examples.git
cd libopencm3-examples
git submodule init // 
git submodule update
make
  • enter into board folder like: cd libopencm3-examples/examples/stm32/f3/stm32f3-discovery/miniblink
  • for STM32F1x board, enter into /libopencm3-examples/examples/stm32/f1/stm32-h103//miniblink/
  • firmware support openocd, can run make flash directory
  • Or manually telnet to openocd: telnet localhost 4444
reset halt
flash write_image erase miniblink.elf
reset


Windows Software

For STM8:

Software From version
IAR EWSTM8 1.3
STVD 4.2
STVP 3.2

For STM32:

Software From version
IAR EWARM 6.2
Atollic TrueSTUDIO 2.1
Keil MDK-ARM 4.2
Tasking VX-Toolset for ARM Cortex-M 4.0R1


Schematic

Schematic STM32F103C8T6
STM32-sch 02.png STM32-sch.png

STM32 F103 Features

Core: ARM 32-bit Cortex ™ -M3 CPU

  • Up to 72MHz operating frequency
  • Single cycle multiplication and hardware division

Memory

  • from 64K or 128K bytes of Flash program memory
  • up to 20K bytes of SRAM

Clock, reset and power management

  • 2.0 to 3.6 V supply and I / O pins
  • Power on / off reset (POR / PDR), programmable voltage monitoring (PVD)
  • 4 ~ 16MHz crystal oscillator
  • Built-in factory-calibrated 8MHz RC oscillator
  • Built-in calibrated 40kHz RC oscillator
  • PLL that generates the CPU clock
  • 32 kHz RTC oscillator with calibration function

Low power consumption

  • Sleep, Standby and Standby modes
  • V BAT supplies power to the RTC and the back-up registers

2 of 12-bit analog-to-digital converters, 1us conversion time (up to 16

  • Conversion range: 0 to 3.6V
  • Double sampling and hold function
  • Temperature sensor

DMA:

  • 7-channel DMA controller
  • Peripherals supported: timers, ADC, SPI, I 2 C and USART

Up to 80 Fast I / O ports

  • 26/37/51/80 I / O ports, all I / O ports can be mapped to 16 external interrupts; almost all ports can tolerate 5V letter number

Debug mode

  • Serial single-wire debugging (SWD) and JTAG interfaces

Up to 7 timers

  • Three 16-bit timers, up to four for each timer / Input Capture / Output Compare / PWM or Pulse Count channels and incremental encoder inputs
  • One 16-bit with dead zone control and emergency brake for motors
  • Control the PWM Advanced Control Timer
  • Two Watchdog Timers (Standalone and Windowed)
  • System time timer: 24-bit self-decrementing counter

Up to 9 communication interfaces

  • Up to 2 I 2 C interfaces (Supports SMBus / PMBus)
  • Up to 3 USART interfaces (supports ISO7816 interface,

IN, IrDA interface and modem control)

  •  Up to 2 SPI interfaces (18 Mbit / s)
  • CAN interface (2.0B active)
  • USB 2.0 full speed interface

CRC computing unit, 96-bit chip unique code

Maple Mini

  • Schematic

Maplemini.jpg

Models

  • STM32F405 - 168Mhz M4 32bit, 1MB Flash
  • STM32F401 - 84 MHz, 512 Kb Flash