Hi everyone!
I'm trying to produce the 16-bits fast PWM mode on the PB7 pin (Atmega 2560).
This is my code:
#include <util/delay.h> #include <avr/io.h> #include <avr/interrupt.h> #define PortInit DDRB|=(1<<7) #define LedOn PORTB|=(1<<7) #define LedOff PORTB&=~(1<<7) //int TimerCounter=0; void timer_ini(void) { TCCR1A|=(1<<COM1C1)|(1<<WGM11)|(1<<WGM10); // неинверсный режим TCCR1B|=(1<<ICNC1)|(1<<ICES1)|(1<<WGM13)|(1<<WGM12)|(1<<CS12)|(1<<CS11)|(1<<CS10); // Устанавливаем делитель=1024 TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x30; OCR1CH=0x00;; OCR1CL=0x15; // } int main(void) { timer_ini(); //DDRB|=(1<<PORTB7); //LedOff; //PORTB^=0x80; //Меняем состояние вывода while(1) { } }
As I understood the datasheet, is should work,but it doesn't.
Where is my error in this code?
Thank you in advance:)