Module: ESP32-WROOM-32D
IDF version: V4.2
OS: Win7
Expected result: Generate 10000Hz squal wave by timer is successful
Real result: Watchout occurs when the generated frequence is over 80000Hz
Tested timer: Timer 0 of Group0
Output pin: IO26
Test Step: (1)Set TIMER_INTERVAL0_SEC = 0.000009
(2)Change state of IO26 (from 0 to 1 or 1 to 0) in timer_group0_isr
(3)View the result on IO26 use Oscilloscope
Attached: (1)main.c of project (a2dp_gatts_coex)
(2)sdkconfig of project (a2dp_gatts_coex)
(3)log file when watchdog occurs
Since the sdkconfig have no text format that can't upload, so I add .txt, please delete .txt format when need build it.
The square-wave-output generated by timer can't greater 40000Hz
-
- Posts: 5
- Joined: Thu Oct 13, 2022 8:36 am
The square-wave-output generated by timer can't greater 40000Hz
- Attachments
-
- timerDebug.log
- (14.12 KiB) Downloaded 140 times
-
- sdkconfig.txt
- (53.64 KiB) Downloaded 152 times
-
- main.c
- (219.57 KiB) Downloaded 154 times
-
- Posts: 5
- Joined: Thu Oct 13, 2022 8:36 am
Re: The square-wave-output generated by timer can't greater 40000Hz
Sorry, some description need correct:
Expected result: 50000Hz(change state from 0 to 1 or 1 to 0 in 10us)
Real result: Watchdog occurs when the generated frequency greater than 40000Hz(change state from 0 to 1 or 1 to 0 in 12.5us)
Expected result: 50000Hz(change state from 0 to 1 or 1 to 0 in 10us)
Real result: Watchdog occurs when the generated frequency greater than 40000Hz(change state from 0 to 1 or 1 to 0 in 12.5us)
Re: The square-wave-output generated by timer can't greater 40000Hz
Is generating a square wave the final result you'd like to achieve, or is it just a simplified example?
ESP chips have many peripherals which let you generate complex waveforms while using little CPU time. So if the waveform you are generating is pre-defined, you can set up RMT, SPI, I2S or LEDC peripheral to generate it.
(The limitation you are running into is due to the total time it takes to switch between the task and interrupt context. Once the system doesn't have enough time to do anything other than constantly entering and exiting the interrupt, the watchdog occurs.)
ESP chips have many peripherals which let you generate complex waveforms while using little CPU time. So if the waveform you are generating is pre-defined, you can set up RMT, SPI, I2S or LEDC peripheral to generate it.
(The limitation you are running into is due to the total time it takes to switch between the task and interrupt context. Once the system doesn't have enough time to do anything other than constantly entering and exiting the interrupt, the watchdog occurs.)
-
- Posts: 5
- Joined: Thu Oct 13, 2022 8:36 am
Re: The square-wave-output generated by timer can't greater 40000Hz
I need generate a CW or CCW signal to control servo motor.
It is a square wave between 0Hz to 50000Hz.
Since the frequency must be change anytime, so I select use timer to control.
I think maybe PWM is selection.
It is a square wave between 0Hz to 50000Hz.
Since the frequency must be change anytime, so I select use timer to control.
I think maybe PWM is selection.
-
- Posts: 5
- Joined: Thu Oct 13, 2022 8:36 am
Re: The square-wave-output generated by timer can't greater 40000Hz
exp-idf have (servo control) example, I can use it to modify. thanks.
-
- Posts: 5
- Joined: Thu Oct 13, 2022 8:36 am
Re: The square-wave-output generated by timer can't greater 40000Hz
Our control must can control the number of pulse and the frequency of output pulse at the same time.
So, can not use PWM and only can utilize the ISR of timer that priority is more high.
So, can not use PWM and only can utilize the ISR of timer that priority is more high.
Who is online
Users browsing this forum: Bing [Bot] and 112 guests