Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * tes_time.c
- *
- * Created: 18/06/2018 09:38:18
- * Author: Andrea
- */
- #include <avr/io.h>
- #include <avr/interrupt.h>
- int i;
- int s;
- int main(void)
- {
- DDRD &= ~(1 << DDD2);
- DDRC = 0xFF;
- PORTD |= (1 << PORTD2);
- //registri pulsante
- EICRA=0X2;
- EIMSK |= (1 << INT0);
- //registri timer
- TCCR0A |= (1 << WGM01); //CTC mode TC0 (OCR0A -> TOP)
- TCCR0B |=((1 << CS02) |(1 << CS00)); //Prescaler 1024 (1 clk = 64 us)
- TIMSK0 = 0x00; //Interrupt compare A disabled
- OCR0A = 156;
- sei();
- while(1)
- {
- i=0;
- s=0;
- PORTC|= (1 << PORTC0);
- if(s=5){
- PORTC|= (1 << PORTC1);}
- if(s=10){
- PORTC|= (1 << PORTC2);}
- if(s=15){
- PORTC|= (1 << PORTC3);}
- if(s=20){
- PORTC|= (1 << PORTC4); }
- if(s=25){
- PORTC|= (1 << PORTC5);
- i=0;
- s=0;}
- }
- }
- ISR (INT0_vect) {
- PORTC=0x0;
- TIMSK0 = 0x02;
- }
- ISR (TIMER0_COMPA_vect) // Timer/Counter0 Compare Match A interrupt service routine
- { i++;
- if(i=200){s++;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement