AVR STUDIO (compiling C and running)

  • Thread starter Thread starter tenacity2986
  • Start date Start date
  • Tags Tags
    Running
Click For Summary
SUMMARY

The discussion focuses on compiling C code using AVR Studio and running it on an AVR microcontroller. Users must understand that the AVR Compiler generates AVR machine code, which requires hardware to execute. For simple output testing, participants suggest using an LED connected to a microcontroller pin instead of relying on JTAG or serial connections. Additionally, alternatives like GCC, Visual C++, and XCode are recommended for those seeking simpler environments for C programming.

PREREQUISITES
  • Understanding of AVR microcontroller architecture
  • Familiarity with AVR Studio and its compilation process
  • Basic knowledge of C programming and embedded systems
  • Experience with hardware connections, such as using LEDs and resistors
NEXT STEPS
  • Learn how to set up and use the GCC compiler for embedded systems
  • Research how to connect and program AVR microcontrollers using serial communication
  • Explore Visual C++ for Windows development of C programs
  • Investigate XCode for developing C applications on macOS
USEFUL FOR

Embedded systems developers, hobbyists working with AVR microcontrollers, and anyone interested in learning C programming in a hardware context.

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)
 

Similar threads

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