Programming on a Windows Machine

From Free Charge Controller wiki
Jump to: navigation, search

Follow these stop by step directions to set up the development environment on a Windows machine. You will need to follow these directions weather you writing your own firmware or simply re-flashing the board with the latest firmware.


Download Software

  1. Download the latest copy of WinAVR
  2. Download AVR Studio 4.18
  3. Download the latest firmware


Install WinAVR first, then install AVR Studio second. AVR Studio will detect the installation of WinAVR and use it for compiling programs from within AVR Studio.


Here are some additonal websites that you might find helpfull:


Create A Project in AVR Studio

Unpack the firmware

Unpack the firmware into a chosen directory.

Unpack Firmware


Open AVRStudio

Open AVRStudio


Select a New Project

Select New Project


Select GCC Project

  • Type in a name for the project under "Project name:"
  • Uncheck "Create initial file"
  • Under "Location", navigate to the directory where you unpacked the source code
  • Select "AVR GCC"


Note: If "AVR GCC" is not an option, then AVR Studio is not able to detect your installation of WinAVR. Exit AVR Studio and reinstall WinAVR.


Select GCC Project


Tell AVR Studio Which Microcontroller You Are Using

Version 2.0 hardware uses an ATMega16 microcontroller.


  • Select "AVR Simulator" (not "AVR Simulator 2") under "Debug platform:"
  • Select "ATMega16" under "Device:"
  • Click on "Finish"


Choose a Microcontroller


Load Source Files and Compile

Add Source File to Project

Add Source File


  • Right click on "Source Files"
  • Select "Add Existing Source Files(s)..."
  • Select "main.c" from the directory where you unpacked the firmware
  • You can now double click the "main.c" file to edit the code


Add Main.c

Build and Run Project

  • Select "Build" -> "Build & Run" to compile the source

Build and Run


Program Charge Controller

Connect to AVRISP

  • Make sure the AVRISP is plugged into the USB port.
  • Click "Tools" -> "Program AVR" -> "Connect..."

Connect to Programmer


Select AVR Programmer

  • Select "AVRISP mkII" under "Platform:"
  • Select "USB" under "Port:"
  • Click "Connect"


Connect to AVRISP mkII