Learning Microcontrollers  - Page 1
Forum section: electronics / general

author: stl
author_rank: Contributor
timestamp: May 20, 2011, 04:57:56 pm
content: I would like to learn how to program and use microcontrollers but I'm confusedI've read most of the topics here but didn't help much, I'm really starting from zero in this subject. Probably I won't never need this knowledge professionally but maybe for some personal projects like using sensors and switches to control something.I saw some cheap development boards in ebay that seem ideal for what I want like this one:http://cgi.ebay.com/Development-Board-kit-Atmega16-ATMEL-AVR-mega16-/190530275630?pt=LH_DefaultDomain_0&hash=item2c5c7d492eor this one:http://cgi.ebay.com/Development-kit-Board-ATMEL-AVR-Mega128-ATMEGA128-/250727266422?pt=LH_DefaultDomain_0&hash=item3a60827876I'm comfortable with C language, can you give an idea of what kind of software tools I could use with these boards? Could I use the manufacturer developer tools?Do you have any other suggestion without being much more expensive?Thanks

author: Simon
author_rank: Unknown
timestamp: May 20, 2011, 08:39:28 pm
content: you can use a good programmer (usually from the manufacturer) and a breadboard if you want. It's all down to what you want to do and how much gadgetry you want

author: stl
author_rank: Contributor
timestamp: May 20, 2011, 11:22:39 pm
content: I would like something simple and cheap to start with. I don't have any particular project in mind, just want to learn how to make the program, load it to the micro and test it.What attracted me on those boards is the fact that i have already in the pcb switches and leds to simulate an input and output.Thanks

author: Mechatrommer
author_rank: Super Contributor
timestamp: May 21, 2011, 01:17:35 am
content: the one with the removable chip you linked is nice. you can program an atmel and put it in another circuit. but dip only, for soic or qfp, you need an adapter for it. but can be easily build if you have the materials.dev kit like this is a good starter as you dont need an additional programmer to program the chip. arduino ide or avrstudio with avrdude can do the job.

author: bartek
author_rank: Contributor
timestamp: May 21, 2011, 06:55:44 am
content: If you are completely new to micros, definitely check out MBED:http://mbed.org/, their cookbook, examples and user community guarantees you will have a project up and running in a few steps, I had USB MIDI working in 5min!The plus side is you are working with a 32bit arm micro so you have a lot of power, the down side is that if you want to build something from scratch and don't want to use their module than its a lot harder than a PIC or something.

author: Unknown
author_rank: Unknown
timestamp: May 21, 2011, 03:59:45 pm
content: Quote from: Mechatrommer on May 21, 2011, 01:17:35 amSure, in the old days before in-system programming became popular. Don't see the point of plugging a uC in a different board for programming these days, just including a programming header on your target board is much more convenient.

