I'm going to to through the process of getting the simplest possible program working on a simple AVR chip. When done, the chip will blink an LED. From there we can move on to other stuff.
I'm going to use the Atmel ATTiny85 chip as an example, because I've used it for my last few projects.
Before you start, check out this link for equipment. You'll want a breadboard and jumper wires, whatever chip you decide to use, and a programmer that is compatible with that chip.
Since we're using a bare chip, you'll need to wire things to it. The best way is to use a solderless breadboard, as shown in the link above.
You'll also need some way to plug the programming plug into it. I have hand built a little 6 pin breakout board that I just hand wire into my boards, but this is a great alternative:
You'll need a programmer - USBASP is available on ebay for almost nothing (see above link again)
You need a programming environment - WinAVR or AVR Studio (I use the latter- use studio 4. The newer versions are a ridiculous amount of overkill unless you're developing large systems using advanced chips) Install WinAVR first, then AVR Studio. WinAVR contains the compiler, AVR studio gives you a nice environment to use it in.
For the first program, we're just going to cause an LED to blink with an ATTiny85 chip. Plug it into the board above and plug that into the breadboard, or plug the chip straight in and wire in an ISP socket, whichever you want.
The LED and a 150 ohm resistor will be wired between pins 4 and 5 (ground and output 0) on the ATTiny85 as shown.
Open AVR Studio 4, create a new project called "helloworld" specifying AVR Simulator 2 and ATTiny85 as your chip. Create "helloworld.c" and put this into it:
#define F_CPU 2000000 // 8 MHz clock
// set port B bit 0 to output
DDRB = 1;
PORTB = 1; // turn LED on
PORTB = 0;
Click on Build/Build. Hopefully it will compile without errors.
Go out to the DOS prompt and switch to the directory where you saved the project. There should now be a "helloworld.hex" file which is the compiled version of your little program. This needs to be sent to the chip using the programmer. With the programmer plugged into the chip, run this command from the command line:
avrdude -p t85 -c usbasp -U flash:w:helloworld.hex
avrdude should write the code to the chip, and the LED should immediately start flashing.
This week I decided I'd had it with all the other printers in my stable. The CTC is stable and decent but it just bugs me (can't st...
I have been building my own 3D printers for several years now and I'm pretty happy with what I have. But I have been keeping an eye on...
I recently put an E3D hotend on my i3 printer. I primarily print with PLA. It turns out that if you are going to print PLA, it's a good ...
I am using the modified box frame. The blueprint for this may be found here . It's cut out of 1/2" (12mm) plywood. Get 5 ply if...