Servo ansteuern Mega32

#2122124
Lesenswert?

So habs ich gemacht ...
1
/************************************************************************************************************/
2
void EnableServoTestTimer ()
3
{
4
  DisableServoTestTimer ();
5
  // External crystal 16 MHz, Prescaler 8
6
  // Enable fast PWM mode 14 (table 47 page 113 ATMega16 Doc): 
7
  TCCR1A    = (1 << COM1A1) | (1 << WGM11);
8
  // Set prescaler 8
9
  TCCR1B    = (1 << CS11) | (1 << WGM13) | (1 << WGM12);  
10
  // Set PWM
11
  ICR1     = (uint16_t)40000;
12
  OCR1A    = (uint16_t)ServoPosition;    // min: 1800, neutral: 3000 max: 4200
13
  sei ();
14
}

Grüße,
Michael

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