Programming an AVR

Electronics Computer Programming Q&A
Post Reply
User avatar
GoingFastTurningLeft
Posts: 163
Joined: Wed Sep 06, 2006 7:33 pm
Contact:

Programming an AVR

Post by GoingFastTurningLeft »

C code written in AVR Studio will allow me to export the compiled .bin or whatever so that I can upload it with TwinAVR (formerly WinAVR), correct?

It seems like such a simple question it's better to 'fish' for answers than dig for one.
stevech
Posts: 138
Joined: Mon Jun 05, 2006 10:27 pm
Contact:

Post by stevech »

AVR Studio from Atmel is primarily for writing assembly language programs.

The public domain GCC C compiler version for Atmel AVRs, winAVR or whatever its nam du jour is, can be added to AVR Studio just to use AVR Studio's editor and IDE.

In either case, a .HEX file is typically what results. That is placed into the AVR's Flash memory either with an in-system-programmer cable (ISP) or via a serial port connection to an AVR that has a bootloader installed. Newer yet is the use of JTAG to download code and set breakpoints for debugging using real hardware.

There are several C compilers for AVRs. Some have free limited size versions good for students and the like. Most are far easier to use and more AVR-tuned than GCC / WinAVR. I like Codevision.

There are other editors and IDEs too, such as AtmanECL and Programmer's Workbench.

All these topics are discussed at length on avrfreaks.net's forum.

Be aware too of zbasic.net. A real powerhouse.
User avatar
GoingFastTurningLeft
Posts: 163
Joined: Wed Sep 06, 2006 7:33 pm
Contact:

Post by GoingFastTurningLeft »

Thanks a lot! That's pretty much everything I needed to know to get started. I really have no interest in writing assembly. 8)

AVRFreak's newbie guide didn't go much farther into detail than using AVR Studio to simulate an assembly program.

I have an "SP-12" compatible Parallel port ISP wired up on my breadboard, as per the documentation included with TwinAVR (WinAVR). Everything looks good to go ahead, since it can correctly identify the MCU and read all the configuration/fuse bits.

Simple question though.... just because they're named 'fuse bits', they're still reprogrammable and not permanent, right?
wd5gnr
Posts: 104
Joined: Wed Dec 19, 2001 1:01 am
Contact:

Post by wd5gnr »

I looked at zbasic.net (usually use gcc which is great). Question is, can you use zbasic without the corresponding hardware? Or is it licensed or otherwise locked down to the zbasic hardware?
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Post by rshayes »

One caution in using the AVR.

The In System Programmer uses four dedicated pins on the chip to load the program. After programming, these can be used as I/O lines.

The programming mode is entered when the reset line is active when power is applied. If this pin is programmed as an output pin, the chip cannot detect the reset signal and cannot be reprogrammed with this type of interface. If possible, do not use the reset pin as an output.
Bigglez
Posts: 1282
Joined: Mon Oct 15, 2007 7:39 pm
Contact:

Post by Bigglez »

Greetings David H.,
GoingFastTurningLeft wrote: Simple question though.... just because they're named 'fuse bits', they're still reprogrammable and not permanent, right?
Correct. Although they are commonly called fuses, they
are reverseable.

The exception to this is if the AVR is set to use an external
oscillator (or crystal or resonator) and the hardware is not
present. The AVR will lock up, and require resetting with an
external clock oscillator and parallel (high voltage)
programming.

Another gotcha is that AVR chips are programmed for
an internal RC one meg oscillator from the factory. It
requires un-setting the divide by eight fuse on some models.

One final word of caution. The ISP clock for serial
programming must be set lower than one-fourth
the clock frequency, which is set to one meg by
default, so it's possible (likely) to get locked out if
the ISP and clock fuses are not set before downloading
code to the flash memory.

AVR studio set up allows these problems to be avoided.

Comments Welcome!
Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests