I am building a boost converter using a mosfet. The mosfet is driven by PWM generated by an Arduino Uno through Matlab Simulink. In Simulink I am giving 10 KHz pulse width 50%. Practically 10 KHz available at pins 5 and 6. Up to how much frequency can pins 5 and 6 handle?
2 Answers
See my page about timers. The maximum frequency the hardware can output is 8 MHz if you are running a 16 MHz clock.
10 kHz should be easily achievable if you tweak the hardware registers, as Gerben said.
Up to how much frequency can pins 5 and 6 handle?
here is a way for you to find out:
1) pin 5/6 are OC0A and OC0B -> two output compare pins tied to timer0
2) go to the datasheet and timer0 is a 8-bit timer, with a few pwm modes who top out at 0xff or OCR0A -> useless for your application.
So the theoretical but useless answer is 16Mhz/2, at 1:1 prescaler.
the more practical answer is 16Mhz / 256, at 1:1 prescaler.
with that said, some AVRs (ATtiny25/45/85 for example) can run in asynchronous modes generating incredibly high PWM with very little outside help.
if generating high speed pwm is your thing, check them out instead.
millis
anddelay
. You'd better of using pins 9 and 10 which use timer1.