Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * GccApplication12.c
- *
- * Created: 3/26/2019 4:59:06 PM
- * Author : dspuser
- */
- /*
- #include <avr/io.h>
- #include <avr/interrupt.h>
- void init_led(){
- DDRB |= 1<<0; //pb0 as output
- }
- void led_toggle(){
- int k=0;
- while (1) {
- if(k%2){
- PORTB |= 1<<2; //led on
- k=0;
- }
- else{
- PORTB &= ~(1<<2); //led off
- k=1;
- }
- }
- }
- int main(void)
- {
- init_led();
- init_timer();
- while (1)
- {
- if(timer_match()){
- led_toggle();
- clear_flag();
- }
- }
- }*/
- #include <avr/io.h>
- #include <avr/interrupt.h>
- volatile uint8_t count;
- int main (void)
- {
- DDRB |= (1<<0); //PD6 as output
- TCNT0 = 0;
- count = 0;
- TCCR0 |= (1<<CS02) | (1<<CS00); // PRESCALER 1024
- TIMSK = (1<<TOIE0);
- sei();
- while(1) {}
- }
- ISR (TIMER0_OVF_vect)
- {
- if (count == 31)
- {
- PORTB ^= (1<<0);
- count=0;
- }
- else
- count++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement