Arduino Micro Isp

Philipp | Feb 24, 2020

Description

A PWM signal is generated at output PB3 without timer prescaler. The register OCR0 (0..255) defines the duty cycle. The timer runs in non inverting mode. Thus, the output becomes high when the counter jumps from 255 to 0 and the output becomes low when the coampare match takes place and the counter is equal to OCR0.

Sourcecode

FastPWM.c

#include <avr/io.h>

int main(void)
{

    DDRB = 0x08;                         // Setup PB3 as output

    TCCR0 |= (1<<WGM00)|(1<<WGM01)       // Start timer0 without
             |(1<<COM01)|(1<<CS00);      // prescaler in non
                                         // inverting fast PWM
                                         // mode. Connect OC0 in
                                         // non-inverting mode

    OCR0 = 64;                           // Set Dutycycle to 25%

    for(;;);                             // Endless loop
                                         // main() will never be left

    return 0;                            // This line will never be executed

}

Signal Plot

signal plot