Amazing resource for learning C++

C++ is very powerful language and learning it can be a bit daunting for some. I’ve found a beautiful course in MIT OCW.

The link to the course is as follows: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-096-introduction-to-c-january-iap-2011/lecture-notes/

It doesn’t matter if you are learning from scratch or want a quick refresh on your concepts, this is the course for you.

The examples taken in the slides are to the point and relevant in real life coding. Concepts like constructors, destructors and even the tricky ones like pointers, memory management and templates to name a few are beautifully explained.

If you don’t have a compiler and IDE installed then the CodeBlocks IDE is a great bundle. Here is a link to the windows bundle : http://www.codeblocks.org/downloads/26

If you are a beginner then codeblocks-17.12mingw-setup.exe is the file you should download (this advice is given on codeblocks site).

Hope this helped!

Embedded C programming using AVR Studio on Arduino Boards

For those of you who have an Arduino development board and wanted to code in embedded c and upload your code on the board, this is the right post.

For starters you need to download following components:
1. Arduino IDE Download Link
2. AVR Studio Download Link or AVRDUDE download

We shall be using AVRDUDE utility for burning our programs onto the micro-controller.

Once you’ve installed above programs. We can begin the setup of AVR studio using AVRDUDE for burning our programs.

First you must locate following two files:

  1.  avrdude.exe : If you have installed Arduino IDE then a sample path for this file is as follows. C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe
  2.  avrdude.conf : Similarly for Arduino IDE installation the path is as follows. C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf

If you are using AVRDUDE direct download, then these files shall be in the avrdude installation folder. example: C:\avrdude\avrdude.exe and C:\avrdude\avrdude.conf

We shall require both of these paths in the subsequent steps, so kindly ensure you’ve copied these two paths and kept it somewhere.

Next step is detecting which COM port your arduino board uses.

devicemanager

In my case the port used by the Arduino Board is COM3. Keep this information with you.

Now the AVRDUDE arguments is as follows:

  1. Arguments for Arduino Mega 2560
    -v -patmega2560 -cwiring -P COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i -C"C:\avrdude\avrdude.conf"
  2. Arguments for Arduino UNO
    -v -patmega328p -carduino -P COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i -C"C:\avrdude\avrdude.conf"

I shall explain few important command line options used in above commands. The detailed explanation for all the options is given in following documentation.
options
Now that we understand about the commands that shall be used, we can proceed with the creation of AVR Studio programmer.

avrstudioprogrammer

Steps:

  1. Open AVR Studio.
  2. Under tools select external tools.
  3. Press add.
  4. Name your programmer in the Title field.
  5. Paste the appropriate arguments in the Arguments field.
  6. Paste the avrdude.exe file path without the quotation marks in the Command field.
  7. Check the ‘Use Output window’ box.
  8. Press OK.

Now you have your programmer available in the tools menu above the external tools sub-menu.

You can upload a LED blinking program to your board to check whether everything is working.

Steps for testing

  1. Create a new GCC executable project
  2. Make your main.c file
  3. Build the project so that the hex file is generated
  4. Go to Arduino Programmer in the tools menu and click on it
  5. You should get an output window

If everything works you will have the hello world blinking LED.

Hope you liked the post. If you found it useful, please like and share! Remember sharing is caring 🙂