Hacker News new | past | comments | ask | show | jobs | submit login
ARMing a Breadboard – Everyone Should Program an ARM (hackaday.com)
130 points by ck2 on Oct 10, 2015 | hide | past | favorite | 69 comments



If you're interested in low-level code (assembly, JITs, Forth, etc.), note that official documentation for the ARM ISA has considerable encumbrance. It's not like most architectures where you just go to the manufacturer's website and download a PDF of the programming manual; ARM makes you register an account and agree to a rather restrictive clickwrap license (something to the effect of "you're only allowed to use this manual to support our products, not to compete with us").

This seems to not be common knowledge. Maybe the atmosphere of typical ARM applications is already so buried under NDAs that nobody cares, or maybe people just punch "ARM Architecture Reference Manual" into Google and grab one of the many slightly-outdated copies that are floating around on .edu servers. But I found it pretty surprising after seeing how widespread ARM is in "open" hardware.


The situation still isn't great, but this has gotten better over time with the documentation on infocenter.arm.com, which Google usually pulls up as a top result when you search for various ARM instructions.

For example, Googling for "arm tbl" brings up this: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....

which contains links to the rest of the AArch64 instruction set. The documentation has scary "Superseded" notices, but it's all basically accurate and it's enough to do low-level programming.


It's only got the "Superseded" notices because it's an old version, if you browse to the latest one in the menu on the left they're not there.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....


That's good to know. I hope it's a sign of things to come. I've been hoping for RISC-V to take off, but even being optimistic, that's probably 3+ years from being orderable on Digi-Key.


or maybe people just punch "ARM Architecture Reference Manual" into Google and grab one of the many slightly-outdated copies that are floating around on .edu servers

That's what everyone does, and AFAIK the ARM ISA documentation is public. The lower-level details to do with the core hardware itself/how to synthesise the core are NDA'd, however.


That shouldn't encumber most people though. How many people who don't already know that have the skills to seriously compete with ARM? Probably none.


Historically, it hasn't really taken "serious competition" to invite threats. There's a reason that the best-known open-source ARM implementation explicitly only targets ARMv2 (which dates from the days when the "A" stood for "Acorn") [1].

That said, people who just want to play with ARM-based hardware can get pretty far by leaning on the GNU support and third-party documentation (there are some Game Boy Advance documents that cover the ARMv4 instruction set, for example).

[1]: http://opencores.org/project,amber


I too am often surprised at how often people reach for an Atmel 8 bit AVR chip rather than an ARM. It is a testament to the momentum that Atmel built, the avr-freaks community and the amazing cost effectiveness of it all.

But now we're seeing ARM chips with built in clocks, and fewer base components required and I think the end of that AVR dominance is on the horizon. And that is why Dialog is buying Atmel[1].

Getting started with ARM is easy with one of ST's Nucleo boards (which are kinda Arduino Shield compatible, the biggest issue I have hit is that i2c at 3.3v is an issue on some boards). Their Discovery boards are even more capable but can be a bit more work to breadboard with.

Once ARM put out a supported GCC on launchpad.net it really made it easy to get a development environment up (no more crosstool or other package for building a cross compiler).

[1] http://fortune.com/2015/09/21/dialog-buying-atmel/


I'm using a PIC12 in product that replaces an existing one. At Volume Pricing 8 Bit PICs are pretty much incomparable to ARMs. A quick check on Digikey shows that for 10000 pieces, the cheapest 8 Bit Micro is a PIC10 - 35Cents/Unit (that's for today only). ATTiny is about 2 Cents more but that can change. The cheapest 8051 from Energy micro is in the same range as well.

The cheapest ARM Cortex M3/M0 or even a ARM7 is $1+. When you are shipping products (and not doing a hobby project), BOM cost is a major factor. If you sell a Million Units each with a micro in them, the cost difference is about $700,000. Even keeping cost aside, size matters. The smallest 8 Bit micros from Atmel or Microchip or any 8051 is around 3x3mm. Most ARM micros are much larger.

Rule of thumb that I use is to pick the micro by function, price and size. Sometimes a 8-Bit micro is more than enough for the job. Buying something that costs more, bigger in size and for which the MHz is not an advantage is an overkill.

Having said that, a companion product that also working on requires the MHz and so, a Cortex-M3 fits perfects there.


> At Volume Pricing 8 Bit PICs are pretty much incomparable to ARMs. A quick check on Digikey shows that for 10000 pieces, the cheapest 8 Bit Micro is a PIC10 - 35Cents/Unit (that's for today only)... The cheapest ARM Cortex M3/M0 or even a ARM7 is $1+.

I don't think that statement reflects the situation today.

Cost differences at the low end have become increasingly narrow, where they are present at all. Using just Digikey pricing at 10k, as above, it's easy to find M0/M0+ parts in the range of $0.40--$0.50/ea at 10k.

> The smallest 8 Bit micros from Atmel or Microchip or any 8051 is around 3x3mm. Most ARM micros are much larger.

These parts are obviously available in a range of package sizes, but the smallest M0+ MCUs are also 3x3mm.


Could you please provide links [to DigiKey]?


Digikey has a pretty good web site for search, start with ARM M0+ and then select for what you want. I picked the 3x3MM QFN package as a selector and got a number of Kinesis parts, here is one that in 100 unit quantities is .50 each. In 10K I'm sure that is under 40 cents. http://www.digikey.com/product-detail/en/MKL03Z8VFG4/MKL03Z8...

This particular part 8K flash and 2K RAM. Now the M0+ is better for these low end parts because it has the Thumb instruction set which gives it better code density than the original M0


Thank you, will do :)


The cheapest ARM on Mouser is the same price: 0.35/part for 5k in an SOIC-8 (6x6mm). ARM chips are available in 2x2mm chip-scale packages.


Most hobby electronics projects aren't really CPU limited though, so using ARM doesn't really bring relevant advantages. Having a standard platform, including the peripherals like PWM/ADC/timer etc which are going to vary wildly between ARM implementations, is far more important for people starting out and are trying to solve their problems via Google.

The 5V chips are also better at taking punches from miswired projects.


My experience is that most hobby projects are RAM limited when people are using the AVR chips. Whether its trying to hold a copy of an LCD view, or any sort of moderate data structure. The ATMega328 is 8K of RAM. The M0+ chips seems to all come with 64K of RAM, and given that folks are writing in C/C++ rather than Assembler that is quite helpful.

I agree with you on the general tolerances to abuse though. I've filled out a couple of surveys sent to me by semiconductor folks (I often get one after attending a free training session) and I've mentioned several times that a short/overvoltage hardened chip would be a useful thing for me. You can do that with off chip parts but since manufacturers are wondering what to do with an abundance of silicon surface area to distinguish their products, I continue to suggest that would be one way.


> The ATMega328 is 8K of RAM

No, just 2K. [0]

> The M0+ chips seems to all come with 64K of RAM

That would be 8K. [1]

[0] http://www.atmel.com/devices/atmega328.aspx

[1] http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1817?sc=...


Thanks, I was talking to the Atmel Tech On Tour folks today and the part I'm really interested in of late is the R21 which has both radio parts and the M0+ in a tiny package.

It has up to 32K of RAM and 256K of flash [2], the larger Cortex chips have the big RAM numbers as you note.

[1] http://design.avnet.com/axiom/atmel-sam-r21-atmel-cortex-m0-...

[2] http://www.atmel.com/Images/Atmel-42223-SAM-R21_Datasheet.pd...


I agree with this take on it. I either find myself using an Arduino or other cheesy AVR board, or a "serious" FPGA platform. There never seems to be much demand around here for mid-grade controllers or SoCs. If I can't get the job done with an Atmega256, I'll drag out the heavy artillery.


Avr devtools are also fantastic since they licensed the Visual Studio shell.


Very much yes, if for no other reason than their automagic conversion of . to -> as needed for classes. It's a tiny thing, but when you're dereferencing a lot of classes, needing to hit one convenient button is nicer than three.


