Arduino runs out of steam – Atmel Studio saves the day?

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

I was just talking to a guy interested in examples where an Arduino application runs out of steam and requires porting the code to Atmel Studio (to, for example, get around the Arduiono pin I/O constraints).

 

I can’t think of anything right off the top of my head and thought somebody here might have an example – and maybe even point to an Arduino sketch that has been ‘fixed’ in Atmel Studio.

 

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

smileymicros wrote:
Arduiono pin I/O constraints

What constraints?

 

There does seem to be a widespread misunderstanding that Arduino automatically imposes a huge amount of bloat. The bloat only really appears if you use the Arduino libraries intensively. If you ignore the API, you can cut out nearly all of the Arduino overhead. Even the C++ overhead is not that much. Since the "Arduino" footprint can be quite small, I can't really imagine any project where you need the extra few bytes.

 

I think the main reason for moving to Studio is that the IDE is much better, and you have the possibility of interactive debug.

 

 

Bob.

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

The only thing I can think of here are the interrupts and port manipulation.

 

I didn't find a lot on how to use the peripheral interrupts, so these are probably not meant to be accessed directly by the user. In some very time constraint applications where waiting in the main loop is unacceptable this might be an issue.

 

The port register are completely accessible to the user. But Arduino officially discourages writing to them directly for portability and code readability reasons. This means that if you need to write an entire port at once to use an 8-Bit bus, you officially should do this by writing each of the 8 bits individually using the digitalWrite methods. Which is of course much slower. But it can be circumvented with ease.

 

AFAIK, the Arduino IDE relies on avr-gcc, just like the Studio. So it shouldn't make a difference in performance which IDE one chooses. The libraries however can make a difference, so to gain anything, you probably have to rewrite most of the code to "standard AVR C".

 

Disclaimer: I have very little experience with Arduino, this is all just "from what I've heard" and short google search, so I might be completely wrong.

 

-Patrick

 

Edit:

donotdespisethesnake wrote:
I think the main reason for moving to Studio is that the IDE is much better, and you have the possibility of interactive debug.

+2

"Some people die at 25 and aren't buried until 75." -Benjamin Franklin

 

What is life's greatest illusion?"  "Innocence, my brother." -Skyrim

 

Last Edited: Wed. May 3, 2017 - 07:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
Arduino application runs out of steam

Do you mean Arduino IDE?

"When all else fails, read the directions"

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

One place where it can run out of steam is trying to change port pins at a high rate. There are so many instructions (eg, code clock cycles) to access a port pin that it can get significantly bogged down.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

ka7ehk wrote:
One place where it can run out of steam is trying to change port pins at a high rate. There are so many instructions (eg, code clock cycles) to access a port pin that it can get significantly bogged down.

 

You can simply use your own code, (although there is a fastwrite library), there is no need to use Studio. You can even use assembler routines in Arduino, if you want.

 

I assume that "using Studio" also implies use of ASF. I guess ASF is some improvement over using the Arduino API, but using the Arduino API is not mandatory.

 

I'll challenge anyone to write this more small in Studio (without using assembler);

 

void mydelay (volatile long n)
{
  while (n--)
    asm ("nop");
}
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  DDRA &= ~0x80;

  while (1)
  {
    PORTA |= 0x80;
    mydelay(1000);
    PORTA &= ~0x80;
    mydelay(1000);
  }
}

// the loop function runs over and over again forever
void loop() {
}

 

Sketch uses 742 bytes (0%) of program storage space. Maximum is 253,952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8,183 bytes for local variables. Maximum is 8,192 bytes.

 

 

I accepted :)

 

#include <avr/io.h>

void mydelay (volatile long n)
{
	while (n--)
	asm ("nop");
}


int main(void)
{
	// initialize digital pin 13 as an output.
	DDRA &= ~0x80;
    /* Replace with your application code */

    while (1) 
    {
		PORTA |= 0x80;
		mydelay(1000);
		PORTA &= ~0x80;
		mydelay(1000);
    }
}

                Program Memory Usage     :    390 bytes   0.1 % Full
                Data Memory Usage         :    0 bytes   0.0 % Full

 

