Category: "Tips"

The Great Microcontroller Showdown '10

12/28/10 | by Jfkfhhfj | Categories: Informative, Tips

Micro’s come in many shapes and sizes nowadays, what was once very simple and specialized comes in all sorts of packages with all sorts of peripherals and features. Over the year I’ve put together a healthy collection of many different platforms and devices and I’d like to share my experiences with all of them. I do not claim to be an expert of all the controller lines below, I work mostly with PIC and have a good amount of experience with AVR,I also work mostly in assembly and do little high level programming. However, I still have done plenty of research and I hope I can offer advice that helps.

The way i'm going to do this review is go over several important categories when choosing a controller, generally I see this as most important to least, however some things are interchangeable depending on the target audience and device.

Support
What type of support do outside communities offer/how good are manufacture documents
Programmers (including emulation)
How easy is it to get your code on your chip and to make sure it works.
IDE(s)
How easy is it to write your code.
Languages (including assembly and high level)
What the hell are you writing.
Cost
How big of a loan will you have to take to finish your death bot of doom.

General architectural things will be discussed throughout the review as well in non particular order. (I.e. I will be going on rants and diversions)

With all that said, let the games begin!


Microchip PIC

The first series i will be going over is my favorite. Microcontroller’s Pic architecture is very intuitive and great for hobbyists. It’s a very minimalistic approach to microcontrollers. Everything about a PIC is simplistic, the assembly, the programing, and the IDE. There is very little which is a hassle to do. For beginners, I always recommend PICs since i feel they’re the easiest chip to get started with. The PIC comes in many different varieties including the PIC10, PIC12, PIC16, PIC18,PIC24, PIC32 and DSPpic. The most commonly used lines are the PIC16, mid end 8 bit processor and their flagship PIC18 high end series microprocessor.

Support:
Microchip has always been about the hobbyists, they offer great support and they have tons of great documentation. I personally feel their data sheets are some of the best. Always well organized and very well written. They always supply good code examples in both c and assembly so you spend less time trying to interpret what they’re saying and more time programming.

Programmers:
By far the PICKIT is the best programmer available. It will program all of microchip’s products without hassle, has on board power source, its USB and very portable. Also the pickit supports debug features.

IDE:

There is something really nice about MPLAB, it’s a small download, and it works, very well. It’s a very bare bones ide, but it gets the job done extremely well. Everything is intuitive and whether you’re managing a huge project or writing a small assembly code. MPLAB just works. Simulation is a breeze as well; MPSIM works great and has everything you could ask for. The biggest gripe with MPLAB is that it is rather old and some ancient features will come back to haunt you. For a while if you weren't building in a project file path lengths had to be kept under a certain number of characters, this wasn't fixed until recently.

Languages:
Microchip’s assembly is very minimalistic, on most lines it doesn’t support fancy indirect calling, or software controllable stacks or sometimes even branch instructions(PIC16 has no branch), but for what it’s worth, Microchip’s assembly once again just works. It’s very intuitive as far as assembly goes. Although most people hate the idea of a working register I feel it defiantly simplifies things since we can address all SRAM with it. (no specialized move instructions). Interrupts are simple since there’s only one or two vectors. Indirect referencing is done via a INDF register and a FSR register (one hold the memory address, other holds the contents). Higher level series such as the PIC18’s have indirect referencing to program memory through table instructions but they can be cumbersome. The biggest downsides to PICs are the segmented memory banks. Although on the PIC18’s this isn’t much of an issue when you write small programs,on larger projects it can be a real pain in the butt.
Again I’ve done little programming with C, but microchip offers a limited C compiler for most of their micro lines. As far from what I’ve seen, it works and it’s C, what more could you ask for?

Cost:
Microchip is great when it comes to cost, if you’re a student they offer a hefty discount on their programmers and will send you free chips through their sample programs. Otherwise prices are pretty standard.

Links:
http://microchip.com/ - Microchip's Home Page
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002 - MPLAB download link
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en023112 - Sample device page
http://www.microchip.com/samples/ - Link to sample program
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PG164130 - Pickit 3 programmer

ATMEL AVR

AVR is an industry standard microcontroller and regarded as one of the best. If you want simply the most powerful microcontroller in terms of functionality, AVR is for you.

Support:
Atmel’s support is second to none; if you can manage their website you will find documentation on everything. These guys have some of the technically best datasheets out there. With that said, technically best isn’t always the best. Their datasheets can be a chore to read through at times, but you defiantly get the full picture. Also unlike microchip whom include all their supplementary data in their device datasheet, things like instruction set summaries are supplement documentation and you usually have to hunt them down. (That’s what Google is for). AVR also has generally pretty large communities behind them (*cough* AVRfreaks *cough*) As well, they’re the go to micro in industry and university.

Programmers:
*bangs head on desk* the most frustrating aspect of any AVR chip is programming the damn thing.
There is no one programmer from ATMEL that will program all their chips. Some use ISP some use JTAG some use god knows what. The best thing to do usually is grab a JTAG programmer off of ebay and stick to an ATMEGA series chip. Most AVR microcontrollers support several programming options, this is nice however can bit a bit confusing at time (see above :P). The most common interface is ISP which is your standard In-Circuit Serial Programming.AVRs also support JTAG and other high voltage serial/parallel programming algorithms.(check out the data sheets) You can buy the 40$ AVR Mkii ISP and be able to program most if not all of their stuff. Programming through ISP can be a nightmare especially if you set the wrong fuses and brick your chip (very easy to do). Also ISP is very finicky with the programming speed and sometimes doesn’t work. I’ve even had issues with JTAG. Many times if the proper power up sequence isn’t followed the chip will refuse to talk to the programmer. This is by far the worst experience with AVRs but once you figure out the kinks of whatever setup you have, it’s usually smooth sailing (until you F$*#K up the fuses).

IDE:

AVR study hands down is one of the sexiest worksuites available for a micro. It’s just sooo shiny. And then it crashes. But really, AVR Studio is a great IDE and it’s the complete opposite of MPAB IDE. It’s a bit of a PIA to download and update (requires registration and multiple service packs) but it’s a fully featured modern IDE. One of the biggest problems with MPLAB is how ancient it feels and looks, with AVR Studio this is not an issue. As an IDE it does everything you could want it to do, everything is intuitive and when emulating there are just some really nice features that blow any other IDE out of the water. It’s a great IDE, just wish they would iron out some of the bugs.

Languages:
AVR assembly is both its greatest strength and weakness. In terms of sheer power, the AVR assembler is unmatched and the language is almost flawless. However, there is a steep learning curve associated with AVR and it’s assembly language. This mostly has to do with how it’s memory is arranged and mapped.

AVR memory:
Like all processors we have our CPU, Ram and Rom. In an AVR our program memory is 16 bit long and that constitutes our word length, this program Rom is accessible through our Z pointer. (and our LPM and SPM instructions). We can use program memory to both store instructions as well as ROM lookup tables. By using the .db(Define byte) and .dw(Define Word) we can load Rom with values at assemble time. This is mostly due to the power of the AVR assembler and ability of the Z pointer to indirectly reference program memory. This is an extremely useful feature.
Now the AVR RAM is a bit peculiar. The SRAM is mapped linearly and broken up into sub blocks. We have a General Purpose Register (r0,r31), I/O space (Our IO ports and Special function Registers) and our Data SRAM (everything else). Data SRAM is where we hold our system variables and where the stack pointer resides. Another really powerful aspect is that with AVRs we can use our PUSH and POP instructions to load the stack with system variables as well as control program flow.
However there is a downside to this implementation. Depending what sub block we are addressing, determines which instructions we use. We can generally address any space with our GPRs, however if were loading to IO space we use the in and out instructions, and if we load to data space we use lds and sts. Moving between GPR is done via mov. If you program a lot with AVR, this actually isn’t too bad, and preferred in some cases (prevents data corruption). However, it’s all a gimmick. The memory space is completely linear, there is no reason you can use an out instruction to load to a GPR to data space, it’s the same memory and in some cases you can(play around with it its fun)! The only thing preventing you most of the time is the assembler itself. Because of all these different instructions to do the same thing it can get rather confusing (SBIS, SBRS). For beginners, I do not prefer AVR assembly and I think at times it can be really counter intuitive.
With a PIC, the memory space is linear. Although we have a working register W0, there is only one Mov instruction (From and To W.) which addresses all RAM.
With that said, AVR assembly is great if you know what you’re doing, it’s extremely powerful especially with things such as software stack and its indirect referencing system, but for novices it can bit a bit much.
C, is a completely different story. One way which AVR blows microchip out of the water is through its C compiler and general C support. Out of the box AVR studio works with C and uses a GCC compiler so for those Linux guys they’re covered as well. This is where Microchip could learn from ATMEL.

Cost:

Here is another gripe I have with AVR’s. And it mostly goes back to programmers. There really is no one programmer that does it all, and because of this the costs associated with developing with AVR chips can be quite high. If you use the ATtiny line, you need an ISP programmer if you use ATmega you need a JTAG programmer and if you use anything else, well good luck. Although programmers can be chopped together easily, it’s nice to be able to buy something from the company that you know works (Instead of relying on Chinese clones). Also ATMEL’s sample program is almost nonexistent, you gotta buy all the chips you use, So no love for students.

With that aside, the costs aren’t tremendous, you can get an ISP programmer for around 40$, and the chips themselves are never more than a few dollars. However I wish ATMEL made more of an initiative to make things a little bit friendlier.

Links:
http://www.atmel.com/ - Main website
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=ATAVRISP2-ND - AVR ISP Mkii programmer (for ATtiny Chips)
http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega48 - Sample product page
http://www.atmel.com/dyn/products/param_table.asp?family_id=607&OrderBy=part_no&Direction=ASC List of all their products and features.

*This concludes the part of the article of the chips I actually know a bit about, please only use the following for reference*

TI Launchpad MSP430

This is TI’s attempt at getting back into the minds of hobbyists. This line is meant to be cheap affordable and no frills. The actual processor is built around a simple but powerful assembly language and has very barebones peripherals. TI released an evaluation kit for the MSP430 called the Lanuchpad which main feature is that it only costs 4.30$ and includes theoretically everything you need to get started.

Support:
There seems to be a good amount of support documentation floating around, and TI does a decent job of providing a good amount of documentation. Ti is really trying to make a push into the hobbyist market and offers a wiki for their launchpad product.

Programmers:
Programming depends on the device but for the value line, programming seems to be done via a serial interface. The launchpad evaluation board has a programmer and emulator onboard, so that should be all you need to get going. It will also program other MSP430 devices and not just the value line.

IDEs:

TI provides a link to IAR embedded workbench, which works, most of the time. It’s a decent toolsuite, but doesn’t hold a candle to dedicated suites such as MPLAB or AVR studio. (and it just crashed on me... $*$#@!!!)

Languages:
I haven’t had much time to play with the assembly, but from what I see, it truly looks very “modern.” We have a very small instruction set, but we also have some really powerful assembler directives that allow control of the stack and the ability to easily create ROM tables. It’s the best of both worlds. It’s a really nice step in the right direction with a nice core.

Cost:
4.30$, its cheap and for that it’s worth it in parts alone, if you can get an IDE to work with it, it’s a great chip which has a lot of potential.

Links:
http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29?DCMP=launchpad&HQS=Other+OT+launchpadwiki - Launchpad Wiki
https://estore.ti.com/MSP-EXP430G2-MSP430-LaunchPad-Value-Line-Development-kit-P2031.aspx - Buy it
http://focus.ti.com/lit/ds/symlink/msp430g2211.pdf - Datasheet for value line chip

Parallax Propeller

This is quite possibly one of the most interesting processors I’ve ever come across. Parallax builds its processors around “Cogs” or miniature processor cores. Each processor has its own peripherals, shares IO and has access to main memory in a round robin fashion. A typical propeller has 8 cogs which can run at an impressive 20 MIPS, giving you a total of 160MIPS per chip. I’ve found that this chip is defiantly nice and very impressive especially coming from such a small company like Parallax, but I still have a hard time seeing exactly what its really good at. It seems the processor is much geared mostly towards game development (each core has its own video genorator).
There are also a few quirks you should be aware of. First off, there is no rom, so all programs are run off of the ram. Unless you have external EEPROM, every time you reset the chip your program is lost. Part of the startup routine includes looking for external EEPROM and automatically loading its contents into RAM. Another quirk is all the IO is shared via each processor core, not only that, IO control is OR’d with each COG, so things can get pretty messy. Really, you have to check out the documentation for this chip because it is very interesting.

Support:
Parallax is a very small company but their effort is the same as any other large companies. Their datasheet’s are pretty informative and they have just the same documentation you come to expect. Their website is pretty informative and easy to navigate and it’s a breeze getting everything you need to get up and going. However i've yet to find any real support online like there is for the other processor cores mentioned.

Programmers:
Programming of a propeller is done via serial and you can use any USB to serial adapter to do this. The one provided on their website is incredibly cheap and nice and compact. Because of the onboard bootloader, things are pretty no frills here.

IDE:

You can download the free Propellor Tool from Parralax’s website. This is a super simple IDE, again no frills, just what you need to get things working. The best thing about Propellor Tool is the sheer amount of reference code that comes with the IDE. You’ll have plenty of examples for both the SPIN language and assembly. Once you can figure out what you’ll use your chip for, you’ll have no lack of reference code to tear apart.

Languages:
The assembly is pretty standard and does everything you expect it to do however programming for a multicore chip is rather, interesting. Essentially each cog has its own RAM to store its program, while the main system RAM holds your main program. Using a SPIN command you can enable a new processor and you set the origin address of the assembly you would like it to load. On startup, the cog will take that code from the main memory and dump it into its ram. This usually takes a little while but allows each cog to independently run its own code.
If you don’t feel like dealing with that, you can use the high level SPIN language which is a combination of C, BASIC and some really interesting preprocessor directives. I haven’t used it much but you can do some really powerful stuff pretty easily. One of the interesting things is this processor support direct driving of a composite video signal and has instructions to generate text to any NTSC TV set. Pretty cool stuff for a little micro.

Cost:
The propeller is defiantly an expensive chip, but you’ll only need one and the chip is pretty much all you need to get going. If you want to grab a chip “programmer” and eeprom from parallax it’ll run you about 20$ shipped, which isn’t bad at all. So it’s an expensive chip, but that’s only because of the sheer amount of stuff you get in that little hunk of silicon.
Links:
http://www.parallax.com/ - Parallax main site.
http://www.parallax.com/propeller/ - General Information for the propeller
http://www.parallax.com/Store/Microcontrollers/PropellerChips/tabid/142/ProductID/332/List/1/Default.aspx?SortField=ProductName,ProductName - Buy a Propellor here
http://www.parallax.com/Store/Microcontrollers/PropellerTools/tabid/143/List/1/ProductID/398/Default.aspx?SortField=ProductName%2cProductName - Programmer here
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/WebPM-v1.1.pdf - Datasheet here

Arduino

Ardunino is a hit with the hobbyist community. Combine open source, with tons of support, tons of code, high level language and a super simple interface and Arduino is what you get. Arduino Is essentially a bootlaoder for the popular ATmega series of chips made by ATMEL. Arduino is nothing more than a wrap for AVR chips and a philosophy, provide the support and the hackers will come.
However, there is a dark side to Arduino, with the simplicity a high level language offers, it also brings forth hacktronics and some pretty shoddy engineering. If you’re someone with little electronics experience and you want something cool to play with, Arduino is for you. If you’re an EE who wants to learn microcontrollers I recommend Arduino AFTER you learn a more substantial core. Then you can use Arduino as a powerful development tool and not as a crippling toy. (Seriously what did you expect from someone who prefers assembly over C?)

Support:
Go on any major hobbyist website/hacker community and if you can’t find support for Ardunio you’re doing something wrong. Unlike the corporate driven datasheets and reference documents you will find hacker guides and tons of support from people who just love to hack. The Arduino website is chock full of information as well. This is the beauty of open source, the wealth of information.

Programmers:
Arduino is programmed via USB and usually when you get your Ardunio board it has a USB header on it which is all you need to upload your compiled programs.

IDE:

Arduino’s main IDE is a simple .jar program which is cross platform and extremely minimalistic. You write your sketches and compile them onto your Arduino and off you go. Nothing more is needed. Support for outside compilers is plentiful aswell. No matter what platform you run, you can program with Arduino.

Languages:
Arduino is prized for it’s C like language which is incredibly high level and very powerful. Open source libraries add everything from sound generation to image processing and everything between. Find your library, learn some simple commands and that’s all you need to get going with Arduino. If you actually care what’s going on, good luck(:P).

Cost:
A typical Arduino board will go for around 20$. Part of the Arduino philosophy is the idea of shields. Stack-able modules which connect to your main Arduino board and add features such as sensors and other peripherals. Shields can range from cheap to expensive depending on the functionality. Arduino is very affordable for anyone to jump right in and build some pretty impressive electronics.

Links:
http://www.arduino.cc/ - Main website
http://arduino.cc/en/Main/Software - Programmer
http://www.sparkfun.com/products/9950 - Arduino Uno, latest board

ARM


The holy grail of microcporcessors. These processors are in everything from your Iphone to your toaster. However you’ll never find an ARM chip. ARM simply licenses its processor core for companies to modify at their leisure. At its heart ARM is a general purpose RISC processor.

Support:
The first part of developing with ARM is finding a vendor and figuring out what support they offer. ARM platforms can range from elaborate to very simple and can be an evaluation kit or just a dip chip. Typically ARM processors interface through JTAG or serial and you upload binaries into the Rom.

Programmers:

Programming is typically done through JTAG or serial and varies from manufacturer to manufacturer (Hint, find one which works first)

IDE:
Varies from manufacture to manufacture, however anything that generates ARM binaries can be used (usually).

Languages:
Typically c is used when programming with ARM however an extensive assembly language is usually provided, I’ve yet to find an appropriate assembler.

Cost:
Developing with ARM can be a costly experience or it can be dirt cheap, it just depends on how much time you’re willing to spend banging your head against your desk and wondering why you can’t get the damn chip to work. Unfortunately, if you’re working with ARM you’re already provided with everything you need from whomever you’re working for. If you’re trying to work with ARM you have a lot of research ahead of you.
Links:
http://www.arm.com/ - main ARM website
http://mbed.org/ - Platform based around ARM Cortex m3 processor
http://en.wikipedia.org/wiki/ARM_architecture - Best source of information about ARM
http://www.st.com/internet/evalboard/product/250863.jsp - Really cheap ARM eval board.

X86
HAH!
http://www.intel.com/products/processor/manuals/
http://en.wikipedia.org/wiki/X86_assembly_language
Have fun..

So which is the best?

Honestly, there is no best, nor is there a worst. The best thing sometimes is just to pick a chip and just start working with it. What you should do is rather than pick the “best” or “easiest” chip, pick what works for you best. Also instead of learning what a chip CAN do, learn what a chip CAN’T do, because often times this is what will limit you the most. Understand a chip’s limitations so that when you come across them you know how to deal with them. In either case, happy programming!

I hope this article helped to shed light onto the subject of different processor brands out there. I know my knowledge isn’t complete so I hope anyone who would like to shed light on the caveats I skimmed over to do so. I will gladly add more processors to this list as I come across them and I look forward to updating the sections I glanced over. Even with these faults I hope this serves as a nice intro guide into the world of different processors.

Any questions comments or concerns, email me at Anthony.Tricarichi@sunysb.edu

 

S vs C

10/21/08 | by Jfkfhhfj | Categories: Informative, Tips

This post is going to start off a new category: Tips.

Posts in the tips category are going to be generally short and they wont be chronologically significant. They are just meant to demonstrate common techniques and/or common errors.

There are two letters that will absolutely devastate your code if your not careful, they are s and c. s and c are used in most bit orientated instructions (bcf, bsf, btfss, btfsc). They stand for Set and Clear or 1 and 0 respectively. When making your code and going over your logic, make sure you note what you are setting high and what needs to be set low. Reversing these two letter will utterly change your code, often for the worst. I've had code that went from useless to perfectly working by changing only one letter. A tip for debugging code, ALWAYS simplify your code first and then always check your bit orientated operations and make sure you're using the right instruction. With that in mind you will spend more time programming and testing and less time debugging.

 
February 2017
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28        

Ads by Google

Mcuplace.com Store!

This blog is dedicated to working with digital circuitry and the use of microcontrollers, small compact computers on a chip. I will be encompassing many techniques to develop projects, tools to use to write and assemble code and i will be sharing any projects i am currently working on. User feedback is a must! I do not know it all, hell im not even that experienced, but without a general place to get all the info needed i find it very hard to get into the world of microcontrollers without pursing a CE degree. So come one come all and enter the world of mystery and creativity!

Search

  XML Feeds

powered by b2evolution