Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.c
- *
- * Created on: 23 mar 2019
- * Author: admin
- */
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- volatile uint8_t licznik_przerwan1;
- volatile uint8_t licznik_przerwan2;
- volatile uint8_t licznik_przerwan3;
- #define CZAS_LED1 29
- #define CZAS_LED2 59
- #define CZAS_LED3 119
- int main(void) {
- TCCR0B = (1 << CS00) | (1 << CS02); //preskaler na 1024
- TIMSK0 = (1 << TOIE0); //włączenie przerwania z przepelnienia timera
- sei();
- // włączenie globalnego systemu pzerwań
- DDRA = (1 << PA0) | (1 << PA1) | (1 << PA2) | (1 << PA3);
- for (;;) {
- }
- }
- //inrerrup secial routine
- ISR(TIMER0_OVF_vect) {
- PORTA ^= (1 << PA0);
- //TCNT0 = 0;
- if (++licznik_przerwan1 > CZAS_LED1) {
- PORTA ^= (1 << PA1);
- licznik_przerwan1 = 0;
- }
- if (++licznik_przerwan2 > CZAS_LED2) {
- PORTA ^= (1 << PA2);
- licznik_przerwan2 = 0;
- }
- if (++licznik_przerwan3 > CZAS_LED3) {
- PORTA ^= (1 << PA3);
- licznik_przerwan3 = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement