Hallo,
ich bin Neuling auf dem Gebiet der Mikrocontroller. Ich habe mir ein myavr Baord mit einem Atmega8 gekauft. Nun möchte ich ein PWM erzeugen. Also Lampe an/aus hat prima geklappt, nur bekomme ich das PWM-Signal einfach nicht hin.
Ich habe mich jetzt knapp 3 Stunden eingelesen und rumprobiert, in Foren gesucht, aber nichts verwertbares gefunden.
Ich programmiere mit Codevision in C. Mit Assembler hab ich nix am Hut. Das gleich vorneweg
Ich habe mir nun mit dem Wizzard einen Code erzeugen lassen, welcher sich auch kompilieren lässt, nur leider tut sich nichts.
Wo liegt hier mein Problem? Bisher habe ich nur Beispiele für andere Controller gefunden. Wenn ich die einfach einfüge geht das kompilieren logischerweise nicht.Code:/***************************************************** This program was produced by the CodeWizardAVR V1.25.5 Evaluation Automatic Program Generator © Copyright 1998-2007 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 11.03.2008 Author : Freeware, for evaluation and non-commercial use only Company : Comments: Chip type : ATmega8L Program type : Application Clock frequency : 3,686400 MHz Memory model : Small External SRAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega8.h> #include <io.h> // Timer 2 overflow interrupt service routine interrupt [TIM2_OVF] void timer2_ovf_isr(void) { // Place your code here } // Declare your global variables here void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=0 State2=T State1=T State0=T PORTB=0x00; DDRB=0x08; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: 3686,400 kHz // Mode: Fast PWM top=FFh // OC2 output: Non-Inverted PWM ASSR=0x00; TCCR2=0x69; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off MCUCR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x40; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // Global enable interrupts #asm("sei") while (1) { // Place your code here }; }
Ich hoffe mir kann jemand sagen was ich wo einfügen muss, dass ich meine LED dimmen kann.
Später möchte ich dann ein Servo anschließen und das dann mit dem Poti nach links/rechts fahren lassen. Aber erstmal klein anfangen
Vielen Dank
Gruß Andreas







Zitieren

Lesezeichen