PWM wird nie 0

Gast #1558656
Lesenswert?

Hallo!

Ich habe eine Frage, und zwar bei diesem Einfachen Programm wird die PWM 
nie 0, also ich habe immer ca. 200ns on-time

weiß jemand wieso?
Takt ist ein 4Mhz
1
#include <avr/io.h>
2
int main()
3
{
4
  
5
  DDRB = (1 << PB1 ); //OCR1A Ausgangspin Port B1
6
   
7
  TCCR1A = (1<<COM1A1) | (1<<WGM11); //Nicht Invertierende PWM
8
  TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS10); //Vorteiler 1 10-Bit Fast PWM
9
  ICR1 = 20000;
10
  while( 1 )
11
  {
12
    OCR1A = 0;
13
  }
14
}

danke
Lg Hans
Gast #1558697
Lesenswert?

Das liegt an der Zählweise bei Fast-PWM:
1
The extreme values for the OCR1x Register represents special cases when generating a PWM
2
waveform output in the fast PWM mode. If the OCR1x is set equal to BOTTOM (0x0000) the output
3
will be a narrow spike for each TOP+1 timer clock cycle. Setting the OCR1x equal to TOP
4
will result in a constant high or low output (depending on the polarity of the output set by the
5
COM1x1:0 bits.)

Es geht nur "dauer high" oder bei invertierung "dauer low" mit
dem Spike am anderen Ende.

avr

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren