Hallo zusammen,
ich möchte bei meinem ATMega168 den PWM Port OC2B bzw. PD3 nutzen. Leider kenn AVR_GCC die entsprechenden Konstanten nicht.
Hier mein Quellcode:
Die Fehlermeldung:Code:#ifndef F_CPU #define F_CPU 16000000UL #endif #include <avr/io.h> #include <util/twi.h> //enthält z.B. die Bezeichnungen für die Statuscodes in TWSR #include <avr/interrupt.h> //dient zur Behandlung der Interrupts #include <stdint.h> //definiert den Datentyp uint8_t #include "twislave.h" #include <stdlib.h> //nötig für Zahlumwandlung mit itoa #include <util/delay.h> void pwm_init() { DDRD |= (1<<OC2B); // Port OC2B mit angeschlossener LED als Ausgang TCCR2B = (1<<WGM10) | (1<<COM1A1); // PWM, phase correct, 8 bit. TCCR2B = (1<<CS11) | (1<<CS10); // Prescaler 64 = Enable counter OCR2B = 128-1; }
und der Makefile:Code:app.c:28: error: 'OC2B' undeclared (first use in this function)
Ich vermute es fehlt irgendwo ein include. Leider weiss ich nicht mehr weiter.Code:TARGET = app MCU = atmega168 DEVICE = atmega168 MCU_TARGET = atmega128 CC = avr-gcc CFLAGS =-mmcu=$(MCU) -Wall LDFLAGS =-mmcu=$(MCU) $(TARGET): $(TARGET).o $(TARGET).hex : $(TARGET) avr-objcopy -j .data -j .text -O ihex $< $@ load: $(TARGET).hex avrdude -F -P com6 -p m168 -c stk500v2 -U flash:w:$(TARGET).hex -v clean: rm -f *.o *.hex $(TARGET)
vg bjj







Zitieren

Lesezeichen