-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWM Frequency change #142
Comments
a short example:
reason for the change of PWM Frequency is to change the Drivers operating mode between PWM and Analog output current |
Have a look at the current analogWrite implementation. By default, MicroCore/avr/cores/microcore/wiring_pwm.c Lines 33 to 97 in 9634a5d
|
thanks for the answer. is the "F_CPU/256" necessary? |
i was hoping to run the Tiny @600KHz to save some power. |
That's just how the timer works. Alternatively, you can just PWM fast mode. You'll probably need to use this mode to achieve a fast enough speed when the processor is running at 600kHz. Read the datasheet and search for "AVR fast PWM". There are plenty of examples out there |
how can i set the prescaler during sketch? without it being reset after calling analkogWrite? fastpwm is f OCnxPWM |
You write your own PWM function and use this instead of analogWrite. You can write to the registers directly, like so: |
so i can comment out lines 33 zo 55 and can write as following?
where 1kHz is in reality 585Hz and 5 kHz in reality 4.68 kHz (@1.2 MHz clock) |
i have found my issue, i am on OC0A on the attiny13V, is it possible to get fast and slow pwm here? |
Hello @ltwin8 , you may find my FastPwmPin library useful (see my GitHub page). It supports the ATtiny13A as well as other MCU's. On the ATtiny13A @9.6 MHz I've measured frequencies from 38HZ up to 1.6MHz. Note at very high frequencies the PWM resolution is smaller and the signal can become less stable. |
Hello MCUdude,
i would like to change the PWM Frequency for driving a special IC between 1 kHz (100 Hz up to 1.5 kHz are acceptable) and 3 kHz (2.5 kHz up to 5 kHz are acceptable)
could you please provide an example on how to do this?
Also is it possible to change PWM Frequency after PWM is running? so to speak "in the loop"?
The text was updated successfully, but these errors were encountered: