How to use Arduino libraries w/Atmega324p in Atmel Studio 7 C++ project?

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a "howto" somewhere that describes how to use libraries written for "Arduino" (specifically, classes that begin with "#include<Arduino.h>") in an Atmel Studio 7 C++ project for a chip like the Mega324p?

 

I've spent hours so far wading through seemingly endless Google search results that all seem to be describing scenarios I don't want:

 

* I don't want to use the Mega324p with the Arduino IDE. I want to use it with Atmel Studio 7,  in a normal Atmel Studio 7 C++ project.

 

* I don't want to do Arduino-style flashing (via serial bootloader). I have a JTAGice mk2 & want to use it in the normal manner, using ISP, within Atmel Studio, via "Run without debugging". For what it's worth, I don't think I've ever gotten anything that involves AVRdude to reliably use the JTAGice mkII (from what I gather, Atmel refused to publicly document the JTImk2's communication protocol... AVRdude's developers eventually managed to reverse-engineer enough to get it "sort of" working, but it's officially unsupported.)

 

* Assuming the Arduino bootloader is literally JUST a bootloader that enables serial flashing, and not a HAL/kernel that everything in Arduino.h depends upon in order to work, I don't want to flash an Arduino bootloader.

 

I found THIS, which seems like it might be the source code to an implementation of the Arduino core libraries for the 324p and others...

 

https://elementztechblog.wordpre...

 

... but all of its documentation seems to assume I want to use the Mega324p AS an Arduino, as opposed to wanting to treat "Arduino" as a mere library dependency in an otherwise-normal Atmel Studio 7 C++ project.

 

Am I trying to solve an impossible problem (enabling source with dependencies on Arduino.h to compile in Atmel Studio 7 as a C++ project for the Mega324p), or is this something that's actually pretty easy to do?

There's no place like ~/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to start with a working Arduino project, and then import that into AS7 - that will bring the necessary libraries in with it.

 

EDIT

 

See: https://www.avrfreaks.net/commen...

 

and: https://www.avrfreaks.net/commen...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jun 13, 2018 - 06:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

miamicanes wrote:
I have a JTAGice mk2 & want to use it in the normal manner, using ISP, within Atmel Studio, via "Run without debugging"

If you're not going to do debugging, what's the point of moving to AS ?

 

But AS can program an image from any other IDE - or even any other toolchain - you just specify the hex file in the programming dialogue.

 

You can also use the JTAGice from the command line ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> If you're not going to do debugging, what's the point of moving to AS ?

 

Because the official Arduino IDE is god-awful.

 

I spent a few days trying to like PlatformIO with VS Code, but just couldn't get past my dislike for its enthusiastic embrace of Microsoft's awful flat UI design. It just plain felt like someone stapled an IDE into a web browser.

 

I tried CLion. I liked CLion. But I couldn't get an ESP32-Arduino project that needed U8G2 to compile on it to save my life. As far as I can tell, the problem was due to ESP32's still-beta CMake support.

 

Atmel Studio isn't awesome, but it has the benefit of being Atmel's officially-blessed IDE.

 

As for debugging, honestly, I'd love to be able to debug, but I've had too many chips get ruined by Debugwire. I'm afraid to use it anymore. I haven't tried JTAG yet (this is actually the first opportunity I've had to use a JTAG-capable AVR  since buying the JTAGice mk2 a few years ago), but I'm still nervous about anything that involves setting fuses that can't be fixed without HVP if anything goes wrong.

 

> You have to start with a working Arduino project, and then import that into AS7 - that will bring the necessary libraries in with it.

 

Hmmm... if it's a n Arduino project  that uses a non-canonical Arduino (ie, anything besides  an AVR mounted to a board following a design like the Uno, Leonardo, etc), should Atmel Studio be able to pick up the board definition from the Arduino IDE, or does it need to first be separately defined somewhere in Atmel Studio? About 2 weeks ago, I tried doing something like this with a Tiny25... I added the definition using the Arduino IDE's board manager (I think it was the board def. by David Mello), created a new project, and confirmed that it compiled without errors. I couldn't test it in the Arduino IDE, though, because the Arduino IDE apparently has no idea how to use a JTAGice mkII. When I tried to just import that project into Atmel Studio, it complained about an invalid board definition.

There's no place like ~/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

miamicanes wrote:
if it's a n Arduino project  that uses a non-canonical Arduino (ie, anything besides  an AVR mounted to a board following a design like the Uno, Leonardo, etc), should Atmel Studio be able to pick up the board definition from the Arduino IDE...

I don't know.

 

But, if you look at the linked thread, I get the impression that it's at - if not beyond - the edge of what AS does.

 

If you just want to get the library into AS, then why not just base the "donor" sketch on a canonical Arduino ?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is also an Eclipse-based IDE that claims to understand Arduino:

 

http://eclipse.baeyens.it/

 

I've never tried it, so can't comment on it.

 

 

EDIT

 

There's also VisualMicro: https://www.visualmicro.com/

 

AS6 used it as a plugin before the feature got integrated into AS7.

 

Again, no experience - but might be worth a look?

 

They have a forum: https://www.visualmicro.com/forums/

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jun 13, 2018 - 08:22 AM