User Tools

Site Tools


stm32

STM32

Important facts about the stm32 in general and for programming it

  • Multiple external pins can be associated to interrupts
  • Clock must be initialized by software. The stm32 is able to detect a failure of the external clock and fall-back on the internal clock and issue an interrupt. Connect this to a red led! Blink a special pattern to indicate this condition. Use time measurement that adjust to the different cpu clocks by reading from the clock source register?
  • Booting pins working not clear
  • Reset circuitry not necessary, is already included. It can generate interrupts if voltage goes down. The voltage threshold must be configured. Check PVD.
  • Standby mode. SRAM and register information gets lost.
  • DMA supports circular buffers automatically
  • TIM1 (advance timer) can do 0-100% PWM 4+3complementary
  • TIMx (3 normal timers) 4 PWMs
  • Timer Link allows synchronization between timers.
  • Watchdog can operate as a normal independent timer.
  • SysTick timer can operate as a normal timer.
  • Two Spis operate up to 18Mbits/s
  • GPIOs can do output push-pull and open-drain, input can do pull-up-down,tristate. Analog inputs are not high current, the rest are. 18MHz toggling speed.
  • Two ADC. 16 channels. Automatic conversion over a group of channels. Watchdog threshold, can generate an interrupt. ADC conversion triggering can be connected to timers and DMA. Termometer connected to ADC12_in16.
  • There must be multiple rail capacitors. Take a look on Figure 12. stm32 medium density pdf.
  • Each I/O pin hold 25mA ABS max, 8mA nom and sink 20mA nom output current.
  • For enable prefetching, clock setting and bus prescaling must be previously configured
  • Disabling peripherals is good for current consumption.
  • Flash uses two wait states. Maybe running code from SRAM could be good.
  • Reducing CPU operating frequency reduces current consumption proportionally
  • Sleep mode helps significantly when peripherals are disabled.
  • Stop and Standby mode are in the uA order.
  • ADC freq 0.6-14MHz clock, sampling: 0.05-1MHz. Conversion speed is limited by the input capacitance, it distorts the signal in a non-correctable way. Fig32,33. stm32_medium_density pdf. Temperature sensor information table 49 stm32_medium pdf.

Memory

  • Little endian format
  • There are two bit-banding memory areas. One can set and read independent bits from there. (without doing the read-modify-write instruction.
  • Flash prefetch buffer activated by default
  • table 5 of stm32_low_medium_high summarizes the boot pins.
  • There is an embedded boot loader in system memory for usart1 programming

Power control, Clock and Reset

  • Voltage detector is enabled in PVDE bit in PWR_CR
  • For slowing down CPU speed take a look in RCC_CFGR
  • Enabling disabling peripherals in : RCC_APB1ENR RCC_APB2ENR and RCC_AHBENR
  • For entering sleep mode use WFI (wait for interrupt) or WFE (wait for event) instruction. SLEEPONEXIT (Cortex system control register) is important to select the way entering sleep workds. Wake on event is faster because is not entering any interrupt rutine.
  • Stop mode table 10 stm32_low_medium_high. The internal regulator can be set in low_power mode with LPDS bit in PWR_CR.
  • Reset origin (reason for the reset, what produced the reset) can be check in RCC_CSR. There is software reset.
  • System clock SYSCLK can be driven by HSI, HSE, PLL clocks
  • For clock configuration check RCC_CR.
  • One can check if HSI (8MHz internal RC osc) is stable with the HSIRDY flag
  • The PLL can multiple HSI and HSE. Configuration of PLL must be done before enabling it. And interrupt can be generated when the PLL is ready.
  • The LSI internal RTC source can be calibrated to get Real time like behaviour. Pag 71 stm32_low_medium_high
  • After reset HSI is selected as system clock (SYSCLK). Clock source must be ready to be selected as new clock, check RCC_CR flags for that. With CSS (clock security system) the system detects a failure in the HSE and changes automatically to HSI and issues a NMI.
  • The stm32 can output 4 different types of clock in MCO pin. RCC_CFGR

Peripherals

  • Before using them they have to be enabled in RCC_AHBENR RCC_APB1ENR RCC_APB2ENR

GPIO

  • Each GPIO port has two 32-bit configuration registers (GPIOx_CRL, GPIOx_CRH), two 32-bit data registers (GPIOx_IDR, GPIOx_ODR), a 32-bit set/reset register (GPIOx_BSRR), a 16-bit reset register (GPIOx_BRR) and a 32-bit locking register (GPIOx_LCKR).
  • GPIO registers must be accessed as 32bits words
  • GPIOx_BSRR and GPIOx_BRR registers is to allow atomic read/modify accesses. Ints are not affecting then.

Interrupts

  • 60 interrupt lines + 16 Cortex interrupts. 16 programmable priority levels.

Watchdogs

  • Apparently watchdogs are disabled after reset by default

Device electronic signature

  • The size of the memories contained in the stm are stored in the system memory in some special registers. This may be used by the compiler and/or by the programmer.
  • Device ID. (serial number)

Setup order

  1. Disable Interrupts?
  2. Configure clocks RCC_CR RCC_CFGR
  3. Configure power PWR_CR
  4. Configure GPIOs GPIOx_CRL/H
  5. Set output GPIO pins to non problematic values GPIOx_ODR or GPIOx_BSRR/BRR
  6. Configure Peripherals
  7. Configure Interrupts

ARM CORE

  • You can write to the PSR, APSR, IPSR, EPSR using the MSR instruction. In fact is possible make combinations of this registers.
stm32.txt · Last modified: 2021/02/01 05:55 by 127.0.0.1