So in this case, we save 352 bytes of Flash and 9 byte of RAM by using Studio instead of Arduino.

Bob.

Last Edited: Wed. May 3, 2017 - 08:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

donotdespisethesnake wrote:
I assume that "using Studio" also implies use of ASF.

Not necessarily.

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

awneil wrote:

donotdespisethesnake wrote:
I assume that "using Studio" also implies use of ASF.

Not necessarily.

 

No I know, but it is an advantage of Studio. In theory ASF could be used inside Arduino IDE, might be rather messy. Studio also makes it easier to write plain C or assembler. But at the end of the day, you have the same C/C++ compiler accessed via a slightly different route.

 

The biggest and baddest Arduino software I am familiar with is the Marlin 3D printer firmware. They have optimised versions of several parts of Arduino API, e.g. fast writes, SPI etc. Otherwise it compiles with Arduino IDE and Arduino processor "core" library. I keep wondering when they will decide they have "run out of steam" and step up to a bigger IDE, but they stick with it. One reason for marlin staying with the Arduino IDE, is that the user must rebuild to configure for their printer, and Arduino IDE is a lot lighter and ubiquitous IDE than Atmel Studio.

 

Bob.

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

Arduino doesn't "run out of steam", you don't need to use the setup() and loop() functions, you can delete them and use main(), and then Arduino becomes just a C++ IDE with a few quirks.

 

See, this is a valid Arduino sketch (based on post #6). It generates a square wave at about 600Hz on pin B5 (pin 13 in the Uno, the LED pin).


void mydelay (volatile long n)
{
	while (n--)
	asm ("nop");
}

int main(void)
{
	// initialize digital pin 13 as an output.
	DDRB |= (1<<PB5);
    /* Replace with your application code */

    while (1)
    {
		PORTB |= (1<<PB5);
		mydelay(1000);
		PORTB &= ~(1<<PB5);
		mydelay(1000);
    }
}

The Arduino IDE auto-includes the necessary headers. Size is 198 bytes, so I guess Studio is beaten... better set -Os optimization (Arduino deafault).

 

edit: and if you use volatile uint16_t n instead of volatile long n, it drops to 170 bytes.

Last Edited: Thu. May 4, 2017 - 01:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JEEZ...

 

Lets assume that I understand that the Arduino means an ecosystem to everybody AND that if you choose not to use that ecosystem, you have a nice little AVR board, usually with that ATmega328xx and the optiboot bootloader that you can drill down and use the GCC toolchain OR the Atmel Studio or whatever low level system you might choose.

 

The Arduino Ecosystem includes what is discussed on the Arduino website and what Massimo Bansi and crew came up with originally that they branded Arduino.

 

I get it, you don't have to use any of that - but the question IS - if you restrict yourself to the bog standard tools that are generally known as Arduino, can anyone think of examples where that system runs out of steam and that benefit from doing the sorts of things that benefit from writing C or C++ or Assembler directly in Atmel Studio to correct some weakness in the arduino ecosystem?

 

Clearer?

 

 

 

 

 

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

Well, it's just that from my point of view, if you are using Arduino hardware, programming using the Arduino IDE, flashing with the Arduino interface to avrdude, but just not using Arduino functions, you are still mostly part of the Arduino ecosystem.

It's like using Atmel Studio without ASF. You are still using Studio, right?

Last Edited: Thu. May 4, 2017 - 01:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

smileymicros wrote:
I get it, you don't have to use any of that - but the question IS - if you restrict yourself to the bog standard tools that are generally known as Arduino, can anyone think of examples where that system runs out of steam and that benefit from doing the sorts of things that benefit from writing C or C++ or Assembler directly in Atmel Studio to correct some weakness in the arduino ecosystem?
 

 

Atmel Studio gives you a much nicer IDE and debug tools, so for larger projects,that would be the choice. In terms of the compiler - it's avrgcc.

 

In Arduino land you would normally do:

digitalWrite(2,1); to set a port bit

Nothing stops you from doing the 'usual' method:

PORTB |=(1<<2)

Arduino puts in a little extra runtime stuff to do millis() and pwm. Just don't use those features and grab the timer for yourself.

Apart from the port bit handling, just about everything else is much like you'd write it yourself (maybe better???). If you don't like the way they do their stuff - don't use it and write your own. You can see exactly what the Arduino functions do by looking at the source code ( it's all in the installation).

 

 

 

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

examples where an Arduino application runs out of steam and requires porting the code to Atmel Studio

It's not the right question.  Atmel Studio by itself does not provide any "additional steam", it's the libraries that can be bottlenecks for the Arduino environment.  Libraries that don't have a direct equivalent in Atmel Studio at all.

You can write "direct port manipulation" even in Arduino, and you can use (or write) poor libraries even in Studio.   The only thing I can think of that it's a little difficult to get around in the Arduino environment is getting access to the interrupts that the arduino runtime environment is already using.  (and it's not THAT difficult.)

 

Now, there are a couple of other areas where AS beats Arduino:

  1. Debugging capabilities.   The Arduino IDE doesn't have any, other than print statements.
  2. Chip support.  AS supports ALL of the Atmel chips.  The Arduino IDE only supports a couple (though there are third-party addons for some.)  And it doesn't support all chip frequencies, fuse values, and so on.
  3. Being C++, I don't think that Arduino supports the "named address space" features added in recent versions of gcc; not in any meaningful way, anyway.
  4. access to compiler options.  And compilers other than avr-gcc/g++.  And Atmel assembler.

But those aren't usually things I'd put in the "steam" heading.

 

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

It's a 16MHz 8 bit micro whatever way you come at it. So there's the same amount of "steam" available whether you program it using Asm, C, C++, Arduino-C++ or whatever.

 

As I think we all know the abstraction of the PORT/pin bits to be pinN for portMode() and digitalWrite() just happens to mean that those two lib functions are less then 100% optimal. If that bothers someone then just PORTx = (1 << n) if you prefer.

 

Other than that I don't really know where the steam leaks are? Is it maybe because some device lib code is then, itself, reliant on pinMode and digitalWrite? I guess one could go in "behind the scenes" and implement those two functions using something a bit more optimal?

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

Thanks.

 

Some really nice responses about general things that might be weaker in the Arduino ecosystem than doing regular coding with Atmel Studio.

 

I realize that this gets a bit like the assembly versus C never ending argument. I do know that assembler might be required to do a USB implementation on the ATmega328, but I only point that out - not to discuss C versus assembler - but to point out that there may be a tangible project where using assembler might be required.

 

Likewise, I am looking for an example of a tangible project that might require:

1. Using Atmel Studio versus the Arduino IDE?

2. Using the lower level pin assignment function: PORTx = (1 << n) versus the Arduino technique?

3. Not using the Arduino out of the box because of potential interrupt conflicts with maybe millis and/or pwm?

4. The ability to better organize a large project that got too complex for the Arduino IDE.

5. The need to not use the serial functions but have debugging capabilities.

 

That sort of thing. I'd especially like to hear about any personal experience where someone started with the Arduino Ecosystem, but moved to Atmel Studio - and why they needed to make the move.

 

There is a guy at Microchip that thinks there might be a need or use for an application note that explains this and provides a real world example of where someone had a project that was being developed in the Arduino IDE, but needed to be ported to Atmel Studio for completion.

 

I see that this sounds contrived, but if someone knows of an actual project where this happened, it would help justify the effort to teach how to transition a project from the Arduino ecosystem to the Atmel Studio environment.

 

 

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

The Adafruit library for using NeoPixels (programmable tri-color RGB LED modules: the IC designation is WS2812) requires precisely timed assembler embedded into the C++ library code.  This is because the programming format for the WS2812 has a 0.4 microsecond high, followed by a 0.4 microsecond data level, and a 0.45 microsecond low interval for each data bit transmitted to the string of LEDs.   This is right at the edge of what an Arduino can do, especially for an Arduino that uses an 8MHz system clock.

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

2. Using the lower level pin assignment function: PORTx = (1 << n) versus the Arduino technique?

digitalWrite() and similar are 25x or more slower than the fastest possible (constant argument) direct port writes.  Quite a lot of things "drop down" to faster mechanisms than using the top-level Arduino functions for each pin change.  The most common is probably assorted bit-banged protocols, where even if you're willing to put up with the overhead of of variable port address and bitmask, it's "obviously painful" to do the conversion (from Arduino Pin# to port/mask) EACH time for every bit (and every clock bit.)   There are also assorted "fast_digital_write" libraries and mechanisms that can be used instead of the defaults.

 

 

4. The ability to better organize a large project that got too complex for the Arduino IDE.

Sure.  That.  And Source Code Control, too.   Sub-directories!  Makefiles.  (I'm moderately annoyed that the Arduino folk have written their own "make-like" utility, in yet-another-language (Go), instead of figuring out how to use one of the standard existing tools.   Sigh.)

 

 

5. The need to not use the serial functions but have debugging capabilities.

 I can tell you that the Arduino IDE is pretty useless for working on, or debugging, any of its own bootloaders, if you want a concrete example...

 

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

smileymicros wrote:
1. Using Atmel Studio versus the Arduino IDE?
AFAICS the only real motive for moving to Studio is to get access to things like VassistX that may make writing the code easier but principally so you can interface to a debugger. If you don't want to debug (which involves modifying the electronics of your Arduino) then there's little motive to move to Studio.
smileymicros wrote:
3. Not using the Arduino out of the box because of potential interrupt conflicts with maybe millis and/or pwm?
We've seen some threads about this where people have tried "standalone" but doing it in the Arduino IDE and haven't realised that peripherals they are tying to use have already been "taken over" by Arduino.
smileymicros wrote:
4. The ability to better organize a large project that got too complex for the Arduino IDE.
I thought Arudino had the capability to split things into separate INOs in separate tabs. If used correctly that should provide a way to modularise code. What maybe isn't so great is how Arduino automatically handles the inter module dependencies so the user is not encouraged to document module interfaces in .h files.

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

I thought Arudino had the capability to split things into separate INOs in separate tabs.

The Arduino IDE will cope with multiple INO files, multiple CPP files, multiple C file, multiple S files (I think), multiple H files in a project directory.

 

The INO files get concatenated and forward references kludged.

Regular CPP, C, S files are built independently.   You must obey the language rules.

 

The whole system works pretty well.    It is easier to debug an Arduino IDE generated object file than to copy everything into an AS7 project.   (Especially since the AS7 "import sketch" is feature-rich)

 

Regarding Smiley's original question.    You can construct an artificial "slow" project but it would be equally "slow" in AS7.  e.g. bit-banging with digitalWrite() when the hardware peripheral is available.

The most noticeable effect of AS7 is incremental builds are a lot quicker.   And you can add global Symbols without having to edit the platform.txt or boards.txt

 

David.

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

The Arduino IDE will cope with multiple INO files, multiple CPP files, multiple C file, multiple S files (I think), multiple H files in a project directory.

Yes, but things get a bit hairy when the editor tabs get too narrow to read the filenames... :-)

 

 

The whole system works pretty well. 

 True enough, at least for the size of typical ATmega328 programs.   I'm no sure I'd want to build a a sketch that filled a SAM3X's 512k using the Arduino IDE!

 

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

Thanks for all the great ideas.

 

I was asked to come up with a justification for using AVRs in Atmel Studio when you have the Arduino and I think the boundary case is large and diffuse.

 

I came across this helpful video:

https://www.youtube.com/watch?v=...

 

I suspect that most Arduino users are perfectly happy with what they have and will rarely run into limits. I also suspect that folks that get into more detailed projects (large and requiring critical timing) would naturally gravitate to Atmel Studio, unless they are heavy Linux users, then they probably would be comfortable with avr gcc and the whole command line workflow thing.

 

To an extent I think I can say that if you want to get something done that isn't too complex or time critical, just go with the Arduino. If what you want is complex and time critical, go with Atmel Studio. And if you are really into this sort of thing and want to go deep, then the AVR GCC stuff (avrlibc, avrdude, etc.) are the way to go.

 

I don't actually think I've learned anything I didn't already know, but maybe I have a better handle on how to express this to others.

 

Thanks again for helping me think this out.

 

Last Edited: Mon. May 8, 2017 - 03:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rarely run into limits.

Ah.   The best reason to move to something else is when you actually DO run into limits...

 

Mac users would also be dis-inclined to move to Atmel Studio...  (It will be interesting to see if AVR and ARM support shows up in MPLAB X !)

 

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

smileymicros wrote:
I was asked to come up with a justification for using AVRs in Atmel Studio when you have the Arduino
"Debugging" - simple as that. In fact I can think if very few other reasons.

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

This is primarily re newcomers to programming, right?

If you've been using the more powerful IDEs then you might feel that Arduino lacks some of your favourite features. Find in files.., regular expressions, split windows, macro recording and playback, ability to define your own hotkeys/accelerators, organize you own toolbar, drag windows/panes outside the main IDE frame, modify code completion behaviour... The list goes on and on.

Even if some of this is doable, how do you do it in Arduino? You might want to avoid having to learn a single-targeted IDE when there are others that are far more generic.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Mon. May 8, 2017 - 02:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
Even if some of this is doable, how do you do it in Arduino?
Arduino (like VS for that matter) "watches" files so if you have a preferred editor you can use it externally. When you save changes Arduino will tell you "I've noticed foo.cpp has changed - reload?". That is, of course, equally true for MS VS (and hence AS7 too) so even in those, if you want to use a "better" editor you can.

 

Of course a lot of people want an IDE to be a "one stop shop" and in that case you might choose one principally based on the "power" of its editor.

 

BTW although the Arduino editor may seem a little "mickey mouse" the fact is that I think it is based on a Scintilla engine (or similar).

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

I don't have Ardino installed ATM. It might be Scintilla-based but if so (and IIRC) not many of the features has been incorporated or exposed.

 

Don't get me wrong. I think that is a good thing. I can easily imagine how the intended audience might be overwhelmed if their first experience was something like Atmel Studio or NetBeans or CodeBlocks. Not to mention Eclipse (with which I have entered an interesting  love/hate relationship the last few years..)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

donotdespisethesnake wrote:

 

#include <avr/io.h>

void mydelay (volatile long n)
{
	while (n--)
	asm ("nop");
}


int main(void)
{
	// initialize digital pin 13 as an output.
	DDRA &= ~0x80;
    /* Replace with your application code */

    while (1) 
    {
		PORTA |= 0x80;
		mydelay(1000);
		PORTA &= ~0x80;
		mydelay(1000);
    }
}

                Program Memory Usage     :    390 bytes   0.1 % Full
                Data Memory Usage         :    0 bytes   0.0 % Full

 

So in this case, we save 352 bytes of Flash and 9 byte of RAM by using Studio instead of Arduino.

 

Let me state at the outset - I am not a huge fan of the Arduino IDE.  The only reason it is on my computer is so that I could perform some experiments with GRBl and a Mega2560 - with much success, I might add.

 

But what is really funny, I put a "Copy & Paste" of the above program into the Arduino IDE and it compiles perfectly.

 

I got the following:

 

Binary sketch size: 365 bytes (of a 258,048 byte maximum)

 

It seem that there needs to be much clarification regarding the above claims that the Arduino IDE is not as steamy as AVRStudio - and there are tons more seemingly unqualified claims out there in cyber-space.

 

In fact, from my experience with AVRStudio, I consider it a pig, wearing lipstick.  I no longer use AVRStudio because if is a FAT hog and it has shown itself to be quite good at tripping over it's own hooves.

 

Since I discarded Windows and moved to Linux Ubuntu Mate, I've been using AVR-GCC, make, AVRDude with several AVRISP-MKII programmers and learning KiCAD and Fritzing.

 

And then too, maybe Linux Ubuntu Mate and the Linux port of the Arduino IDE do things differently enough to tip the scales.

 

From my perspective, there is no need to remain in bondage to Windows and AVRstudio, when there are much better options out there, while offering greater flexibility - but at the expense of some intensive book learning.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

microcarl wrote:
But what is really funny, I put a "Copy & Paste" of the above program into the Arduino IDE and it compiles perfectly.

No surprise there I hope?

 

microcarl wrote:
I got the following:   Binary sketch size: 365 bytes (of a 258,048 byte maximum)   It seem that there needs to be much clarification regarding the above claims that the Arduino IDE is not as steamy as AVRStudio

Since the Arduino uses the same compiler as the one shipping with AVR Studio, then the size of the generated code should be (roughly) the same (allowing for different compiler versions, optimization settings etc).

 

We need to distinguish between the Arduino IDE and the Arduino software framework. The latter is what sports e.g. the "bloated" pin wiggling/reading code. Compile an arduino sketch with AVR Studio and you'll get the same "bloat".

 

And, as "snake" has pointed out, compiling something that does not use the Arduino framework in the Arduino IDE should produce about the same as if compiled with AVR Studio.

 

Bottom line is: avr-gcc is avr-gcc, regardless of how it is invoked.

 

So...

 

A discussion about the Arduino IDE should mainly be about its usability. Discussions about Arduino code efficiency is a discussion about the Arduino software framework.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I'm coming in late to this and there may be threads elsewhere that could help me but here's my task..

 

I will be working with AS7 for the debugging features and I prefer to work with a toolset I'm reasonably familiar with.

I have found arduino libraries and examples to control a zigbee radio link and it makes sense to me to use them rather than write all from scratch, but of course the library and examples are in C++.

Now I've only ever used C# as an OOP tool, but familiar with OO concepts enough to give it a go.

 

I've created the C++ project and got the library functions and a bit of startup code compiling ok, however I have commented out the bits to do with the streams and serial ports.

I'm not sure the best way to go about adding that bit - I have my own c code to read/write  the serial port and throw it into or get it from a circular fifo buffer - which has worked to date.

 

I have been trying to find source code for the Stream class - to use or somehow use as a template for using my own code.

I don't need all the bells and whistles - I'm only using a single fixed Serial port, but do need uart handshaking ( using my own pin assignments ) with the zigbee module.

 

I saw Smileymicros mention elsewhere  about creating such examples when porting from Arduino.

 

I don't want to take a full Arduino project and simply do an import. I'd sooner write my own bits to deal with timer, serial and IO ..  or is that not considered the smart thing to do?

 

 

 

 

 

 

 

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

rowifi wrote:
I don't want to take a full Arduino project and simply do an import.

But that is the way that AS7 is designed to work!

 

or is that not considered the smart thing to do?

I always think that working with the tools is the smart thing to do - rather than trying to fight the tools  and force them to work "your" way ...

 

YMMV

 

 

I'd sooner write my own bits to deal with timer, serial and IO ..  

There's nothing to stop you doing that in the long term - but, for getting started,  I would certainly suggest that importing a known-working "sketch" is the way to go ...

 

 

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: 1

rowifi wrote:
I have been trying to find source code for the Stream class - to use or somehow use as a template for using my own code.
It's in the core installation of Arduino. In fact pretty much all the core stuff is in one directory:

 

But like Andy says the major leap Atmel made in Studio in the 6 to 7 transition was the addition of an INO importer. It will scan an INO and find all that it depends on and pull that into an AS7 C++ project so why wouldn't you simply use that? If you think the result is "bloaty" or something then do it anyway but once you have everything then analyse what it has pulled together and either throw away bits you think you don't need or maybe even refactor things like digitalWrite() to implement them in a more efficient way if you think that's possible. The alternative of trying to manually pick functionality (and then all it's dependencies!) from an Arduino tree is (as you are likely discovering) much more "fraught". The AS7 technology automates the process - computers do repetitive jobs like this far better than us error prone humans ever can.

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

and, of course, once you have the "sketch" imported into AS, you can use all of its (ie, Visual Studio's) standard navigation & browsing tricks to find where stuff is defined / declared / used ...

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...