MUS177/267 – table lookup oscillators STM32F746

I am aware that most of my examples have been for the STM32F4Discovery board. This time I have coded it up for the STM32F746Discovery, and there is a little touchscreen meantone scale organ built in.

Use the blue button to switch between sine-saw-square-triangle. All formulas in the code, and most all of my code is in main.c for convenient browsing.

Details discussed next Tuesday.

Download link: f746disco-audio

MUS177-267 OpenOCD (update)

Installing OpenOCD

I have edited this document to put preferred methods of installation on the top. Also note that openocd 0.10 is required to program STM32F7 family chips.

macOS – Preferred method – homebrew

  • install Xcode and Xcode command line tools
  • install homebrew using  this command in the Terminal:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • install openocd using this in the Terminal:
    brew install --HEAD openocd
  • run openocd -f board/stm32f4discovery.cfg from the Terminal

Windows – Preferred method – Freddie Chopin

  • Download from http://www.freddiechopin.info/en/download/category/4-openocd
  • You will need a .7z unpacker to open the archive.
  • Place in your STMToolchain folder (not strictly necessary)
  • run openocd with options -f “board\stm32f4discovery.cfg” from Eclipse. You can do this from the Command Line, but you will need to set the MSDOS search path.

Common Bug – If you are “bounced” by openocd and have an STM32F4Discovery board

  • You probably have version MB997E of the board
  • Edit the file board/stm32f4discovery.cfg (in the openocd scripts folder) with Eclipse. If on macOS, you will have to first type Command-Shift-G in the file open box and enter /usr/local/share/openocd/scripts
  • Change the line that reads
    source [find interface/stlink-v2.cfg]

    to

    source [find interface/stlink-v2-1.cfg]
  • Save the file and try openocd again

Common Bug – If you are “bounced” by openocd and you are running Windows

Testing – Check Telnet Connection to OpenOCD

You will be able to connect to openocd with “telnet localhost 4444”. Windows users may need to enable the Telnet Client

Other methods to install OpenOCD (not all will work on all hosts)

 Windows & macOS (precompiled OpenOCD – latest for STM32F7)

  • Download from https://github.com/gnu-mcu-eclipse/openocd/releases
  • To run from command line – add bin directory to search path. macOS example – edit .bashrc:
     export PATH=$PATH:/Applications/GNU\ MCU\ Eclipse/OpenOCD/0.10.0-3-20170826-1813-dev/bin
  • Windows example – edit Control Panel:System:Advanced:Environment:Path. Append to end of path text:
    ;C:\Program Files\GNU MCU Eclipse\OpenOCD\0.10.0-3-20170826-1813-dev/bin
  • Run from Terminal (macOS) or Command Prompt (Windows)
    Windows

    openocd -s "C:\Program Files\GNU MCU Eclipse\OpenOCD\0.10.0-3-20170826-1813-dev\scripts" -f "board\stm32f4discovery.cfg"

    macOS

    openocd -s /Applications/GNU\ MCU\ Eclipse/OpenOCD/0.10.0-3-20170826-1813-dev/scripts -f stm32f4discovery.cfg

Windows(MSYS2 precompiled method)

  • Install MSYS2 from www.msys2.org
  • Install OpenOCD binary for 64: pacman S mingww64x86_64openocdgit
  • -or- for 32 bit: pacman S mingww64i686openocdgit
  • Restart MSYS2
  • Enter openocd -s “/mingw64/share/openocd/scripts” -f “board/stm32f4discovery.cfg”
  • You can now connect via “telnet localhost 4444” from another MSYS2 window
  • Connection from Eclipse uses port 3333 rather than 4444

Mus177-267 Installing Eclipse

Installing Eclipse

  • macOS and Windows are nearly the same for installation
  • neither macOS or Windows will have a Java Runtime Environment installed. Install JRE 8 from Oracle. JRE 9 does not currently work with Eclipse (without workarounds)
  • Install Eclipse Oxygen for C/C++ development
  • Older versions of Eclipse will work as well

Configure Eclipse for ARM development

Follow the guide on Camine Noviello’s blog https://www.carminenoviello.com/2014/12/28/setting-gcceclipse-toolchain-stm32nucleo-part-1/ from the text “When finished, you can launch the C:\STM32Toolchain\eclipse\eclipse.exe executable”

Skip the part about STLink and stop before “Flash the binary on the STM32Nucleo”

Now follow the blog entry on configuring OpenOCD https://www.carminenoviello.com/2015/01/07/setting-gcceclipse-toolchain-stm32nucleo-part-2/

MUS177 MUS267 Syllabus

music 267/177 – custom programming for music – winter 2022

instructor – tom erbe – tre@music.ucsd.edu

ta – devansh zurale – dzurale@ucsd.edu

•••••topic

this year we will be learning to program music software in a number of contexts. PD/Max externals, computer applications, or embedded processors. to do this we could cover 5 topics.

  1. c programming
  2. PD external programming
  3. Embedded programming on  STM32F4/7 bare metal or electrosmith daisy
  4. JUCE music application API
  5. computer music/signal processing algorithms

••••likely schedule

  1. introduction, discussion, basics, PD externals
  2. dsp code 1 – amplifiers and distortion (first assignment)
  3. STM programming – ADC and DAC, gates, CODEC, analog connections 
  4. dsp code 2 – oscillators and sampling 
  5. dsp code 3 – filters (second assignment)
  6. JUCE API – plugins and applications – GUI, parameters, MIDI, audio
  7. dsp code 3 – delay reverb
  8. other topics as interest or need requires (final assignment)

••••texts – software – hardware

all of these texts are suggested, but not required. however, all of these books will help you solve programming problems or give you signal processing ideas

  • C Primer Plus by Stephen Prata
  • Computer Music by Charles Dodge
  • DAFX by Udo Zolzer
  • ARM Cortex M4 Cookbook by Mark Fisher
  • DIGITAL SIGNAL PROCESSING AND APPLICATIONS : USING THE ARM CORTEX M4 by Donald Reay

PD is required for PD external programming

JUCE API from www.juce.com

For ARM programming obtain either an STM32F4Discovery Board or an STM32F7Discovery. The F4 board is slightly slower and has only sound out, but should be sufficient for this class. The F7 board has a touch display and sound in and out (though not simultaneously)

STM32F407G-DISC1 $21.70

STM32F746G-DISCO $56.25

As of this year there is a much simpler ARM board available. The Electrosmith Daisy Seed. It is $27.95, but I suggest either the POD, PETAL or PATCH, as they come with easy to use knobs and jacks (the POD is least expensive at $84).

•••••my office hours

9 – 5 tuesday and thursday

•••••class requirements

3 projects of increasing complexity…. one is a final project. students will be required to use their final project in a piece or for research.

****class notes

all class keynotes and examples will be on the class canvas and synthnotes.ucsd.edu