A microcontroller does what you program it, does so quickly, and reliably. Microcontroller pins have multiple functions. A microcontroller takes some type of input.It makes a decision based on the software you have written. The outputs are changed based on the decision. When we look at the pin out of microcontroller we observe the pins whose names start with PD. We use Avr Programmer to program the avr microcontroller. For example You see eight of them total, labeled PD0 through PD 7 and this is a fantastic example of the 8-bit nature of these chips. Here PD stands for Port D means one of the input and output register. In these chips centers around 8-bits. A sequence of eight 1’s or zeros in different combination. You can turn on or off specific features and can also change one or more bits in a 8-bit register. When we want to change one pin you must address all eight in the register.
Know about AVR Programmer Working and How to Run an Application
Let’s take ATmega168 as a programmable microcontroller. It is a programmable microcontroller, it has a size limit of 16 kilobytes of programming space. In reality that’s 16 kilobytes of machine code. We can do a lot with this space. We need some type of hardware to get the code onto these chips. This comes in the form of an Avr Programmer.
Let’s discuss to write our own code for the Avr Programmer that uses the RISC architecture. We do this on a computer with x86 architecture. A necessary tool to accomplish this program is called a cross-compiler. It is quite possibly the best reason to choose Avr Programmer for development. It is an excellent tool chain available that can easily be installed on multiple platforms.
Mac users-Install CrossPack
Windows users: Install WinAVR
Linux users -Debian and Ubuntu users should install the GCC-AVR package which includes the entire tool chain.
AVR Programming software
Software-of-choice to run the hardware programmer is called AVRdude. After installing one of the tool chains above, we should already have this program. By going to a terminal window or the command prompt and type the following to make sure Avrdude –h. It shows the help screen. Look at some of the available atmel AVR programmer options.
Put the microcontroller on a breadboard and connect it to a power supply and a programmer. Program some software to send some example code to the microcontroller
AVR ISP Programmer
Here we focus on In-System Programming (ISP) which means that you can program the chip without removing it from the electronic project circuit.
A Direct avr isp programmer Parallel Access(DAPA cable) is an incredibly simple and cheap programming method. We can build one very quickly for a few bucks worth of parts, but the convenience comes with a few gotchas. You must have a parallel port onto computer, which that modern laptop and some modern desktops don’t have.
This connects to a computer using a DB25 connector. We use 1 kilo Ohm resistors on the SCK, Reset, MISO and MOSI pins for current protection. We should not use a resistor on the ground pin. At the other end of the ribbon cable we should use a connector housing with six slots and filling one of them with a blank so that we could keep track of the signals. It will be a better choice to use a 2×3 IDC connector and route the signals using the AVR ISP standard from Avr Programmer.
We can use an Arduino as a programmer. It is an ubiquitous with the embedded arm systems crowd. It is required to write an AVR avr microcontroller projects programmer sketch to the Arduino and make the programming connections.
The USBtinyISP is an In-System-Programmer based around an ATtiny2313 that uses a USB connection cable. You can build a circuit yourself and use a DAPA cable to get the programming firmware onto the chip. If you think you’re going to be serious about AVR development consider shelling out the extra bucks for a professional programmer.
Avr Professional programmers
The Ateml programmers are the gold standard level. These offer something that none of the other hardware we’ve covered before, and the ability to recover a chip that you’ve messed up. You want to use the reset pin as I/O then you will need to use High Voltage Parallel Programming to talk to your chip. At some point you’re going to screw up and you’ll need to recover a process, that helps offset the extra cost of a professional programmer device.
And it is possible to use an Arduino for High Voltage Parallel Programming to recover your AVR and use an AVR Dragon for pretty much and STK500 is a very popular board even though you need a serial port to use. It will have chip sockets, buttons, and LEDs for on-board prototyping and the dragon leaves options open with unpopulated socket footprints and it uses a USB connection.
We should at least mention the program MKII that offers ISP in the same way that the USBtinyISP, it also provides JTAG, debug wire.
The bootloader is not really a programmer and it’s just a way to get around using one. The Bootloader is a set of code already on your microprocessor chip, which handles basic input and output necessary to write your code into the chip’s memory. These take up programming space, but you won’t have to buy a hardware programmer.
Settingup Our Own Circuit
We need four things.
A microcontroller, power supply, programmer, display.
- Solderless breadboard
- Jumper wires
- ATmega168 microcontroller
- 78L05 voltage regulator
- 100uf electrolytic capacitor
- 10uf electrolytic capacitor
- 180 Ohm resistor
- A programmer
Let’s blink an LED as our first embedded program. It takes a few components: a power supply, microcontroller, LED and its current limiting resistor. Power supply consists of a voltage regulator that will take an input voltage above 7v and output a constant voltage of 5V. This circuit requires two filtering capacitors to act like storage tanks, to absorb small fluctuations on the power rail to provide a steady source of electricity to keep our microcontroller safe and happy. An output we are going to use an LED. It must include a resistor to limit the amount of current that will flow when the software lights it. Current limiting resistor used to get current would flow at levels that are unsafe for the LED, the microcontrollers.
The circuit schematic
This is a simple 5v regulator circuit using an LM7805 linear regulator and two filtering capacitors is on the left side and separated from the rest by a dotted box. Get some type of regulated 5v supply save yourself some time and use that.
The chip in the schematic is labelled as AVR-MEGA8. This ATmega168 that we’re using is pin-compatible with at ATmega8, means that you can swap one for the other and all 28 pins will be where they are supposed to be and will cause no issue.
There should be two 0.1uF capacitors for decoupling and filter out fluctuations on the power rails called noise. Between VCC and GND and the other between AVCC and AGND as close as possible to the pins. We should also put a pull-up resistor on the reset pin with letting an incredibly small amount of current trickle into the pin at a 5V level. The chip from resetting by accident when it’s floating not connected so there’s no clear 0 or 5V value.
Programming Our Test Circuit
Check all of your connections one more time based on the given circuit and let’s get ready to program the microcontroller.
Connecting to a programmer
- We need to make six connections in order to program
- Master In Slave Out (MISO)
- Master Out Slave In (MOSI)
- Reset (RST)
- Slave Clock (SCK)
It is true for any programmer that is using In-System Programming method. Even a standardized 6-pin header that we design into most of the circuits so that you can easily reconnect your programmer to a circuit board and update the firmware down the line. For example, we just use some jumper wires to make the connection possible. To keep in the back of your mind is to only use one voltage source when programming and should either disconnect the power to your circuit while programming do not make a connection to the voltage line on your programmer.
Connecting an Arduino as a programmer
Arduino as a programmer is super easy. Thing you’ll want to do is open up the Arduino IDE, then open the example software ArduinoISP.pde in the examples/ArduinoISP folder. Load it to your Arduino in the normal fashion. Then follow the directions for targeting an AVR on a breadboard. Choose one power source that is to say either connect the voltage on the Arduino board to your breadboard or connect the battery to the power supply we wired up. By doing both has the potential to damage your hardware.
- Provided LED should be flashing away quite happily at this point.
- You should get the message “258 bytes of flash verified” and “ avrdude done Thank you” Then you successfully programmed.
Lets try the programming command again using ‘-v’ in place of ‘flash: w: main. Hex’. It will just attempt to talk to the chip instead of writing to it.
Using this programmer and avrdude you can program any in-circuit serial programmable chip that avrdude supports. It does not do JTAG or High Voltage programming. One can re-program Arduino’s using this.