ECE 486 Support Libraries
|
This library defines an interface that allows a user use the STM32L476G-Discovery development boards to stream input sampled data in real time from one or two ADCs, process the data, and stream the resulting output samples to one or two output DACs.
The user interface is as follows:
The user calls
where:
The same sample rate is used for the input ADC and output DAC data streams. The initialize_ece486() call enables clocks and configures the appropriate ADC(s), DAC(s), Timers, buttons, DMAs, UART, and interrupts. The function pauses at the beginning of the initialization (with red and green LEDs flashing) to wait for a user push-button (center joystick) indicating to continue (allowing the device to be re-programmed without errors).
For input_mode = MONO_IN or STEREO_IN, Analog input waveforms are sampled using ADC1 (MONO) or ADC1 | ADC2 (STEREO_IN). For the STM32L476G-Discovery board, ADC1 is accessed as an input on PA1, and ADC2 is accessed on PA2.
Analog output is generated using DAC Channel 2 (MONO_OUT) or DAC Channels 1 and 2 (STEREO_OUT). DAC CHannel 2 is accessed as an output on PA5 (MONO_OUT or STEREO_OUT). DAC Channel 1 actually drives an internal op-amp buffer (OPAMP1), with output to the discovery board connector on PA3 (STEREO_OUT only).
The green and red LEDs are configured and enabled. The LEDs are used to provide feedback during program execution. The red LED us used to indicate an error condition.
Sample values in the "input" or "result" arrays are of type float, and are normalized to range from -1.0 to +1.0 over the voltage range of the ADCs | DACs. (A sample of -1.0 is near 0V, +1.0 is near 3V, and 0.0 indicates the mid-scale voltage of 1.5V)
By default, Pin PD0 on the STM32L476-Discovery board is configured as a digital output pin. The pin status may be set using the macros
Other digital output can be configured using the standard HAL libraries The following configures PB6 (Port B, Pin 6) as a digital, push-pull output pin:
Once the pin is initialized, you can set the output state:
The LEDs on the discovery boards are accessed using the BSP_LED_xxx() functions. By default, the green LED (LED5) and red LED (LED4) are initialized. While both LEDs are available to the user, the red LED is used by the library to visually indicate error conditions. To drive green LED:
Users can check the global variable KeyPressed to check whether the (blue) user button on the Discovery board has been pressed. KeyPressed==SET indicates that a button press has occurred. The user should reset the value using KeyPressed=RESET;
A UART is also configured to direct printf() output to the ST-LINK USB serial port. Assuming that the host is connected to the ST-LINK connector, printf output may be examined on the host by connecting a terminal to the serial port. The terminal should be configured at 115200 bps, 8 bits, no parity, one stop-bit. printf() calls are blocking.
The discovery board LCD display may be accessed through the board-specific libraries provided with the discovery board. For example: