1

I'm wondering how to use Arudino libraries for projects using regular microprocessors, in my case, the ATMega328p. I just have a PDIP processor on a breadboard and I'm not using an Arudino Uno or anything. I also don't want to be use the setup() and loop() Arduino programming environment, but I do want to be able to download and use the EtherCard library, which includes Arduino.h within it.

I'm using Atmel Studio 6.2 on Windows 8.1. I've found this post Using the Arduino libraries for regular AVR code which includes an excellent response, but it's specific (i think) to the linux environment. Has anyone used Arudino libraries for a non-arduino project? If so, how do I properly include them in Atmel Studio?

Thanks in advance for any input you may have.

Community
  • 1
  • 1
user2537523
  • 11
  • 1
  • 3

2 Answers2

1

There are two sets of libraries in Arduino tree. The first general AVR libraries (C) and the second Arduino libs (C++). Arduino extends AVR libraries providing some implicit functionality clock (msec, sec), streams, UART buffered handler etc. Obscure .ino extension file is copied to .cpp with added #include "Arduino.h" line. From my point of view Arduino IDE is wrong idea because it does not use normal make file but it's somehow hardcoded it in java (using only external avr-gcc).

Also "to-be-implemented" loop(), setup() seems like obscure idea introduced by Arduino's main.cpp implicitly linked in every project.

But I'm using both AVR and Arduino libraries and compile with avr-gcc (installed in Arduino tree). I recommend more fresh gcc (4.7 or so unless it causes problem in Avrstudio as Avrstudio 4.19 toolchain using gcc 4.7.x). I have own Makefile and using in Windows XP. You can override also some Arduino functions implemented using attribute ((weak)).

Community
  • 1
  • 1
TMa
  • 723
  • 1
  • 5
  • 14
0

Please connect the ATMEGA USBASP programmer and the ATMEGA328 controller like shown below:enter image description here
(source: learningaboutelectronics.com)

Then write the ATMEGA Uno firmware code to the controller. It is available over here - https://github.com/arduino/Arduino/tree/master/hardware/arduino/bootloaders/optiboot Download the 328 hex version over there. These boot loaders will also be available in you computer if you have successfully installed Arduino Sketch IDE. Now write the hex code to the micro-controller using he programmer and from then onwards the controller will work as a arduino uno. Connect the basic crystal and use a breadboard circuit as shown below. enter image description here

Now you continue your programming and loading on arduino sketch.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Arun Chettoor
  • 1,021
  • 1
  • 12
  • 17