AVR STUDIO (compiling C and running)

  • Thread starter tenacity2986
  • Start date
  • Tags
    Running
In summary, the user is able to compile the c file without any issues, but when they run it, it tries to connect through jtag and hardware. The user is only interested in seeing the output of the compiled program and is asking for advice on how to do so. Suggestions are given for using a DB-9 connector and a terminal program, as well as an alternative method using an LED and a resistor. If the user is looking for a simple program, they are directed to use the GCC compiler, Visual C++, or XCode.
  • #1
tenacity2986
44
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
  • #2
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)
 
  • #3


I can understand your frustration with wanting to simply see the output of your compiled program without having to deal with the complexities of JTAG and hardware connections. In order to do this, you may want to consider using a simulator or emulator within AVR Studio. These tools allow you to run your program without the need for physical hardware, giving you a more streamlined and efficient way to test your code and see the output. Additionally, you may want to check the settings in your program to ensure that it is set to run in simulation mode rather than trying to connect to hardware. I hope this helps and good luck with your project!
 

Related to AVR STUDIO (compiling C and running)

1. What is AVR Studio and how does it work?

AVR Studio is an integrated development environment (IDE) used for programming and debugging microcontroller-based applications. It provides a user-friendly interface for writing, compiling, and debugging code for AVR microcontrollers.

2. How do I compile a C program in AVR Studio?

To compile a C program in AVR Studio, you first need to create a new project and select the appropriate AVR microcontroller. Then, you can add your C files to the project and click on the "Build" button to compile the code. The output of the compilation process will be displayed in the "Output" window.

3. Can I use AVR Studio for running my C programs on an AVR microcontroller?

Yes, AVR Studio allows you to run your C programs on an AVR microcontroller. You can connect your microcontroller to your computer and use the "Run" button in the IDE to download and execute your code on the microcontroller.

4. What is the difference between compiling and running a C program in AVR Studio?

Compiling a C program in AVR Studio involves converting the human-readable code into machine-readable instructions that can be understood by the microcontroller. Running a C program, on the other hand, involves executing the compiled code on the microcontroller to perform the desired tasks.

5. Can I debug my C programs in AVR Studio?

Yes, AVR Studio has a built-in debugger that allows you to step through your code, set breakpoints, and analyze the values of variables during runtime. This can help you identify and fix any errors or bugs in your program.

Similar threads

  • Programming and Computer Science
Replies
0
Views
358
  • Computing and Technology
Replies
6
Views
1K
  • Programming and Computer Science
Replies
29
Views
2K
  • Nuclear Engineering
Replies
6
Views
1K
Replies
8
Views
1K
Replies
6
Views
1K
  • Electrical Engineering
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
17
Views
1K
Replies
15
Views
5K
Back
Top