AVR Programming: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 18: Line 18:
         {
         {
             PORTC |= (1<<PC0);  //LED on
             PORTC |= (1<<PC0);  //LED on
             _delay_ms(3000);     //3 second delay
             _delay_ms( 3000 );   //delay 3 second
             PORTC &= ~(1<<PC0);  //LED off
             PORTC &= ~(1<<PC0);  //LED off
         }
         }
     }
     }
    return 0;
}
}
</syntaxhighlight>
</syntaxhighlight>


== References ==
== References ==
* [https://www.obdev.at/products/crosspack/index.html CrossPack for AVR Development]
* [https://www.pololu.com/docs/0J51 AVR Programming Quick Start Guide]
* [https://www.pololu.com/docs/0J51 AVR Programming Quick Start Guide]
* [https://jawher.me/2014/03/21/using-xcode-avr-c Using XCode for AVR C Developement]
* [http://www.instructables.com/id/How-to-get-started-with-Eclipse-and-AVR/ How to get started with Eclipse and AVR]
* [http://www.instructables.com/id/How-to-get-started-with-Eclipse-and-AVR/ How to get started with Eclipse and AVR]
* [https://www.obdev.at/products/crosspack/index.html CrossPack for AVR Development]
* [https://github.com/osx-cross/homebrew-avr Homebrew AVR Toolchain]
* [https://github.com/osx-cross/homebrew-avr Homebrew AVR Toolchain]
* [http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_GCC_Toolchain The AVR GCC Toolchain]
* [http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_GCC_Toolchain The AVR GCC Toolchain]

Latest revision as of 05:29, 26 February 2018

ATMega32 IO

//ATMega32AVR.c

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    //DDRC = 0x01;
    DDRC |= (1<<PC0); //PC0 as output
    
    //DDRD = 0x00;
    DDRD &= ~(1<<PD0);//PD0 as input
    while(1)
    {
        if(PIND & (1<<PD0) == 1) //when switch on
        {
            PORTC |= (1<<PC0);   //LED on
            _delay_ms( 3000 );   //delay 3 second
            PORTC &= ~(1<<PC0);  //LED off
        }
    }
    return 0;
}

References