AVR ExamplePWMgenerator.c: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace |
Bez shrnutí editace |
||
(2 medziľahlé úpravy od jedného ďalšieho používateľa nie sú zobrazené) | |||
Riadok 2: | Riadok 2: | ||
/* ******************************************************** */ | /* ******************************************************** */ | ||
/* Example 10.1. Timer counter 1 as a PWM generator */ | /* Example 10.1. Timer counter 1 as a PWM generator */ | ||
/* | /* */ | ||
/* Warning: The values are NOT CORRECT, they should be re- */ | /* Warning: The values are NOT CORRECT, they should be re- */ | ||
/* placed by students themselves!!! */ | /* placed by students themselves!!! */ | ||
/* ******************************************************** */ | /* ******************************************************** */ | ||
int main(void) { | int main(void) { | ||
/* *********************** Init device | /* *********************** Init device ******************************** */ | ||
DDRB = 0b00000000; // | DDRB = 0b00000000; // | ||
PORTB = 0b00000000; // | PORTB = 0b00000000; // | ||
DDRC = 0b00000000; // | DDRC = 0b00000000; // | ||
PORTC = | PORTC = 0b00000000; // | ||
/* *********************** Init T1 as a PWM generator *************************** */ | /* *********************** Init T1 as a PWM generator *************************** */ | ||
Riadok 36: | Riadok 26: | ||
for (;; | for (;;); | ||
} | } |
Aktuálna revízia z 08:21, 9. november 2012
/* ******************************************************** */
/* Example 10.1. Timer counter 1 as a PWM generator */
/* */
/* Warning: The values are NOT CORRECT, they should be re- */
/* placed by students themselves!!! */
/* ******************************************************** */
int main(void) {
/* *********************** Init device ******************************** */
DDRB = 0b00000000; //
PORTB = 0b00000000; //
DDRC = 0b00000000; //
PORTC = 0b00000000; //
/* *********************** Init T1 as a PWM generator *************************** */
TCCR1A = 0b00000000; // Mode: PWM, Phase Correct, 9-bit
TCCR1B = 0b00000000; // Prescaler 1:1024
OCR1A = 000; // Initialization values
OCR1B = 000; // for 1:1 duty cycle
TCNT1 = 0;
for (;;);
}