Author Topic: How are micros programmed in real world situations?  (Read 30331 times)

0 Members and 1 Guest are viewing this topic.

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
How are micros programmed in real world situations?
« on: April 09, 2015, 10:16:42 am »
Do they use C? Or even assembler?
I ask because I really enjoy low level programming and am trying to find real life applications I can focus on.
 

Offline cyr

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: se
Re: How are micros programmed in real world situations?
« Reply #1 on: April 09, 2015, 10:51:54 am »
In my experience it's pretty much all C, with perhaps a couple of lines of inline assembly here and there in very rare cases.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: How are micros programmed in real world situations?
« Reply #2 on: April 09, 2015, 10:53:11 am »
I would say over 98% of MCUs are programmed in some version of C.

Generally assembler is only used for 4 reasons.

Money
1) If you get the code as small and fast as possible you can get more functionality out of cheaper chips.

Necessity
2) For very small/limited micros, like some of the really cut down 4 or 8bit chip, the micro is just too simple to support compiled code.

Speed
3) If you run out of cycles to perform a function at the needed speed and don't want/can't change the hardware to something faster you can recode the function with inline ASM for more speed.
Sometimes programmers are forced into it by management who will not agree to a new hardware revision but keep wanting more features added.

Timing
4) Time critical applications, If you need absolute control over when things happen you can code down at the ASM level where you know how long instructions are going to take. 
« Last Edit: April 09, 2015, 11:00:32 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online EEVblog

  • Administrator
  • *****
  • Posts: 37740
  • Country: au
    • EEVblog
Re: How are micros programmed in real world situations?
« Reply #3 on: April 09, 2015, 11:00:23 am »
As other said, mostly C, with some inline assembly for speed sometimes.
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #4 on: April 09, 2015, 11:10:07 am »
Thanks for the reply guys, that makes sense. What are the most common micros in real life projects? Microchip or Atmel? or maybe both?

I didn't expect a reply from you Dave, I appreciate it.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: How are micros programmed in real world situations?
« Reply #5 on: April 09, 2015, 11:11:38 am »
Thanks for the reply guys, that makes sense. What are the most common micros in real life projects? Microchip or Atmel? or maybe both?

I didn't expect a reply from you Dave, I appreciate it.

Yep,  PIC and AVR are used, but there are lots more.  STM32 is common as are LPC and loads of others.

http://www.eetimes.com/document.asp?doc_id=1261398
« Last Edit: April 09, 2015, 11:13:09 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #6 on: April 09, 2015, 11:15:44 am »
And what kind of setup would you use to program these micros? Just the official dev kit and/or programmer form the respective company?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: How are micros programmed in real world situations?
« Reply #7 on: April 09, 2015, 11:41:29 am »
And what kind of setup would you use to program these micros? Just the official dev kit and/or programmer form the respective company?

You can use cheap debugger or an eval board that includes a debugger for programming during development, but you'd typically use a good quality production programmer for devices in production.  Unlike the cheap debuggers, these have protected outputs so that board faults, or misaligned connectors etc. don't blow up the programmer.

Some production programmers will also perform verification at multiple supply voltages.
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #8 on: April 09, 2015, 11:49:32 am »
Good to know, what are some super common applications? I know micros are pretty much used in everything, but some really common ones.


EDIT: And for the Microchip parts, is the pic kit 3 a good place to start? How about the AVR Dragon for Atmel?
« Last Edit: April 09, 2015, 12:03:04 pm by sonnytiger »
 

Offline ehughes

  • Frequent Contributor
  • **
  • Posts: 409
  • Country: us
Re: How are micros programmed in real world situations?
« Reply #9 on: April 09, 2015, 12:16:05 pm »
http://www.slideshare.net/StephanCadene1/2014-embeddedmarketstudythennowwhatsnext


C is it.     Most of reponses that were not  for microcontrollers, rather embedded "PCs"
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #10 on: April 09, 2015, 12:33:59 pm »
Embedded PCs? Even for automotive and Industrial Control? Wouldn't Industrial Control be largely PLCs?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: How are micros programmed in real world situations?
« Reply #11 on: April 09, 2015, 12:41:23 pm »
Arduino is a simple place to start.

But if you want a real micro get a STM32F103 discovery board for ~$11 and install the free EmBlocks IDE/toolchain.
(EmBlocks works out of the box for STM32 discovery boards)
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: How are micros programmed in real world situations?
« Reply #12 on: April 09, 2015, 01:16:49 pm »
Quote
Do they use C? Or even assembler?

If you look at the installed base, I would say that a substantial portion (maybe even majority of them) of the mcus are programmed in assembly - think about those little guys in your coffee machine, in your calculators, watches, washers / dryers, window motors, mp3 players, toys, etc.. If you talk to those taiwanese guys, they wouldn't talk to you if you don't buy 100k+ pcs / yr. Those are tiny mcus and it is hard to imagine them being programmed in C.

However, most of the coding in the mcu land is done in C: many of the mcus: in cars, routers, wifi devices, embedded appliances, etc. They are smaller in quantity per project / coding but most of them are done in C to lower software costs.

So the answer depends on the question, duh!
================================
https://dannyelectronics.wordpress.com/
 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
Re: How are micros programmed in real world situations?
« Reply #13 on: April 09, 2015, 01:46:01 pm »
Quote
Do they use C? Or even assembler?

If you look at the installed base, I would say that a substantial portion (maybe even majority of them) of the mcus are programmed in assembly - think about those little guys in your coffee machine, in your calculators, watches, washers / dryers, window motors, mp3 players, toys, etc.. If you talk to those taiwanese guys, they wouldn't talk to you if you don't buy 100k+ pcs / yr. Those are tiny mcus and it is hard to imagine them being programmed in C.
For really simple high volume stuff maybe, but not for most stuff.
I have seen source codes for some cheap video games, lcd monitors and for some media player ics. All of them were C. The main function is done in hardware, all the software has to do is adjust the settings depending on the input data and then let the dedicated hardware do their job. In mp3 and video players you have GBs of flash, so nobody cares about code size. Even in white goods modern devices often offer complex menues in multiple languages and GUIs with touch screens and lots of graphics that take many 100kBytes or even MBytes.
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #14 on: April 09, 2015, 01:51:56 pm »
Arduino is a simple place to start.

But if you want a real micro get a STM32F103 discovery board for ~$11 and install the free EmBlocks IDE/toolchain.
(EmBlocks works out of the box for STM32 discovery boards)

I have done lots of stuff for Arduino, but I am more interested in learning how to use something that I would see in a professional setting.
So it depends, that makes sense.
That sounds like some interesting stuff to see!
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: How are micros programmed in real world situations?
« Reply #15 on: April 09, 2015, 02:52:46 pm »
Purely depends on your industry.

With all best practices taken on board etc, most of them get ignored, only really the smaller companies that try and abide by the best practices in my experience.

I work in a medium sized company and we have issued code in Arduino format, the hex file that gets produced just gets written directly to the Atmel chip, we use a range of MCU's and FPGA / CPLD's, depends on what the engineers favourite flavour of chip is, it's that simple.

Mainly C, I use some inline assembler for speed and timing occasionally if necessary.

PicKit 3, PM3, or the ICD3 is what we use, PK3 and PM3 for field programming,although, bootloaders can be of assistance here, our latest "product" I have created a wireless bootloader, which dumps the program into E2 before verifying it and programming the chip, it takes a backup of the program memory into the E2 also in a different location, belt and braces as much as it can be as GSM isn't 100% reliable.  Had to modify the linker and create "modules" and almost an API as the interrupts were becoming a nightmare I have separate interrupts and a function pointer for each mode, it sounds complicated and unnecessary I know but trust me, it was the only way I could get it to work reliably!

