Hi all,
I am using ATMega328-AU controller in that I am using Pin 9(PD5) for pulse generation. I haven't set any frequency to the pin, I want to know what is the default frequency of the pin and if i want to change How to change the frequency.
Hi all,
I am using ATMega328-AU controller in that I am using Pin 9(PD5) for pulse generation. I haven't set any frequency to the pin, I want to know what is the default frequency of the pin and if i want to change How to change the frequency.
Assuming you are using the Arduino IDE to program it, the frequency will be as stated in the arduino documentation for the board definition you are using. IIRC it's just under 500Hz.
If you want to change the pwm frequency, either use a library that does this for you, or reconfigure the registers that control Timer1 per the datasheet.
Be sure to set the fuses (using Burn Bootloader) when using a new microcontroller, otherwise the board will be running at 1MHz instead of the speed you expect.
But each and every timer like Timer 1 and Timer 0 will run at different frequencies by default like 8KHz, 64KHz etc... for timers without using resgister setting it will run at some default frequency. As i am using Pin 9 it is Timer 1
The timer set up by the Arduino IDE is established by init() in wiring.c.
The path to that file in Windows is
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring.c
There you will find
// set timer 1 prescale factor to 64
// put timer 1 in 8-bit phase correct pwm mode