One of the reasons that 8-bit AVRs are still popular is that the architecture was specially designed for C - compared to many other popular 8-bit microcontrollers, it has a C-style stack, lots of registers, and low latency for most instructions. The 8-bit PICs are much less amenable to C compilers.

I also use the ST micros for most of my projects, but the AVR is also a great device with a well supported toolchain - I think it's generally easier for most beginners due to easy to use peripherals and simpler clock trees than the ST chips, while still being production-ready.


For your i2c issue, the translation circuit is just a couple MOSFETs and ensuring both sides of the converter have their pull-ups.[1] Bit annoying when you're dealing with the circuit, but there are worse problems to be had.

[1] http://playground.arduino.cc/Main/I2CBi-directionalLevelShif...


That it a good solution, and in the case of the ST Micro chips the i2c lines can be pulled to 5V without issue, but in terms of compatibility Arduino shields which use i2c rarely pull them to 5V with weak pullups, expecting you to do that with the chip instead.


The documentation and ease of use of Atmel peripherals, and the electrical robustness of the chips, is something I like. Don't need an ARM to blink some LEDs when a sensor triggers. For ARM, I like both the OpenCM 9.04 ($9 board) and teensy 3 ($19 board.) Both of them can take 100 mil headers and be breadboarded if needed.


With a development board: yes. But if you want to do hack something on a breadboard or make your own PCB it is really convenient to have THD ( through hole device ).

The ARM used in the article is the only TDH available AFAIK.


Breadboard, yes, but if you're making your own PCB, I'd argue that SMD for the micro is easier (not to include BGA, but everything with perimeter pins, I think SMD is easier, even for the home hobbyist).

For SMD-only parts, there are SMD to DIP adapters readily available to let you use them on breadboards; for relatively low-frequency digital work, there's no problem using them, so being available in through-hole isn't a practical advantage.


And the "winner" is something like the Teensy which is an SMD part but its mounted on a board that gives it pins like a DIP chip.


NXP makes a smaller LPC that's also PTH, the LPC810. It's only 8 pins, but it looks a lot sexier for certain designs than the ol' standby ATtiny85, because it's got things like built-in i2c.

Oh, and with a mild amount of bravery, soldering SMD components isn't that difficult. A cheap toaster oven that you know damn well will never ever ever be used for making food again can do a decent enough job of doing the reflow for you.


My go-to for applications that don't need more than an 8-bit MCU is PIC and 8051. Quirky architectures, but they're also cheaper in large quantities.


I use 8051 for anything I do 8-bit as well. There are an almost infinite variety of speed/memory/peripheral combos available, still comes in hobby-friendly packages, and vast libraries of code and solid dev tools.

Never could stomach PIC. 8051 is 'quirky'; PIC is 'wtf?'. YMMV.


You can buy Arduinos on Aliexpress for USD1.80[1] and there are no comparable offers for ARM boards.

[1] aliexpress.com/item/Free-Shipping-Nano-3-0-Controller-Board-Compatible-with-Arduino-Nano-CH340-USB-Driver/2021663360.html


I bought 5 Arduino Uno R3 clones for $2.39 a piece off AliExpress and they were pretty good apart from shitty soldering on the headers.

They fill the "can't be bothered to read the 500 page long datasheet" niche for me nicely. I remember having to get along with datasheets and simple programmers and writing PIC assembly back in the 1990s and I'm glad that time is gone.


That's not true. They are just hidden.

Stm8, $1.28 http://m.aliexpress.com/item/32351992629.html

Stm32, $3.06 http://m.aliexpress.com/item/1568685935.html

Edit: my phone did a stupid.


Nice! So there is basically no reason to buy Atmega anymore (for me, at least).


The only reason is network effect.

Most "shields" and devices are tested and libraries made easily available for Arduino/Atmel 324P. Going to ARM means having to rebuild some of your toolkit, or finding it.

But again, it's ARM. And the "more expensive one" is 32bit.


But perhaps the largest hurdle is that most of the chips are surface mount devices.

