Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 3.c
- *
- * Created: 05.11.2019 13:53:30
- * Author : dspproject
- */
- #define F_CPU 14745600UL
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <util/delay.h>
- void init_timer()
- {
- unsigned value = 18; //asta ii OCR1A , grija la virgula
- OCR1AH = (value >> 8) & 0xFF;
- OCR1AL = (value & 0xFF);
- TCCR1B = 1 << 3; //mode 4
- TCCR1B |= 1 << 1; // clk pt asta trebuie sa fie 1 (CS11 = 1)
- //OCR1A = value;
- }
- int main(void)
- {
- /* Replace with your application code */
- DDRB |= 1;
- init_timer();
- int x = 0;
- while (1)
- {
- if((TIFR & (1 << 4)) != 0) //tifr arata cand a ajuns la capat, un fel de ct
- {
- //aprinde led
- if(x)
- PORTB |= 1;
- //_delay_ms(200);
- else
- PORTB = 0;
- //_delay_ms(200);
- x = x ? 0 : 1;
- TIFR |= 1 << 4; //asa ii facut, sa se reseteze cand il punem pe 1 ( siguranta++)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment