Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

AVR STUDIO (compiling C and running)

  1. Sep 17, 2009 #1
    okay i can compile the c file fine. but when i run it, its trying to connect through jtag and hardware. I just want to see the output of the compiled program!! any1 know how? thankyouu verry much
  2. jcsd
  3. Sep 18, 2009 #2


    User Avatar
    Science Advisor

    Are you aware that the AVR Compiler compiles to AVR machine code and needs to be run on an AVR microcontroller? If so (sorry, have to cover all the bases), and you're using a printf statement or two, that means that you need to wire up a DB-9 connector, hook it up to your computer's serial port, and use a terminal program to take input.

    If you don't want to go to all that trouble (or lack serial ports and/or a serial-to-USB converter), and you're just looking to do some kind of "Hello world!" thing, just hook up an LED and a resistor in series to one of the pins, and have it light up:

    Code (Text):

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

    #define F_CPU 8000000UL //change to whatever

    void _delay_1s(void)
    //1s delay routine
        int n;

        for(n=0; n<50; n++)
        {   _delay_ms(20);  }

    int main(void)
        DDRA |= 1 << PINA7;
        PORTA |= 1 << PINA7;
        for(;;) //toggle PIN A7 every second
            PORTA ^= (1 << PINA7);  //XOR existing value to toggle
    If not, and you're just looking for something to do a very simple program in, look into how to use the GCC compiler (Linux), Visual C++ (Windows, the personal edition is free), or XCode (Mac--also free)
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - STUDIO compiling running Date
How to test CST design studio for analyzing data errors Dec 19, 2016
Why isn't my code working? Dec 15, 2016
DC-voltage sweep @CST Design Studio Dec 1, 2015
Matlab Compiling Running (MCR) Sep 11, 2015
Compilers and Logic gates May 17, 2011