admin管理员组文章数量:1429979
I am currently working on an stmG474-re development board and aiming to use dac1 channel 2 to output a triangular waveform at a frequency of 77khz with the high resolution timer but struggling to reach the higher frequency of 77khz required.
Generating a triangular waveform is not an issue I have done this through multiple methods now via:
- inbuilt stm triangular waveform generator from the DAC with HRTIM as a trigger
- writing an array to the DMA and using that (this method is preferable as I plan to generate custom waveforms in the future
- Use a timer interrupt to update the DAC output manually at the desired rate and calculating a dac value in the interrupt handler.
However with each of these method I cannot seem to reach the high frequency required. Using the triangular waveform I am constrained to a period of 72 us. This is something I observe on my oscilloscope. Going above a frequency of approx 500kHz with the DMA creates a bottleneck and the DAC can't update fast enough instead outputtting a constant value.
I'm no expert in using cubeMX and pretty new to embedded programming but if anybody could suggest methods for outputting a triangular waveform at this frequency that would be great. Other Points:
- when using a sawtooth waveform generator this seems to reach the desired frequency rate with no issue.
- HCLK operating at 170MHz and PCLK1 also operating at 170MHz
- This is for DAC 1 Out 2 pin PA6.
- Most work here is done via configuration throug the cubeMX IDE.
- For the triangular waveform generator more info: An internal triangle counter is incremented three dac_hclk clock cycles after each trigger event according to the manual
I am currently working on an stmG474-re development board and aiming to use dac1 channel 2 to output a triangular waveform at a frequency of 77khz with the high resolution timer but struggling to reach the higher frequency of 77khz required.
Generating a triangular waveform is not an issue I have done this through multiple methods now via:
- inbuilt stm triangular waveform generator from the DAC with HRTIM as a trigger
- writing an array to the DMA and using that (this method is preferable as I plan to generate custom waveforms in the future
- Use a timer interrupt to update the DAC output manually at the desired rate and calculating a dac value in the interrupt handler.
However with each of these method I cannot seem to reach the high frequency required. Using the triangular waveform I am constrained to a period of 72 us. This is something I observe on my oscilloscope. Going above a frequency of approx 500kHz with the DMA creates a bottleneck and the DAC can't update fast enough instead outputtting a constant value.
I'm no expert in using cubeMX and pretty new to embedded programming but if anybody could suggest methods for outputting a triangular waveform at this frequency that would be great. Other Points:
- when using a sawtooth waveform generator this seems to reach the desired frequency rate with no issue.
- HCLK operating at 170MHz and PCLK1 also operating at 170MHz
- This is for DAC 1 Out 2 pin PA6.
- Most work here is done via configuration throug the cubeMX IDE.
- For the triangular waveform generator more info: An internal triangle counter is incremented three dac_hclk clock cycles after each trigger event according to the manual
- The datasheet mentions the HRTIM waveform generator, but from the user manual it appears that it is for PWM waveforms not DAC output. It is rather unclear, perhaps clarified by the CubeMX support (I never use it), but I am not sure how this is supposed to work. Perhaps you might show the code to a screenshot of the CubeMX configuration? – Clifford Commented Nov 19, 2024 at 15:05
- I am still (from staging) not sure what "I am constrained to a period of 72 us." means. Is that a constraint on the CubeMX configuration? Or a self imposed constraint? – Clifford Commented Nov 19, 2024 at 15:08
- ... sorry, just read your staging comment - that is not a "constraint" it is an apparent limit. A "constraint" is a self imposed imitation or a limit you are required to stay within. In this case it is an observation that it does not work at any faster period - strange to switch from frequency to period in your question too - a little confusing. – Clifford Commented Nov 19, 2024 at 15:12
1 Answer
Reset to default 1Use TIM6 instead which is "dedicated" for DAC.
if TIM clock is 170MHz
- PSC = 0
- ARR = 220
- ERROR: 0.1%
You will need 10 samples per period.
本文标签:
版权声明:本文标题:embedded - Outputting a Triangular Waveform from a DAC Output Pin at a rate of 77khz on an stm board - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745557041a2663250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论