SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By jsavage
#135959
I'm looking to learn to code AVR chips. Which one, I don't know yet, I'll probably start out small. I was originally going to go with a PIC, but after some research, I've decided on AVR - the reasons being that they seem slightly cheaper, and the ASM instruction set seem a bit more intuitive to me. I'm going to start out with assembler. I'll get to C later, once I have a firm grip on the asm for the chips. Now my to my question: I'm on a mac, and I've had a hard time finding any information on programming AVRs from a mac. Can anyone out there that uses a mac to program in ASM point me in the right direction on which programmer I should get? The one on sparkfun is a parallel port adapter, which I won't be able to use. Help is appreciated, thanks.
By tld
#136048
Just curious... Why do you want to start out with ASM?

Also, even if you'd prefer starting with ASM, I'd still recommend getting an Arduino Uno. It'll give you some support to get up and running, and then you can take away supporting bits once you're comfortable.

Note that the Arduino-environment uses Sketches, which are really C++, which supports C, which supports ASM... I don't really see any reason why you shouldn't be able to do ASM in the Arduino environment.

That said, you should be able to get avrdude running with buspirate or pocket programmer, to program AVRs directly. The compilers come with the Arduino environment, but I'm sure you can find them standalone.

tld
By Ben Wallace
#136093
I also find that it is easier to abstract upward in complexity. I'm old,
and started programming in ASM. Sorta like latin.
Assembler is like driving a car with a four speed, You get to feel the metal
with your fingers. What I would like is an overview of the various USB style
programmers.
By jsavage
#144035
tld wrote:Just curious... Why do you want to start out with ASM?
I've been playing around with both the the past few months. C is great, don't get me wrong. But it seems like such a waste of programming memory to me for the majority of the projects I've been working on. Plus, I prefer to learn from the ground up and having both ASM and C in my pocket as tools puts me ahead of 99% of the programmers out there - if I'm unable to program a time sensitive application in C, I can jump in and take care of t with ASM. ASM takes more thought (and I enjoy that challenge), but there seems to be less of a support base for it out there (or rather, it's just harder to find), but in my opinion, it's my programming language of choice for micro-controllers. I now only use C sometimes to prototype code for a project to quickly get a proof of concept running and then go back and reprogram with ASM to slim the hex file up.
By stevech
#144099
Very good choice to do a bit of ASM before C, for microprocessors. Helps you understand the principles.
If you've not learned C before, do so first on a PC with console programs and a free compiler (not bloated Visual Studio). Then apply those language concepts to microprocessors. C++ for small memory microprocessors is doable, but arguably not advantageous.
By krphop
#155362
This thread is pretty old, but for folks looking to program/develop AVRs on Mac, and are looking for an IDE, try Eclipse. There's a avr plugin that adds avr-gcc support and seems to work well with avrdude.
By stevech
#155374
Atmel's Studio 6 for AVR and ARM - free. Based on free Microsoft Visual Studio Express IDE. Admittedly bloated, but many people know Visual Studio from C#, C++, VB.net.

I used Eclipse with Python. Eclipse was too non-intuitive and thus I avoid it.
By jernfrost
#156731
Hi, I know this question is old, but there might be others who check out the answers to this question much later. I wanted to do exactly the same as OP. I figured it out through a lot of googling and trial and error.

I wrote down how to program an AVR chip http://pluggerogkontakter.wordpress.com ... g-arduino/, and how to do assembly programming on it http://pluggerogkontakter.wordpress.com ... -mac-os-x/.

To provide a summary:
1. Get a USB AVR programmer which can do ISP (In system programming). There are lots of those.

IMPORTANT:
2. Since the Mac does not have a serial port and you have to use the USB port, the Mac simulates a serial port with a logical device which gets created under /dev/ on the fly when you connec the AVR programmer. You HAVE TO CONNECT IT! If it is not connected it doesn't show up.

3. You can find the serial port with ls /dev/cu.*

4. Download the following software:
* CrossPack - contains AVR dude and a whole host of programs needed to do AVR programming
* avra - AVR assembler which works on Mac, following ATMEL syntax
* vAVRdiasm - AVR diassembler. To check if everything was assembled correctly e.g. Not needed.
* AVRFuses - Mac GUI app. Not needed. But gives a nice GUI interface to avrdude.
* avr-assembly.tmbundle. Not needed. Lets you write AVR assembly code in TextMate. Need to set AVR_UPLOAD, and AVR_ASSEMBLER variables in TextMate

5. Look at your datasheet to see how you connect the 6 pins on your programmer to your AVR chip. It depends on the programmer. But usually you do not need to connect anything put the 6 pins of the AVR chip on a breadboard. The chip usually gets power from the programmer. The 6 pins are: Vcc, Ground, serial in, serial out and clock.

6. Upload the code with a line like this: avrdude -p attiny13 -c stk500v2 -P /dev/cu.usbmodemfa121 -U flash:w:"$AVR_UPLOAD_FILE.hex:i"
That line is from my TextMate AVR_UPLOAD variable. Here is an explanation of the switches:
-p say I am programming a ATtiny13 chip
-c say my programmer is compatible with stk500v2. The name of my programmer is actually AVR-ISP500 from Olimex.
-P says which serial port the programmer should use. This is just a logical one as there is not physical serial port on the Mac. It get created when you connect the programmer.
-U tells what to upload or download and where. flash:w means write to flash. :i means we are using intel hex format. This is what avra produces when it assembles.

You got to set the fuse bits (configuration bits) as well but you can read about that e.g. on the CrossPack website.