Can't really go into what it was, but sensors, automation and control systems, CCTV and signage is the game.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: How are micros programmed in real world situations?
« Reply #16 on: April 09, 2015, 03:11:35 pm »
EDIT: And for the Microchip parts, is the pic kit 3 a good place to start? How about the AVR Dragon for Atmel?
I wouldn't start with those. Old and antiquated. Better get something with an ARM CPU under the hood. Having enough processing power makes life much easier when doing timing critical stuff because you don't have to care so much. Unless you are doing high volume designs (>10000 pieces) engineering costs are dominant over component cost.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline sonnytigerTopic starter

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: ca
  • Life is pretty enjoyable, eh?
Re: How are micros programmed in real world situations?
« Reply #17 on: April 09, 2015, 03:13:08 pm »
Great info thanks! I'll probably have to use the pickit because the others are a little too expensive...

What dev boards/programmers does atmel have for the ARM based MCUs?
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4228
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: How are micros programmed in real world situations?
« Reply #18 on: April 09, 2015, 03:27:21 pm »
I have done lots of stuff for Arduino, but I am more interested in learning how to use something that I would see in a professional setting.

My choice of processor is usually guided by the choice of peripherals I need, and the operating voltage of the circuit.

If, say, you're building something that needs to be able to drive out 5V, then it can save space and cost if you can just use a 5V capable microcontroller, rather than having to provide 3.3V and some amplifiers or level shifters.

Or, perhaps the application could be well implemented with a slightly unusual peripheral that's only available in a particular MCU. That may make it a good choice, even if there are compromises elsewhere.

