Porting code/project to an AVR microcontroller

15 Dec 2009

Over the past couple days I have been brainstorming simple ideas to use my MBED for prototyping it and tuning how everything would work.  I am a complete newbie to the microcontroller world and doing any kind of development with them is a first for me.  Firstly, I chose MBED because I was impressed with how fast it is to get up and going and that pre-ordering the production board was only $60 USD.  I also noticed how reusable the development board is by being able to drop new code onto the board and away you go =D

My question is, if I wanted to produce a widget for my friends to use how tough would it be to port code and the project over to say an AVR controller to reduce build cost after the prototyping stage is done?  I saw that sparkfun.com sells 8-pin AVRs for about $2.75 USD vs a $100 USD MBED board + materials cost for each widget.

Any advice?

16 Dec 2009

A couple of points.

1. You're comparing a bare CPU with a complete board. Why don't you check prices on a single LPC1768? Please also compare flash and RAM size and the set of peripherals (Ethernet, USB, ADC and so on).
2. AVR is an 8-bit MCU, mbed's LPC is a 32-bit ARM. If you don't need all features of LPC17xx there are cheaper and simpler LPC13xx or even LPC11xx (<1$ at 10k pieces). While cheap, they're still full 32-bit ARM processors.
3. The mbed libraries are mbed-specific, if you use them in your prototype then you will have to find analogs for AVR or somehow write your own. Are you up to the task?

So here's my advice: if you check all above and think that AVR will be enough for you, get an Arduino and do a prototype with it. Porting code from mbed to AVR will take twice as long as developing on AVR from the beginning, even though it's not as easy as drag-and-drop with mbed.

16 Dec 2009 . Edited: 16 Dec 2009

The LPC1768 is a "big" MCU, as opposed to the ATMega328— if you really need things like Ethernet, USB OTG, or CAN it is actually pretty reasonable.

The Cortex M0 core (the basis for the LPC11xx) should certainly mix things up a bit in this space.  It would be awesome to have an "mbed tiny" design based on this, that could be cost competitive with Arduino/Freeduino offerings.

16 Dec 2009

The IC's for an LPC1768 are about $7 in single unit quantities.

18 Dec 2009

I found the answer I was looking for in Chris Styles' notebook pages. I just wasn't asking the right question:

http://mbed.org/users/chris/notebook/prototype-to-hardware/

 

I did also find the LPC1768 on digikey.com. They have it priced out at $8.70:

http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=2556109&k=LPC1768

 

Thank you for all your responses. I hope this also helps anyone else

18 Dec 2009

As the other thread states, there are also the LPC13xx series, with fewer peripherals and cheaper. Depending on the use these may also offer an alternative.

20 Dec 2009 . Edited: 20 Dec 2009

If you want lower-cost NXP processors, look at LPC1342/LPC1343. The LPC1343 available for $3 from Future, 1-off, and it's more powerful than an ATmega328.

NXP produce a development board called the LPCXpresso (http://www.standardics.nxp.com/lpcxpresso/~LPC1343/) which has an LPC1343 and USB JTAG. They also offer a free development environment which uses JTAG to give quite sophisticated debugging, which may be helpful if you're a programmer (but new to micro-controllers).

If you are interested in low-cost, simpler devices, I'd recommend the AVR devices. You could use an Arduino for prototype development. The Arduino IDE is very simple to use and will drive In-Circuit-Programmers. IMHO, the Arduino libraries are even easier to use than Mbed (an experienced C++ programmer might prefer the Mbed libraries). I'd suggest starting with an AVR, and using the Arduino or AVR libraries from the start; it'll be less effort than porting.

You could even get going with Arduino using something like Lady Ada's Boarduino; you can get just the PCB for $5, and the parts should be under $10 (http://www.ladyada.net/make/boarduino/index.html)

The nice thing about the AVR range is the low-end devices, the ATtiny, start at $1 one off, and come in DIL packages (as small as 8-pins) to make it easy to prototype on stripboard. You could use an Arduino as a USB interface, much like the Mbed cookbook article, to program devices. You can write the code for ATtiny using the Arduino IDE. We made an Infrared remote control for a Nikon DSLR in a key-fob case using the Arduino IDE ATtiny and stripboard. You can even make most of an Arduino straight on a breadboard, no need for a PCB.

I'm investigating making a simple LPC1343 prototype without making a PCB. I'll report back if I get time, and make any progress.

HTH, GB-)