5972 views|6 replies

3

Posts

0

Resources
The OP

About the synchronization problem of stm32 output PWM square wave [Copy link]

Hello, seniors. I am planning to call an ADC recently. I have encountered some problems that I do not understand. I need help! The problem is that the ADC needs a 10MHz CLK signal and a CONV signal from the microcontroller. The CONV signal jumps every 4760 clks, that is, the high and low levels jump, but it requires that the conv jump must jump within 10ns around the 4760th clk rising edge, which requires the phases of clk and conv to be almost synchronized. Some people on the Internet say that CH1 of TIM1 generates a 10M clk signal and ch2 generates a conv signal. But how can we make the conv jump within 10ns of the clk rising edge every time? Please help me! Thank you! In addition, if the ADC is connected to a 10M crystal oscillator, and the crystal oscillator signal is also introduced into the stm32 counter, when the 4760th clk rising edge is counted, the CONV jumps immediately. In this way, at the 72M stm32 frequency, how many ns will the reaction time be? According to the concept of instruction cycle, is it several dozen ns at once? :time: I am still a student, please give me more advice, thank you very much!
This post is from stm32/stm8

Latest reply

This post was last edited by wuqibuyou on 2014-11-21 11:06If you use the same counter and use the edge alignment mode, the phases will definitely be the same, with very little difference, because the comparison action of the comparator is not through the CPU, but is automatically compared by the hardware, so the speed is still quite fast. However, it is best not to use interrupts to handle it, because after entering the interrupt, the CPU will act, which is very slow. You can turn on the pwm output, which is already the fastest you can do. You can use an oscilloscope to see if the waveform meets the requirements. I think it should be fine. As for how to write the program, you can look at what is in the library function. Basically, it initializes the timer and output module, which is quite simple. But I don't have any ready-made code at hand now. . . And I used dsp and 430 before. I just got started with stm and I am not very familiar with this thing. So, if you really can't write it yourself, I will work hard for you. If you can get it done, it will be great.   Details Published on 2014-11-21 11:04

104

Posts

0

Resources
推荐
It can be done using the comparison and capture modules of the timer, but the output frequency of the PLL inside the microcontroller needs to be increased. Use one capture module of the timer to output a 10MHz signal, and use another capture module of the timer to output an enable signal. Since the two modules use the same counter, there should be no problem.
This post is from stm32/stm8

Comments

Hello, thanks for your help! If we use the same counter, will the phase be the same? How should I write this program?  Details Published on 2014-11-20 17:45

4973

Posts

19

Resources
2
One instruction cycle should be only 1us.
This post is from stm32/stm8

Comments

Hello, how is 1us calculated? Isn't it possible to reach a speed of dozens of mips?  Details Published on 2014-11-20 17:43
Personal signature我的博客

4002

Posts

0

Resources
4
You can use the clock to output 10M and then use the timer to make a jump every 4076 clocks to achieve this.
This post is from stm32/stm8

3

Posts

0

Resources
5
zhaojun_xf posted on 2014-11-18 17:59 One instruction cycle should be 1us. .
Hi, how is 1us calculated? Can't it reach a speed of dozens of mips?
This post is from stm32/stm8

3

Posts

0

Resources
6
Wuqibuyou posted on 2014-11-18 18:57 It can be done using the timer comparison and capture module, but the PLL output frequency inside the microcontroller needs to be increased a bit. Using a capture module of the timer...
Hello, thank you for your help! If the same counter is used, the phase will be the same, right? How should this program be written?
This post is from stm32/stm8

Comments

If you use the same counter and use the edge alignment mode, the phases will definitely be the same, with very little difference, because the comparison action of the comparator is not done by the CPU, but is automatically compared by the hardware, so the speed is still quite fast. However, it is best not to use interrupts to process, because after entering the interrupt, the CPU will act.  Details Published on 2014-11-21 11:04

104

Posts

0

Resources
7
This post was last edited by wuqibuyou on 2014-11-21 11:06
cxpph007 posted on 2014-11-20 17:45 Hi, thanks for your help! If we use the same counter, the phase will be the same, right? How should I write this program?
If you use the same counter and use the edge alignment mode, the phases will definitely be the same, with very little difference, because the comparison action of the comparator is not through the CPU, but is automatically compared by the hardware, so the speed is still quite fast. However, it is best not to use interrupts to handle it, because after entering the interrupt, the CPU will act, which is very slow. You can turn on the pwm output, which is already the fastest you can do. You can use an oscilloscope to see if the waveform meets the requirements. I think it should be fine. As for how to write the program, you can look at what is in the library function. Basically, it initializes the timer and output module, which is quite simple. But I don't have any ready-made code at hand now. . . And I used dsp and 430 before. I just got started with stm and I am not very familiar with this thing. So, if you really can't write it yourself, I will work hard for you. If you can get it done, it will be great.
This post is from stm32/stm8

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list