Write program for Atmega microcontroller with C#
C# requires .NET. It does NOT directly compile out into assembly or machine code. It targets the CLR or one of its subsets. Most C# programmers tend to expect a minimum level of library support, as well.

If you write up a .NET layer on your own (and source code is available) or if you find someone else who has already done it, then you probably could use C#.

There already exists C# for some embedded use, now. I've no idea about ATmega devices, though, nor about the use of Atmel Studio. If I were considering this, I'd simply use Visual Studio and be done with it.

I'd recommend, at first, that you look into the .NET Micro Framework 4.1 and the .NET Micro Framework Platform SDK as a starting point. For example, here is Microsoft's Overviews of the .NET Micro Framework as a good page to read. Then I'd probably go search around to see if anyone has attempted an implementation that might be close enough for your interest. I wouldn't expect much, given that you seem focused on the ATmega. .NET is probably easier to implement and better targeted at embedded devices more like the ARM7TDMI, ARM9 and perhaps the Analog Devices' Blackfin.

If you do find something good, though, it may not hurt to provide your own answer here and let all of us know about it.



I can see why someone might be interested, coming from a Microsoft VS background and used to using extremely powerful workstation machines, large expanses of memory and almost unlimited persistent storage to back it up with. Extremely powerful software widgets reduce complex tasks to a few simple operations. But an ATmega doesn't have access to such vast resources or raw CPU power.

For example, .NET permits the use of memory files through .NET objects that wrap an underlying support found in the Win32 API. That itself requires the underlying NT functionality. The .NET methods must switch from managed memory to unmanaged Win32 memory resources and theses are then further managed deep in the NT micro kernel. (Win32 is just yet another wrapper for it.) Memory files are really nice for certain needs. And with almost infinite horsepower and infinite memory to play with, many feel the .NET approach is the way to go to keep it "clean" and "easy." Of course, you lose a lot of performance along the way. But who can tell?

On the ATmega, you'd be able to tell.

The handling of anonymous functions, lambdas, closures, early and late binding, reflection, exceptions, reference counting and garbage collection, and... well... these are wonderful things to have access to. But there is a price, too. More than most would be willing to pay with an ATmega trying to drive a few pins for some simple application.

Not to say it cannot be done. I've not tried, so I'm open to the idea it can be done somehow and perhaps even done well enough with a reasoned subset that people might even like and use it. But it seems like a lot of blood, sweat, and tears getting there to me.

Look around though. Some really impressive group might have gotten there. If so, let me know!