Giter Site home page Giter Site logo

stm32tmrdo's Introduction

STM32TMrdo

Topmetal control and readout using STM32 and its internal ADC

PINS

  • Pixel clock: PC6
  • ADC sampling trigger: PC8
  • Reset: PD12
  • Speak: PD13

STM32H743ZITx NUCLEO-LQFP144

  • USB VCP (on OTG port) could be opened with python -m serial.tools.miniterm /dev/cu.usbmodemFD131 115200
  • D-Cache could cause DMA issues
  • Examples are very valuable.
  • Power domains
    • D1 domain containing some peripherals and the Cortex-M7 core. AXI bus; AHB3; APB3
    • D2 domain containing a large part of the peripherals. AHB1,2; APB1,2; SRAM1,2,3; DMA1,2
    • D3 domain containing some peripherals and the system control. AHB4; APB4; SRAM4; BDMA

ADC

  • PB1 (on CN12) is ADC12_INP5, which is a fast channel.
  • t_conv = 4.5 CLK (8bit) ~ 8.5 CLK (16bit), 1 CLK for every 2 bits.
  • t_samp >= 1.5 CLK.
  • 16-bit mode max sample rate is 3.6 Msps.
  • ADC1 and ADC2 are in AHB1/D2 (domain 2).
  • Fadc = 72MHz / 2 / a select factor. Max is 36MHz (BOOST=1), 20MHz (BOOST=0).
    • The extra /2 factor is introduced in silicon revision V.
    • BOOST should be automatically handled by HAL_ADC_Init().
    • In code, manually setting hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; seems to work.

DAC

  • DAC1_OUT1 is routed out to PA4 (CN11 pin 32). If ADC channel and DAC channel are selected on the same GPIO, connection is done internally in GPIO pad, user has nothing to connect.
  • DAC is on APB1 (120MHz max), 12-bit. TIM6 and TIM7 are usually used for triggering DAC.

Timer

  • TIM8 set to asymmetric PWM mode to generate chip clock and ADC sampling trigger with precise phase offset control.
    • CH1 (Pin PC6) is clock output.
    • CH3 (Pin PC8) is ADC trigger output.
  • TIM4 is set to be the slave of TIM8.
    • In one-pulse mode, slave GATED mode. Effectively the trigger from TIM8 becomes its clock.
    • Ch1 and Ch2 in PWM mode.
    • Software starts counter TIM4->CR1 |= (TIM_CR1_CEN);.
  • TIM6 triggers the DAC.

GPIO

  • Routing PD13 back to PC7 to trigger the start of ADC/DMA acquisition will miss the beginning of the 1st frame by several CLKs.

STM32 ARM MCU firmware

  • STM32CubeMX is used to configure the pin function/clock and setup the basic software skeleton.
    • Make sure SYS->Debug = Serial Wire is selected. Otherwise future flash writing will be disabled.
    • Choose Makefile under Toolchain/IDE for GNU-RM compatible skeleton.
    • Choose HAL set all free pins as analog and Enable full assert.
    • Choose copy all used libraries into the project folder so that make won't rely on independently installed Cube FW package (SDK).
    • Make minimal modification to the generated code. Place the majority of user code in separate files one level up to the generated code directory.
    • It seems asking the software to update the already generated files is not reliable. Better delete all generated files and re-generate.
    • After copying the files over, run cleanCube.sh to clean up the file permissions and add additional information into Makefile. New makefile is generated and make will pick up the new one automatically. Modify cleanCube.sh accordingly when new .c files are added.
    • A new main.c is generated as well. This way, no manual intervention to any of the STM32CubeMX generated files is needed.

Useful commands

  • readelf -a xxx.elf or objdump -h xxx.elf to see the built image size. Add up the size of all the loadable sections, such as .text and .data. Look for the LOAD flag in the output from objdump. Ignore non-loadable sections such as .comment, .debug and .bss.

USB CDC ACM

Toolchain

  • STM32CubeMX
  • GNU
    • Download and put into ~/Applications/arm.
    • ~/Applications/arm/env.sh:
    #!/bin/sh
    
    ARMROOT=$HOME/Applications/arm
    export PATH=$ARMROOT/bin:$ARMROOT/arm-none-eabi/bin:$PATH
    export LD_LIBRARY_PATH=$ARMROOT/lib:$LD_LIBRARY_PATH
    export MANPATH=$ARMROOT/share/man:$MANPATH
    
    $ mkdir build && cd build
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/arm ..
    $ make -j5
    $ make DESTDIR=~/Applications install
    
    • st-util, st-flash, st-info to download image to/manipulate STM32 MCU.
  • In-Application Programming (IAP)
  • Open source ARM Cortex-M microcontroller library libopencm3
  • J-Link Debug Probes
  • Black Magic Probe: In application debugger for ARM Cortex microcontrollers
  • STM32CubeProgrammer
    • Write firmware then start running: ~/Applications/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI -c port=SWD -w build/STM32H743ZITxCubeMX.hex -s
    • For NUCLEO (-H7 at least), remember to hold down reset (black button), start the command, then release the button.
      • Enable Debug (SWD) in CubeMX project to solve this problem.

stm32tmrdo's People

Contributors

ymei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.