AVR STUDIO (compiling C and running)

  • Thread starter Thread starter tenacity2986
  • Start date Start date
  • Tags Tags
    Running
Click For Summary
Compiling a C file in AVR Studio is straightforward, but running it typically requires a connection to hardware via JTAG. To view output without hardware, users can utilize a serial connection with a terminal program, especially if using printf statements. For simple output, an alternative is to connect an LED to a microcontroller pin and toggle it in the code. If hardware setup is inconvenient, consider using other compilers like GCC, Visual C++, or XCode for simpler programming tasks. Understanding the need for hardware is essential for running compiled AVR programs effectively.
tenacity2986
Messages
44
Reaction score
0
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
 
Engineering news on Phys.org
tenacity2986 said:
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

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:
#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
	{
		_delay_1s();
		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)
 
Thread 'I thought it was only Amazon that sold unsafe junk'
I grabbed an under cabinet LED light today at a big box store. Nothing special. 18 inches in length and made to plug several lights together. Here is a pic of the power cord: The drawing on the box led me to believe that it would accept a standard IEC cord which surprised me. But it's a variation of it. I didn't try it, but I would assume you could plug a standard IEC cord into this and have a double male cord AKA suicide cord. And to boot, it's likely going to reverse the hot and...

Similar threads

  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 29 ·
Replies
29
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
15
Views
10K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K