An experimental LED-strip controller and my first embedded-programming project with C and Go. STM32F103 firmware drives LED brightness with PWM through MOSFETs. A separate controller, such as a Raspberry Pi or ESP8266, sends commands over SPI.
The project explores low-latency lighting controls from gamepads, MIDI, network requests and other inputs. These are experiments and design goals; not every input or transport is complete.
- Experimental hardware and software with known bugs, unused code and unfinished features. It is not a supported, ready-to-use lighting system.
- RGB is not supported.
- The original setup used three LED strips. Other configurations have not been verified here.
- The original notes report unexpectedly high CPU use in the Go controller. The hardware and build notes below retain the other known issues.
PA8, PA9, PA10, PA11 (PA11 is used by USB, so only 3 other pins are available)
Current set up: PA4: SPI1_NSS PA5: SPI1_SCK PA6: SPI1_MISO PA7: SPI1_MOSI
This could probably be changed to other SPI on other pins, but I haven’t checked that.
PA11: D- PA12: D+ USB port on the blue pill is connected to the same pins.
doesn’t work if stm32 connected by itself, works if ground is connected to rpi group (???)
- openocd or Black Magic Probe which implements openocd internaly
- gcc-arm-none-eabi
- newlib
copy openocd files to: /usr/share/openocd/scripts/target/cs32f1x.cfg /usr/share/openocd/scripts/board/cs32f103c8t6.cfg
Connect st-link
make -C my-project make flash -C my-project
start openocd: openocd -f /usr/share/openocd/scripts/board/cs32f103c8t6.cfg
connect to it via gdb: gdb-multiarch –eval-command=”target remote localhost:3333” my-project/your-file.elf
You can also connect to openocd via ‘telnet localhost 4444’ and send some commands to it
msg_type size payload
- set one led
- set all leds
- set some configuration?
- get led value?
- get configuration value(s)
Clock / Prescaler / ARR = timer frequency
clock / desired timer frequency = prescaler * ARR
timer_set_prescaler TIM_PSC
divides the clock
timer_set_period ARR
sets timer ?
- TIM_OC?: Output Compare channel
- TIM_OC?N: ?
- Add another message type to only receive the state, not change it
`
UART2 (TX: PA2, RX: PA3) is most convenient.