author: Bored@Work
author_rank: Super Contributor
timestamp: May 21, 2011, 05:48:34 pm
content: Quote from: stl on May 20, 2011, 04:57:56 pmThe world is full of AVR development boards. As long as the board is of reasonable quality it really doesn't matter what you chose as a beginner. There is enough stuff in an AVR, or any other up-to-date microcontroller, that you can be busy for ages just learning all the on-chip periphery.There are a gazillion ways to program an AVR. With AVRs I prefer the following programming techniques in that order.1) ISP SPI (available on almost any AVR),2) JTAG (available only on larger AVRs, programmers are typically more expensive),3) PDI (only on the XMegas),4) TPI (only on some of the more obscure ATTiny's, must ATTiny's use ISP instead),5) bootloader (there are many different types)6) High-Voltage serial or parallel programming (this is from the stone-age and can't be done in-system, not fun)Note that using a bootloader is almost my least popular programming technique. To get a bootloader into an AVR you need to have a normal programmer first. The chicken-egg problem.Exceptions: You buy an expensive AVR where someone already programmed a bootloader into. The prices for these are inflated and after buying a few you have spent so much you could have bought a good programmer. The second exception are some of the USB AVRs, as they come with a bootloader from the factory.And High-Voltage programming? Mehhh. Some market it as the great way to rescue a bricked AVR. I say, just avoid bricking an AVR. But if you brink one, get a new one. It is a waste of time and often also money to do AVR high-voltage programming.I highly recommend to use an original Atmel programmer (programmer == programming hardware), especially for beginners. No clones, no shit from some Chinese fly-by-night-operation, no ghetto-style DIY programming cable, no contraption the guy around the corner suggests, no on-board programmer on the dev board of dubious quality, no stuff you found in some garbage bin. Yes, they work sometimes, for some people. But I promise you, if such junk doesn't work for you, you will spend an endless amount of time fighting the problem and ripping your hair of. $35 for an original Atmel AVR MkII ISP programmer then won't look so bad any more.Again, don't fall for clones. Just because some company uses the same enclosure in the same color and pretends to deliver an MkII programmer doesn't mean the junk will work.Get a dev board that has an ISP interface, or at least all ISP pins should be available, and not unduly loaded by external periphery. I prefer the official 6-pin ISP connector, but especially cheap Chinese boards like to have the old 10-pin ISP connector. Then you need to build an adapter.Regarding programming software, there are only few usable, however not perfect, classes of programming software.1) The original Atmel programming software (typically part of AVR Studio, Windows only, except the FLIP programming software, which is anyhow shit)2) avrdude (many operating systems)3) dfu-programmer (if you need a working replacement for FLIP, which is for a particular kind of bootloader, called DFU)Don't get lured into programming software shit just because it has a GUI. Stay away from PoS like ponyprog and other rubbish. Again, the PoS works for some people some time. But if it doesn't work for you, you are toast.The worst combination is a dubious programmer with dubious programming software. Especially as a beginner you won't know where the problem is. The programmer, the programming software or your code. Using a trusted and tried programmer and programming software takes two factors out if the equation.C compiler: There are good commercial compilers available, an OK free compiler (GCC based, several variants, see below), and at least one rubbish commercial compiler (MikroE C).Free GCC compiler:WinAvr is a pre-made AVR GCC for Windows and can be integrated into AVR Studio 4 and 5."Toolchain" (what a rubbish, unimaginative name), is a Windows AVR GCC hacked by Atmel in unknown ways, and comes with AVR Studio 5. But AVR Studio 5 has a general problem: Most of it doesn't work. My recommendation, if you want to work on Windows, stay away from Studio 5, and instead use Studio 4. Studio 4 requires you separately find, download and install WinAvr.avr-gcc is the GCC version for Linux and Unix systems. Always build your own avr-gcc if you work on Linux or Unix. The ones that typically come with Linux distributions are outdated and miss important patches. Look for the "bingo600 scripts" if you want to build your avr-gcc on Linux.IDEs:Atmel has an own free IDE. They only support Windows. The working, but mediocre and boring IDE is the already mentioned AVR Studio 4. Their latest IDE is the fucked-up AVR Studio 5.In general you can use any IDE you like, as long as the IDE allows to integrate a compiler. Programming is a problem, because the only programming software Atmel officially supports is the one coming with AVR Studio. Some people therefore use their own IDE and hop over to Studio if they need to program. Deep down hidden in the Studio distribution are a few command-line versions of programming software. Some integrate those in their Windows IDEs.On Linux or Unix it doesn't matter what you use, because Atmel gives a shit about Linux/Unix programmers. Use what you like and know, use a tool called Mfile to generate a Makefile for managing compilation, and use avrdude as programming software.And a final hint:As a beginner, do not mess with the fuses until you have understood them. Really, really read the datasheet, word by word, notice the difference between an external crystal and an external oscillator, and don't mess the corresponding fuses up. Plan fuse settings ahead and tripple-check that you have got the right values. Even the descriptive fuse settings in AVR Studio have been known to be wrong. And the 3rd party online toolhttp://www.engbedded.com/fusecalc/is based on the same database.

author: stl
author_rank: Contributor
timestamp: May 23, 2011, 04:19:48 pm
content: Thanks for your feedback