MCU Design
MCU Responsibilities
The MCU is the main controller in this project. It is responsible for reading analog values from the sliders with the ADC, sending those values over DMX using USART, and sending the most recently changed value to the FPGA over SPI.
ADC implementation
Nine linear potentiometers are used in this project, each outputting a distinct analog value between 0 and 3.3V. The onboard ADC is capable of up to 10 12-bit conversions of external signals. At the beginning of the loop, all 9 signals are sampled 100 times and averaged to reduce noise. The 12-bit values are then cast to 8 bits to fit the size of a DMX parameter. The initialization code for the ADC was modified from a previous E155 project by Eli Rejto and Kevin Box
DMX implementation
The DMX standard is built upon RS485, which is built upon UART. The standard provides specific timing and data-framing requirements for transmitters and receivers. Each DMX signal is a string of 8-bit values for up to 512 parameters. In this implementation, we used 18. The timing is more complicated than the USART module alone could handle, so each transmission protocol included both directly writing to the data pin for specific times and UART transmission with the UART module.
Communication with the FPGA.
The FPGA is responsible for representing only the most recently changed slider number and its value. The MCU determines which slider was most recently changed and sends the slider number and value over SPI to the FPGA. The SPI initialization and send functions were modified from the starter code for E155 Lab 7.
Throughout the development of the MCU codebase, we frequently referenced the STM32L432KC datasheet and reference manual.