cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering the DAC DMA with HRTIM

SMile.1
Associate

Hello,

I am trying to trigger the DAC1 DMA off of the HRTIM Master channel using the hrtim_dac_trg signals on an STM32G474, but I am not getting any output on my DAC pin. The timer does seem to be running (I can see MCNTR incrementing in the debugger), and can verify I've got MCR.DACSYNC = 0x01. I also have CR.TSEL1 on DAC1 set to dac_chx_trg15 (0x0F). I have also tried enabling TIM6 w/ TRGO, and changing nothing aside from changing TSEL1 to dac_chx_trg7 I was able to see the waveform on my DAC output, which leads me to believe I am missing something in my HRTIM configuration which is causing hrtim_dac_trig to not trigger. I've attached screengrabs of the MX configuration & the HRTIM master and common register values as seen at runtime in the debugger. If there's any other relevant info I can provide let me know.

Any input would be very welcome, thanks!

0693W000003BQESQA4.png

0693W000003BPvpQAG.png

8 REPLIES 8
victagayun
Senior III

Hello, I am also looking for the same functionality but it seems HRTIM cannot trigger DAC at any setup I do.

There may be a similar project located in

Repository\STM32Cube_FW_H7_V1.9.0\Projects\NUCLEO-H743ZI\Examples\HRTIM\HRTIM_DAC_ADC_Interconnect

I haven't tried it yet so let me know how it goes.

What I did was I external trigger the DAC, and feed the HRTIM output to that external trigger.

It was a waste of 3 IOs, 1 HRTIM output and 2 DAC external inputs.

DmitryRozh
Associate

Hi all,

I also have this issue! Maybe someone (from ST) could post a very simple project with the HRTIM triggering DAC? It is very annoying to lose EXTI9 pin, and it makes trigger jitter definitely higher.

Regards,

Dmitry

riversnails
Associate

I don't know if you're still looking for this feature, but here's the answer.

As far as the operating procedure is concerned

-Hardware Settings
1. Enables the timer to be used among the timers in hrtim.
2. Set the timer to advanced.
3. Sets the period of hrtim to the period of dac trigger.
(I'm referring to the period value.)
(Please set the prescaler ratio for the periodic resolution.)
4. Set mode to free-running.
5. Use dacsyncro to set the dac to trigger.
6. Enables the roll-over function.
(It is tied to the reset update item of the item.)

If you set it up like this, you can see that it looks roughly like the picture below.

setting1.PNG

(I used stm32f334k to confirm that the detailed items may be different, but the functions for using the dac trigger are all the same.)

-Software Settings
1. Initialize with the init code generated through cube mx.
2. Run with HAL_HRTIM_WaveformCountStart function.


This will now output the dac trigger signal.


At this time, I don't see the item setting roll-over in your writing, but I think the cubemx for the stm32g474 project at the time seems incomplete.

In the current version, there are two basic/advanced modes as shown in the picture below.

When you set it to advanced mode, you can see in the picture below that you have a new item to set up roll-over.

advanced.PNG

reset.PNG


(stm32g474RE DOCS)
It is described in the section 27.3.21 DAC triggers in the Reference manual.
If you read this description, you will get a dac trigger output whenever an update event occurs for a timer with DACSYNC set.

A list of update events used here can be found in Table 231.

figure 255. shows the OR dac trigger of multiple timers by using compare to reset the timer (roll-over update).

The way I explained to you is to use roll-over to generate an update event. This setting is to generate an update event every reset and a constant dac trigger signal every cycle.

Eventually, you can generate an update event in many other ways, but using the roll-over function is the simplest way.

Hi,

does anyone know, how one HRTIM timer can trigger more than one DAC? In the post above it is not clear to me how this can be done! In my configuration I use HRTIM Timer_A and I want to trigger DAC1 to DAC3 to work synchron with Timer_A update event. How can this be done efiicently? Any help is would be highly welcome, thanks!

Regards,

Benedikt

berait
Associate II

Nobody any idea of how to trigger DAC1 to DAC3 synchronously with HRTIM? Above is EXTI9 mentioned, that is an option how I can trigger all DACs at once. In the post above EXTI0 is mentioned to do that, but can HRTIM timer event somehow be connected internally to EXTI9 pin?

 

Regards, Benedikt

sorry typo, I mean EXTI9 instead of EXTI0

riversnails
Associate

I'm not sure what it means to synchronize DAC3 in DAC1.

If what you're talking about means tying multiple DAC triggers into one hrtimer's DACTrigOut, I think we should choose how to connect using one more timer.


For example, you can set hrtimerA as before, and then synchronize hrtimerB's reset trigger.

Originally, you would have to link the reset trigger through the master timer, but if the master timer has to be used for other purposes, you could use the reset trigger using hrtimerA's complex.
(The master timer originally exists for the interworking of these two timers, but if you need to use different synchronization options within that mcu, you can try this expediency.)

The exti mentioned above seems to mean setting the trigger of the dac to exti pin and linking the trigger with the output of the hrtimer, so I don't think it's a very good way.

In addition, there is a way to use the external event of hrtimer, but this also doesn't look good to get from other peripherals or pins.


I'm trying to find a way to connect only trigger settings in DAC1 channel 1,2/DAC2 channel 1 without using more timers, but I'm going to take some time to answer.
Here, it seems that the same trigger can be used for DAC1 channel 1 and 2 (DACTRG1/2), but for DAC2 channel 1, a completely different trigger (DACTRG3) is used. In other words, only one hrtimer can be used in the same DAC, but if you have to use DAC2, you will have to use another timer.
I couldn't analyze the program accurately because that part is an environment where I can't debug now.
If it's an environment where you can't use more timers, I think you should test it with a debugger and check it.

 

The examples in this article are based on stm32f334k8t6.

 


I'm sorry that the writing is not smooth because it was written with a translator.
If you have any questions, please reply.

Hi riversnails,

that is a good idea to enable muliple timers inside HRTIM module and synchronize them, but how can I sync Timer_B to start simultaneos to Timer_A without using the master timer?

Regards, 

Benedikt