cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H5 Waveform Generation using External DAC

mrsthb_qmt
Associate

Hi,

I am trying to generate waveforms using the STM32H563 microcontroller and several AD5791 DAC ICs. I am using the ADG732 Multiplexer with 5 select lines to connect my CS line to the required DAC IC. A simplified image of the hardware is provided below:

DAC_WF.jpg

 I have to generate triangle waveforms on two channels simultaneously. Generating the waveform on one channel at a time works perfectly. However, when I attempt to generate two waveforms on two channels, I get the following output:

Screenshot 2024-06-11 125201.png

The two triangle waves have amplitudes of 1.5V and 2.5V, but the output of both channels appears on a single channel, while the second channel remains unchanged. The SPI frequency is 10MHz. I have configured two timers to trigger interrupts based on the frequency and sampling rate of the waveform. I am storing the amplitude values (100 samples) in two different lookup tables. Every time a timer interrupt is triggered, the select value of the multiplexer is changed, and a value from the LUT is transmitted to the DAC over SPI. A few of my code snippets are provided below:

mrsthb_qmt_0-1718274366194.png

Timer IRQ Handlers:

mrsthb_qmt_0-1718277565482.png
mrsthb_qmt_1-1718277596579.png

SPI TxCpltCallback:

mrsthb_qmt_4-1718274875295.png

The select lines of the MUX (A0 - A4) are connected to the microcontroller on pins PC0 - PC4, and the output on the GPIO pins has to be inverted due to hardware limitations. It is important to note that when only one of the timers is started, the waveform is generated on the correct channel. However, things go wrong only when both timers are started together.

1 ACCEPTED SOLUTION

Accepted Solutions
mrsthb_qmt
Associate

I moved the NVIC_EnableIRQ() functions to the HAL_SPI_TxCpltCallback() function and everything works fine now.

View solution in original post

1 REPLY 1
mrsthb_qmt
Associate

I moved the NVIC_EnableIRQ() functions to the HAL_SPI_TxCpltCallback() function and everything works fine now.