Do you guys know where I learn to write c++? - Page 1
Forum section: electronics / beginners

author: Dylon124
author_rank: Contributor
timestamp: June 29, 2013, 07:11:41 pm
content: By,c++ I mean what ever the standard microcontroller language. Please correct me if c++ is wrong. I'm completely new to microcontrollers but I really what to program my own atmega328 and maybe any other mcu's. So if you a website or tutorial online about mcu's. PLEASE REPLY!

author: smashedProton
author_rank: Frequent Contributor
timestamp: June 29, 2013, 07:24:59 pm
content: Is jumping on the ARDUEEEEENO bandwagon an option?

author: c4757p
author_rank: Super Contributor
timestamp: June 29, 2013, 07:29:30 pm
content: The language is C, typically, or C++ for Arduino.Are you just new to microcontrollers, new to C, or new to programming entirely? That completely changes the answer.

author: netheranthem
author_rank: Newbie
timestamp: June 29, 2013, 09:48:16 pm
content: c++ is probably a poor choice for many applications. (And as a software engineer, I think it's crap for anything really).If you are curious about the infrastructure and feel like building complex things with very very simple blocks (Basically mathematical operations / memory read-write / jump to label ) go for assembly. I didn't regret learning a bit of it, even if I rarely use it beyond microcontrollers.Why do I love assembly for microcontrollers so much? Because it's predictable! You assign the memory yourself, and you can know exactly how many cycles your instructions will take, so you can know if that 24MHz will really hold its own and if it can deliver real-time output, for example. You do lose some higher-level constructs, but with most microcontroller applications it doesn't get problematic. If assembly can't solve your problems, maybe a raspberry pi could be worth it.If you want to get stuff done and follow a recipe that will work the same for all microcontrollers (or almost), go with C.If you struggle with setup (Which isn't very long, but you gotta learn it once, as they say. I personally think that struggling with the setup is an important part of learning.) for any of those two, then arduino is the way to start.

author: SharkWrangler
author_rank: Newbie
timestamp: June 29, 2013, 11:27:35 pm
content: When programming 8-bit microcontrollers, the two options you usually have are assembly or C. Each language has its advantages and disadvantages.Assembly is very low level and involves learning the instructions unique to each processor architecture. This approach gives you control of most aspects of your program and is very deterministic. You'll know how many clock cycles each instruction takes and how the registers are used. If you need a high level of optimization for a small microcontroller, assembly is the way to go. The main disadvantage of using assembly is that it can take much longer to write a program in assembly than in C.C is a higher level, more portable language that most microcontrollers have compilers for. It's also suitable for programming most applications. The greater abstraction can make writing programs easier and allow you to reuse code between projects. The C compiler you're using can hide many of the implementation details though, so learning about your specific compiler can be as important as learning C itself.Since C tends to be a bit easier to pick up, I'll assume that you want to use that.If you don't already know how to write in C.There are many books and online references that one can use to learn C.http://aelinik.free.fr/c/-- Teach Yourself C in 24 Hours in HTML format.http://www.cprogramming.com/tutorial/c-tutorial.html-- Another tutorial to get one started in C.Among the numerous printed books one can find online, the classicThe C Programming Language, 2nd editionis a small compact book that introduces the main concepts of the language.If you're already fluent in C.Once you have gasped C, you just need the platform specific tools for microcontrollers.Compiler / IDE: AVR and PIC microcontrollers each have free toolchains. Check outAVR Studio 6for Atmel parts andMPLABfor Microchip parts.Programmer / Debugger: It is important to get a tool that has both. At some point, your code won't work and a debugger will save you a significant amount of time and sanity. Atmel parts:AVR Dragon.Microchip parts:PICKit3.Once you have those, you can start prototyping your boards and programming. There are also tutorials floating around the internet based on using specific features of each microcontroller should you get stuck.

author: cthree
author_rank: Frequent Contributor
timestamp: June 30, 2013, 02:09:02 am
content: http://arduino.ccI'd suggest Arduino to get started. Once you outgrow that you'll know what you want to do.

author: Stonent
author_rank: Super Contributor
timestamp: June 30, 2013, 02:34:41 am
content: I took a C class years ago and think Arduino is pretty close even though I know it's based on C++.

author: c4757p
author_rank: Super Contributor
timestamp: June 30, 2013, 02:38:32 am
content: Yes, the entire Arduino library could be rewritten in C with very few modifications. Once you strip out all the C++ features that are too big to reasonably implement on a microcontroller, you're left with basically "C with namespaces".OK, OK, that neglects templates and a few other compiler-implemented things that present no overhead once compiled, but Arduino doesn't use them AFAIK.

author: Stonent
author_rank: Super Contributor
timestamp: June 30, 2013, 10:41:45 pm
content: I'd recommend watching Sciguy14's videos on Arduino on Youtube. his videos were actually what got me started with Arduino and made me want to buy one, and got me programming up fairly quick.Also when you're a little more comfortable, start watching videos on AVR GCC or AVR/Atmel studio, but wait until you're writing sketches in Arduino first before you go to Atmel studio because there's a lot more nuts and bolts involved that you don't deal with in Arduino. Basically you want to get to a point where you can write code in Arduino and then translate it to Atmel Studio. And by Atmel Studio I mean AVR C using the AVR GCC compiler. Because that's ultimately what the Atmel Studio is just a Microsoft Visual Studio front end for GCC.The AVRFreaks forum will be a big help in the transition to Atmel Studio, for the most part the guys there are pretty helpful if they see that you're making an honest attempt at self teaching and not just dumping code in the forum and say fix it for me.So I would say these should be some paths to look at:Arduino IDE to Atmel Studio (For Atmel Parts)MPIDE to MPLAB (For PIC)Energia to Code Composer Studio (For TI MSP430)Arduino, MPIDE, and Energia are all basically the Arduino programming environment but for other dev boards. MPIDE works for the Chipkit board with PIC processor on it, and Energia is for the TI Launchpad (you can buy them for 5 to 10 dollars and are basically like an Arduino)

author: johnboxall
author_rank: Unknown
timestamp: June 30, 2013, 11:25:19 pm
content: Quote from: Dylon124 on June 29, 2013, 07:11:41 pmHere's an excellent series of video tutorials that will get you started with the ATmega32a:http://newbiehack.com/MicrocontrollerIntroductionABeginnersGuidetotheAtmelAVRAtmega32.aspx

author: Stonent
author_rank: Super Contributor
timestamp: June 30, 2013, 11:52:22 pm
content: Quote from: tronixstuff on June 30, 2013, 11:25:19 pmAh yes those are good too, I couldn't think of his name, just remembered him as the Mechanical Pencil guy who's videos seem to speed up really fast when he's writing.

author: Psi
author_rank: Super Contributor
timestamp: July 01, 2013, 03:07:46 am
content: There are full online courses in programming with their lectures all on youtube.However it's C programming for desktop software and not microcontrollers, but a lot of the content is still relevant.And you're looking at 20+ 1Hour videos

author: Unknown
author_rank: Unknown
timestamp: July 01, 2013, 03:43:29 am
content: Just so you know, Dave thinks assembly programmers are idiots.