This used to be a deterrent for me, but these days I just whip out my ExpressPCB and make a breakout board for the part that I'm interested in playing with. The price is really manageable. Typically my breakout board includes a few basic goodies such as decoupling caps, and a 3.3 V regulator.

But I appreciate the simplicity of being able to just breadboard something.

One reason that this works so well is the chip has a built-in serial bootloader.

That's a nice touch.


This is really cool. One cautionary thing though. I think that because of breadboard capacitance if you try any sort of high frequency stuff on the breadboard (like >= 10MHz) you'll get all sorts of weird effects. (This is just a breadboard problem that occurs at high frequencies, not an ARM problem).

I'm just an amateur in this area, so if someone who is more knowledgeable could confirm or deny with I wrote above that would be great.


1. Others estimate higher max frequency. This one's on the high side of estimates:

http://dangerousprototypes.com/2011/12/05/breadboard-limitat... [might have to ask EE friends about transmission line termination at those frequencies]

2. See also this video (and comments on video) where they measure:

https://www.youtube.com/watch?v=6GIscUsnlM0


Alternatively the STM32F4 Discovery Board and STM32F29 Discovery Boards, are both really good too.

I think the STM32F4 board is around £12 if I recall correctly.


This thread, which includes contributions from some very skilled ARM hackers, has been a true delight to keep up with lately:

https://boards.openpandora.org/topic/5600089-jumping-into-ar...

Jumping into ARM assembly .. with notaz' help!


So if you have a breadboard and a USB to serial adapter, you could build the bare bones version of this for about $6 and maybe break the bank at $15 if you had to buy everything.

I've got a usb to serial adapter just sitting here, definitely trying this project for just $6

Wish it only needed 5V supply, I have endless phone chargers laying around from 500ma to 2a


If you don't have the cable, an arduino uno also works as a usb to serial adapter.

https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

To make 3.3V out of 5V you can use a voltage regulator.


If you want to do anything even semi-reliable with this thing you'll want a regulator on the board anyway. Wall warts are notoriously noisy.


This. New switch mode ones are crappy, really crappy!

I have a stash of old linear ones that aren't fortunately. Worth their weight in gold.


Thankfully, a circuit for dropping the 5v input to 3.3v is really easy to build. It only requires a pair of capacitors and a 3.3v regulator, only about $2 of materials total.


You can also use a voltage divider if you are willing to suffer a bit of leakage current. That's just 2 resistors.


The linear regulators we are talking about are basically voltage dividers with feedback. They aren't significantly more efficient than your design, though they are ton less noisy.


While at peak current, the efficiency of a voltage divider is the same as a linear regulator, at lower currents a voltage regulator has significant benefits. This is because the quiescent current used by an unloaded voltage regulator can be very low (500nA for the TPS783!), while for a voltage divider to be sufficiently "stiff" its quiescent current should be about 10X the max load current. As a lot of microcontroller applications alternate between a low sleep current (several uA) and bursts of high run current (several mA), a voltage divider is significantly (>10000X!) more power hungry then a linear regulator in practice, even if the worst case efficiency for both is closer.


Because of that feedback, you get to use your load as the lower half of the divider, so the total current drawn from the source is the load current plus a few microamps for the regulator's internals.

In the passive voltage divider circuit, if the load varies its current draw, you have to have a resistor in parallel with the load so that the total current through both the load and the resistor doesn't vary significantly (where "significant" is derived from your tolerance for voltage variation).


There are very good TI Cortex M3 and M4 Tiva Launchpad boards (for $12.99) and for the ultra low power applications the MSP432 cortex M4 launchpad boards (for $12.99) with very good documentation and support.


That's a nice little part, but it has very limited memory: 32 kB on-chip flash, 4 kB RAM. That's less than some Atmel ATMega-based Arduinos. The Arduino Due (an ARM CPU) has 512 KB flash, 96KB RAM.

To get more memory, though, you have to go surface-mount.


4 kB RAM + 32 kB flash is plenty for a lot of projects, assuming it's possible to execute directly from flash. Just attach SPI flash for extra data storage.


An an electronics hobbyist wannabe, may I please have the links for parts / assembling the 5v to 3.3v circuit needed to power this thing ?


If you've got a breadboard, just grab one of these and plug it into it.

http://www.aliexpress.com/item/MB102-Breadboard-Power-Supply...


Since you also need a USB-to-serial converter, either of these boards include onboard 3.3 V regulated power output, probably with enough current to run a microcontroller:

https://www.sparkfun.com/products/11736

http://www.adafruit.com/products/284

In addition, this is an easy to apply 3.3 V regulator chip, in a package that's compatible with a breadboard:

https://www.adafruit.com/products/2166


If you're interested in a higher-power version, I just used the SC189 3.3V switching power supply in a design of ours. It can supply 1.5A (provided of course your upstream power can too).

The datasheet (at http://www.semtech.com/images/datasheet/sc189.pdf) has several example circuits.


Look at the application notes for any LDO 3.3V linear regulator i.e., MCP1702. Or you can power it from a 3.3V USB Serial cable...


Others are suggesting power supplies, but I think you can just use a voltage divider from a 5V supply. Like maybe a 2.7K resistor followed by a 5.6K to ground?


It needs to be regulated, because the microcontroller draws varying amounts of current. But a simple regulator is just a three-legged IC and a capacitor.


Ah okay, I didn't realize that.


Just some technical info in this if anyone trips over this thread, consider the following diagram of a voltage divider:

http://pcbheaven.com/wikipages/images/voltagedivider_1235725...

The Rload and R2 are parallel resistors really so if Rload is really low which it is generally if it's doing anything then it will effectively shrink the R2 resistance (Rload || R2) and therefore voltage. Then whatever is connected as Rload won't get enough volts + current.

You can fix this to some degree by using very low values of R1 and R2 but then they start to sink lots of current as they are in series across the power supply and get hot so this becomes an efficiency problem. If you're really unlucky the magic smoke comes out or you touch one and burn your fingers emitting a nice bacon smell.

You can fix all of this with a single NPN transistor and a zener diode pretty easily but you might as well use a regulator IC then.

Analogue electronics is fun even if it does burn and explode in your face occasionally! My shit blows up all the time: http://i.imgur.com/GZBKblt.jpg


You really don't want to do that imo.


The STM32 dev boards already make this pretty easy. (Although setting up a free toolchain is a bit of a pain.)


Really?, it's pretty easy in my opinion on Debian/Ubuntu at least.

I just installed gcc and use openocd to program.

I'm fairly sure I just did "sudo apt-get install gcc-arm-none-eabi" for the compiler.

http://libopencm3.org/wiki/Main_Page is worth looking at too, in case you haven't seen it.


>I just installed gcc and use openocd to program.

Come on, there's a lot of 'just' there. It's not too bad if you just want to play with the discovery board, but there's very little documentation on how to use the discovery board as a programmer. The official docs for the discovery board don't give you crucial information about jumper settings, and I ended up having to download some bloated Windows tool from STM just to output a suitable .ld script for the STM32F030K6. I'm sure it's not as difficult as it used to be, but it's vastly less straightforward than setting up an AVR toolchain.

To be honest, the page you linked to contains no useful information. I can see that it's some kind of peripheral library. It doesn't look like it does anything in particular that StdPeriph doesn't already do (and 90% of example code uses StdPeripg). Plus the github page warns that the API is unstable. Again, compare to AVR. The arm tools are much better of course, but it's so much harder for a beginner to find answers to simple questions. E.g., can I reset an STM32F0K6 with only two pins using OpenOCD and the STLink programmer on the discovery board? (The answer appears to be yes, but it's not readily googleable.)


Maybe 3-4 years ago. With the Launchpad version of gcc for ARM controllers, OpenOCD and gdb, it is a breeze now.


It's very poorly documented compared to AVR. It's not even immediately clear from googling what the preferred tools are. Try googling "open source arm cortex m0 toolchain".


blue raincoat




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: