## Configuring PWM with TCCR0 register The following bits control the various parameters of this Timer/Counter feature We have set the bits 6, 5 , 3, and 0 to HIGH. The functions of each bit are explained in the datasheet of the ATMEGA32 microcontroller used in KuttyPy ### Bit 6, 3 – WGM01:0: Waveform Generation Mode These bits control the counting sequence of the counter, the source for the maximum (TOP) counter value, and what type of Waveform Generation to be used. Modes of operation sup- ported by the Timer/Counter unit are: Normal mode, Clear Timer on Compare Match (CTC) mode, and two types of Pulse Width Modulation (PWM) modes. We have selected mode 3(Fast PWM) since both bits are set. ### Bit 5:4 – COM01:0: Compare Match Output Mode These bits control the Output Compare pin (OC0) behavior. If one or both of the COM01:0 bits are set, the OC0 output overrides the normal port functionality of the I/O pin it is connected to. However, note that the Data Direction Register (DDR) bit corresponding to the OC0 pin must be set in order to enable the output driver. When OC0 is connected to the pin, the function of the COM01:0 bits depends on the WGM01:0 bit setting. Table 39 shows the COM01:0 bit functionality when the WGM01:0 bits are set to a normal or CTC mode (non-PWM). ### The three Clock Select bits select the clock source to be used by the Timer/Counter. ]]> DDRD TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE PORTD TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE DDRB FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE TCCR0 FALSE TRUE TRUE FALSE TRUE FALSE FALSE TRUE WHILE TRUE OCR0 0 0 Y-Axis 0 0.01