Personally I've yet to come across an MCU requirement that couldn't be met by an 8 or 16 bit PIC, or an STM32. Since I know these families reasonably well, they'd be my first port of call. I've only used other families when they've been prescribed for non-technical reasons.

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: How are micros programmed in real world situations?
« Reply #19 on: April 09, 2015, 03:32:53 pm »
Many embedded PCs are not much different than regular ones (assuming we're talking about x86). 

Several of the HMI panels that I've worked with that aren't made by a dedicated company like Allen Bradley, are basically a low profile PC motherboard with a flash drive running Windows 7 embedded.

Some of the bigger names like Allen Bradley use panels that run Windows CE that designed to run compiled applications using their software or Visual Studio.

The PLCs themselves tend to run some kind of RTOS that isn't really visible to the user.  In fact I think many of them may run two operating systems simultaneously (perhaps on separate processors)  The RTOS does the real time I/O switching and the second OS is more conventional and operates the peripherals and embedded HTTP server. That way any networking events only affect the second OS and the RTOS doesn't get bothered. (All speculation, but that's how I would do it)
The larger the government, the smaller the citizen.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: How are micros programmed in real world situations?
« Reply #20 on: April 09, 2015, 03:48:03 pm »
For programming devices, when ordering 1000s of devices, I usually use Microchip's own programming service, turnaround is about a week. However, sometimes Microchip lack stock so I purchase the devices from whoever I can find with inventory and program them up myself using a customised ZIF socket and either a RealICE or an ICD 3 and a foot switch to apply power. But believe me, programming 1,000 QFN devices one at a time in a ZIF socket is not my idea of fun.

For NXP's LPC lineup, you can use an LPC Link2 for debugging and programming, they're only EUR15, I have no idea how they can make them for that price, there is certainly no profit in it. If you buy two, you will have both a debugger and a target, their top of the range triple core LPC4370 is the MCU on that board.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: How are micros programmed in real world situations?
« Reply #21 on: April 09, 2015, 04:02:11 pm »
Oh back on topic for me, Mike from Mike's Electric Stuff uses the Pickit's ability to hold the firmware in memory and just presses it down to the programming header or pads on the board, clicks the button and moves on to the next board.

Time at 24:13 he starts talking about it. (Direct link at that time https://youtu.be/cQWnLOCGpXM?t=1453 )

« Last Edit: April 09, 2015, 04:14:27 pm by Stonent »
The larger the government, the smaller the citizen.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: How are micros programmed in real world situations?
« Reply #22 on: April 09, 2015, 06:33:01 pm »
Typically you create code for micro's using a C cross-compiler. But you can get Java (please don't) and there are startups to getting Javascript to mcu for fast learning purposes.
You can also use C++, which has the benefit of OO programming, (http://en.wikipedia.org/wiki/Object-oriented_programming) which can be really helpful in scalability.
Some people will try to tell you that C++ is not suitable for MCU use, they might get all heated about it. Please try it yourself. If fluent in C, you can easily do OO in C.

Some compilers people use:
  • One of the many variants of GCC, which is free if time is not a currency.
  • Keil
  • Tasking
  • IAR
Eclipse is not a compiler, just an IDE (Integrated Development Environment) I'd prefer not to use.

There are also many architectures, but the most popular ones are:
- ARM Cortex and regular ARM processors.
- Atmel (they have several)
- PIC
- 8051.
There some manufacturers that have some more proprietary stuff. Such as TI or Freescale, but most of the market will be ARM, 8051 and some atmel/pic.

Personally I'd stick with ARM Cortex, they're relatively easy to use across the entire family, but there is a short but steep learning curve. From M0 to M4. But there are plenty of other people developing for it, so the internet is full of it.
You can also easily switch brands if you don't like the peripherals in your current chip, without learning a new architecture or compiler. If you were using Keil or something else generic.
 

Offline Muxr

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: How are micros programmed in real world situations?
« Reply #23 on: April 10, 2015, 04:18:07 am »
Arduino is a simple place to start.

But if you want a real micro get a STM32F103 discovery board for ~$11 and install the free EmBlocks IDE/toolchain.
(EmBlocks works out of the box for STM32 discovery boards)
I am confused. Real micro as opposed to Micros Arduino supports? Are AVRs, SAM3X8E and MK20DX256VLH7 not real micros?

EmBlocks only runs on Windows.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: How are micros programmed in real world situations?
« Reply #24 on: April 10, 2015, 07:30:08 am »
Quote
And what kind of setup would you use to program these micros? Just the official dev kit and/or programmer form the respective company?
You have to separate "development" programming from "production" programming.  A development engineer would probably use some official programmer/debugger, like the PicKit3, Atmel ICE (which is the newer version of the dragon, BTW), Segger JTAG, or whatever.  A "development board" from a vendor might be used for some initial experimentation, but you'd quickly (?) transition to your own hardware design.

When the software is complete and/or it's time to ship the product, you'd create a distributable object file (.elf, .hex, whatever), and hand that off to the manufacturing department, who might have their own idea how to burn that file into the finished product (gang programmers capable of burning multiple chips at once, bed-of-nails fixtures that you can push a board into and get it programmed, specialized connectors and high-speed programmers...)

At a small company, "development" and "manufacturing" might be the same person, and the difference just a matter of ... focus.
When you
re developing, it's all about the turnaround time to fix/build/program/test new code.  By the time you manufacture, it's about throughput in products per hour, and you want the programming step to be quick and simple, so you can sit there and churn out a weeks worth of orders.  (I remember an early contribution I made at one startup was postscript code that printed labels for the EPROMS.  It was much better than the hand-scrawled labels... :-) )

Quote
I have done lots of stuff for Arduino, but I am more interested in learning how to use something that I would see in a professional setting.
If you have experience with Arduino, I don't see why using the arduino board with "more serious" tools isn't a good next step.  Try one (or many) of the alternate arduino IDEs.  Use the command line and learn to write Makefiles.  Write your own libraries.  Modify the core.  Add support for some "close" chip that isn't well supported.  Port as much as you can to some completely different chip family.  Fix some of the bugs or add the features that the Arduino team(s) are slow or unwilling to implement...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf