Advertisement
czaru34

piecjedenc

Jan 14th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. //Cezary Zaprawa
  2. //Jedna dioda swieci 500/2000ms
  3. //Częstotliwość: 1MHz
  4.  
  5. #include <avr/io.h>
  6. #include <avr/interrupt.h>
  7.  
  8. ISR(TIMER1_COMPA_vect) {
  9.     PORTA &= ~(1 << 0);
  10. }
  11. ISR(TIMER1_OVF_vect) {
  12.     PORTA |= (1 << 0);
  13. }
  14. void init() {
  15.     cli();
  16.     DDRA |= (1 << 0);
  17.     PORTA |= (1 << 0);
  18.     OCR1A = 7813;
  19.     ICR1 = 31250;
  20.     TCCR1A |= (1 << WGM11);
  21.     TCCR1B |= (1 << WGM12) | (1 << WGM13);
  22.     TIMSK |= (1 << OCIE1A) | (1 << TOIE1);
  23.     TCCR1B |= (1 << CS11) | (1 << CS10);
  24.     sei();
  25. }
  26. int main(void) {
  27.     init();
  28.     while(1) {
  29.         asm("nop");
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement