Servo Ansteuerung

Aus Ethersex_Wiki
Version vom 4. August 2009, 10:47 Uhr von Kiwi (Diskussion | Beiträge) (Die Seite wurde neu angelegt: dnl ################################################################################ dnl # This program is free software; you can redistribute it and/or modify it ...)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche


dnl ################################################################################ dnl # This program is free software; you can redistribute it and/or modify it # dnl # under the terms of the GNU General Public License (either version 2 or # dnl # version 3) as published by the Free Software Foundation. # dnl # # dnl # This program is distributed in the hope that it will be useful, # dnl # but WITHOUT ANY WARRANTY; without even the implied warranty of # dnl # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # dnl # GNU General Public License for more details. # dnl # # dnl # You should have received a copy of the GNU General Public License # dnl # along with this program; if not, write to the Free Software # dnl # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # dnl # # dnl # For more information on the GPL, please go to: # dnl # http://www.gnu.org/copyleft/gpl.html # dnl # # dnl # # dnl # Daten Analyse und Programm Erstellung: # dnl # Copyright (c) 08/2009 - Michael Schultz <ethersex@keyb.de> # dnl # # dnl ################################################################################ dnl CONTROL_START

       ECMD_GLOBAL(pos, 175, uint8_t);         dnl     Mittel Position @ 16 MHz
       THREAD(pwm_on)
               PORTC = 255 ;
               TCNT0 = pos ;
               PT_YIELD(pt);
       THREAD_END(pwm_on)
       ON STARTUP DO
               TCCR0B |=  _BV(CS02);           dnl     TCCR0B(CS02)=1          clkI/O/256 (From prescaler)
               TCCR0B &= ~_BV(CS01);           dnl     TCCR0B(CS01)=0          clkI/O/256 (From prescaler)
               TCCR0B &= ~_BV(CS00);           dnl     TCCR0B(CS00)=0          clkI/O/256 (From prescaler)
               TIMSK0 |=  _BV(TOIE0);          dnl     TIMSK0(TOIE0) = 1       Interrupt on Timer Overflow aktivieren
               DDRC = 255;
               PINC = 0;
               THREAD_START(pwm_on)
       END

CONTROL_END

ISR(TIMER0_OVF_vect) {

       PORTC = 0 ;
       TCNT0 = pos ;

}