How to Convert Imported Arduino Sketch to C-Style main.c in Atmel Studio?

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

i imported to Atmel Studio, and successfully compiled, the sketch below, filename Sketch.cpp

 

Then i removed Sketch.cpp , and replaced it with the following main.c. main.c is my handwritten attempt to write the sketch in C-style. 

 

On build, got many errors.

 

I'm trying this approach, because some in the forum have commented that getting all the library referenced correct in AS is very challenging. 

 

Is there a right way to do this? -thx

 

sketch.cpp

/*Begining of Auto generated code by Atmel studio */
#include <Arduino.h>

/*End of auto generated code by Atmel studio */

/*************************************************** 
  for Adafruit 16-channel PWM & Servo driver
  PWM test - this will drive 16 PWMs in a 'wave'

  These drivers use I2C to communicate, 2 pins are required to  
  interface.
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
//Beginning of Auto generated function prototypes by Atmel Studio
//End of Auto generated function prototypes by Atmel Studio



// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(&Wire, 0x40);

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel PWM test!");

  pwm.begin();
  pwm.setPWMFreq(1600);  // This is the maximum PWM frequency

  // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
  // some i2c devices dont like this so much so if you're sharing the bus, watch
  // out for this!
  Wire.setClock(400000);
}

void loop() {
  // Drive each PWM 
  for (uint16_t i=0; i<4096; i += 8) {
    for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
    }
#ifdef ESP8266
    yield();  // take a breather, required for ESP8266
#endif
  }
}

 

main.c

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(&Wire, 0x40);


int main(void)
{
	// Arduino "Setup"
	Serial.begin(9600);
	Serial.println("16 channel PWM test!");

	pwm.begin();
	pwm.setPWMFreq(1600);  // This is the maximum PWM frequency

	Wire.setClock(400000);
	
	
	// Arduino "Loop"
	
	while (1)
	{
		// Drive each PWM in a 'wave'
		for (uint16_t i=0; i<4096; i += 8)
		{
			for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++)
			{
				pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
			}
			#ifdef ESP8266
			yield();  // take a breather, required for ESP8266
			#endif
		}		
	}
}

 

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

Arduino uses C++. Hence sketch.cpp and statements like Serial.begin()
If you want to write a C program you must only use C statements.
.
Arduino simply parses the INO file for includes and forward references. Then compiles it as a C++ file.
.
Yes, you can write an equivalent C program with C functions to replace the C++ class methods. Easy for simple programs but a nightmare for complex programs.
.
You can mix C and C++ statements in a C++ file but not in a C file.
.
God gave you the Arduino. I would concentrate on learning how to use the Arduino libraries and IDE as well as possible.
If there is something that you think is not possible, ask.
.
David.

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

As David says, what is the point in changing or converting?

 

Why not just stick to the Arduino IDE?

 

If you really want to move to Atmel Studio (eg, for the on-chip debug), why not just keep it as C++ ?

 

 

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

Thx for helping me understand more. 

 

Food for thought, on which i'll have to think. 

 

thx

Last Edited: Thu. Mar 15, 2018 - 09:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to check but you do know Arduino already has a main() don't you. In a typical installation you find it in:

 

\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino

 

In that directory is main.cpp which forms the heart of the code that Arduino (and later AS7) builds. It consists of:

#include <Arduino.h>

// Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (* /*func*/ )()) { return 0; }

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

void setupUSB() __attribute__((weak));
void setupUSB() { }

int main(void)
{
	init();

	initVariant();

#if defined(USBCON)
	USBDevice.attach();
#endif
	
	setup();
    
	for (;;) {
		loop();
		if (serialEventRun) serialEventRun();
	}
        
	return 0;
}

As you can see this calls out to the setup() and loop() that you implement in the INO (or sketch.cpp) so you already have a complete main() driven program. The other stuff in the main() here are calls to initialize the "internals" of Arduino - like getting the timers going and so on.

 

One things for sure. You can't instantiate and invoke C++ classes from C code so main() almost certainly has to be C++ not C.

 

(the converse is not true - you can call C code from C++ but to disable "name mangling" you generally have to use extern "C" on the interface).

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

clawson wrote:
 In a typical installation you find it in:

 

\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino

 

I only have one converted Sketch to go on but, in that, the main.cpp is in <project-name>\ArduinoCore\src\core

 

I guess that is probably general ... ?

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

Yeah,  that is where the AS7 importer copies it to. I'm talking about where it starts in a typical Arduino installation.

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

clawson wrote:
Arduino already has a main() don't you. In a typical installation you find it in:

 

\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino

 

In that directory is main.cpp which forms the heart of the code that Arduino (and later AS7) builds.

 

thx for ninja-class info. 

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

Every time you try something new then do it in small steps.

I can understand you want to move away from "arduino". But if you want to do so, then first get familiar with your new tools.

You've seem to chosen Atmel's Studio. Build a blinking led in there first.

Then add some of your own functions and expand.

But if you want to use too many of the "arduino" libraries there is not much use in trying to get rid of it.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Thu. Mar 15, 2018 - 11:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Yeah,  that is where the AS7 importer copies it to. I'm talking about where it starts in a typical Arduino installation.

Indeed.

 

Just so the OP knows where to find it in her/his imported project.

 

And, if  OP wants to make changes, they will have to be in the imported copy ...

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

Paulvdh wrote:
I can understand you want to move away from "arduino".
I don't. The reason it's so popular is that it's so good. If I want to pint a float I:

Serial.println("3.141592");

and that comes out on the terminal. I never had to know about %f in sprintf() or what UCSRA/UBRR or what any of that stuff are. It's very difficult to just throw all that away.

 

The problem with Arduino users is that they don't know how complex the "behind the scenes" stuff is. Sure a digitalWrite() might boil donwn to a one line PORTB |= (1<<5) or something but a robotTurnAround() might equate to 5,000 lines of C++ with all stops in between.

 

Apart from a "better editor" I'm not sure what the perceived advantage of AS7 is? If this is about "programming in plain C" then don't just try to mimic what an INO is doing. Set small goals and work up from the ground up: light and LED, flash an LED, use a timer to flash an LED, use a timer interrupt to flash an LED, use a UART to send 'A', use a UART to send "Hello", have a two way UART conversation and so on.

 

But it'll be a long time before you reach the wide range and ease of use of Arduino. Trying to get that robot to turn around could be particularly challenging!

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

clawson wrote:
The problem with Arduino users is that they don't know how complex the "behind the scenes" stuff is

Ha ha - that is a common problem with many things these days!

 

For "Arduino" you could substitute "USB", "Internet", "Image Processing" and many more ...

 

As the old saying goes, "It takes a great deal of effort to make something appear effortless!"

 

frown

 

I'm not sure what the perceived advantage of AS7 is?

I guess The Big One is proper debugging?

 

But then most AS users here don't seem to do that anyhow!

 

frown

 

 

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:
But then most AS users here don't seem to do that anyhow!
For an Arduino it involves hacking about the _reset circuitry which may not be everyone's cup of tea.

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

I see - but I was talking more generally

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

@clawson.

As you know an "3.141592" is a string, and not a float.

The reasons you are giving is why people get sucked into the "arduino" hype. Not the reasons they want to get out.

One of the reasons to get out is if you want to have more control of your peripherals.

Try to use a uart for a RS-485 packet network, an then you discover that your uarts are all tied up in some pre-instantiated classes somewhere deeply hidden in source files where you can hardly find them with the horrible arduino editor which does not deserve the name "ide".

 

I've also played briefly with mbed. With mbed you can declare an instance of a serial port object (and give it the name you like while instansiating) and then use it. By simply providing the libraries, but not instantiating objects you give the users a choiches and open options. "arduino" could have been a great teaching platform if it was designed only slightly differently. On a lot of sides some ooze is coming out which shows that "arduino" is initially set up by some students instead of people with a decent amount of programming experience. They are also doing a lot of silly things for no apparent reason whatsoever apart from doing ther own thing. Why on earth did they have to invent that ".ino" file name extension? Yuch. Is there even a single reference to C / C++ on the arduino site, or do they still want to let pople believe they invented their own langugage?

It seems that they have sacrificed (or deliberately demolished, or never thought about) any kind of usability of the "arduino" platform beyond making a blinking led and some beginner projects which do not go beyond glueing some pre made parts together.

The way arduino seems to work is by dumbing people down instead of inspiring people to investigate, expand and learn.

First time I tried to use it I had quite some trouble in even getting to see the compiler errors/ warnings during compilaton.

 

Splitting main() into an init() and a loop() is also not helping anyone. It is just an extra layer of obfuscation and fudge.

"arduino" would have been so much better if they had not stubbornly had to do EVERYTHING in their own small minded way and sticked with over 30 years of experience and conventions.

 

It is no more difficult for beginners when they start a new program ("arduino" has some other name for it, only god knows why) that a template is loaded which holds the arduino header(s) and a main() function. They could even have put the init() and loop() in that template if they wanted. Keeping to such (and many more) conventions will introduce beginners to C++ in piecewise way, and it will actually teach beginners something usefull. Now if people get annoyed by the arduino limits and they want to get "out" they are suddenly confronted with the harsh wold and presumably 2 main() functions as you pointed out earlier.

 

"arduino" is also learning lots of bad habits to beginners. They all start with a bliking led with delay() and/or counting millis(). Because the delay() bocks everyting (except interrupts) this first bad habit they learn gets them ALL into trouble later on. Why not start wit a simple decent timer in C++ and learn those beginners some proper techniques? Make it easy and accessable to study the internal framework instead of hiding it.

Beginners have a tendency to copy and try out code. And if it works they get curious to how it works.

If you start with a blinking led template which looks like this:

#include "timer0.h"

void ThreadBlink( void) {
    PORTC ^= 1<<0;
}

int main( void) {
	TTimer0 timerBlink, timerMotor;

	DDRC = 0xff;
	timerBlink.Execute_At   = ThreadBlink;
	timerMotor.Execute_At	= ThreadMotorControl;
	sei( );

	for(;;)	{
		PORTC ^= 1<<5;	    	// Debug: Idle toggle on LA (Approx 200kHz)
		timerBlink.Interval( 500);      // [ms]
		timerMotor.Interval( 20);
	}
}

then you set up your beginners for something that is actually usefull and they can extend and learn from. In any decent IDE the source code of the used timer0 lib is just one or 2 key presses away.

 

As a "teaching" platform there should also have been an easy mechanism to pull a library out of the "arduino blob" and put a working copy in a separate project to study, and change the code in that library.

 

clawson wrote:
Apart from a "better editor" I'm not sure
The editor is the very first and an important reason to move away from "arduino" Once the arduino editor has been replaced by some decent IDE you can jump from file to file inside the arduino framework and you have the tools to examine what is going on inside that framework.

The lack of name completion is also a big hindrance for beginners, but they don't even know it. But once they see anybody anywhere typing a class name, a dot and then getting a list of member function for which they haven't even learned the names yet they can not do without. Which confronts them immediately with "how do I ditch this arduino editor and get something better?".

 

Using Atmel's studio is one way to go. If you do not like Atmel's Studio then Platformio is a pretty decent alternative. Platformio defaults to "Atom" as an editor, but is is pretty easy configurable for any IDE that is capable of calling external tools. I've set it up to use it with Qt Creator, just because that happened to be the IDE I was already familiar with.

Go to https://platformio.org/ or watch some youtube vids to get aqqainted with platformio.

 

=========================

In case of curiosity:

Timer0 is a immature not finished small lib just meant to try some ideas of mine.

It has about 20 lines of code, and lots of comment.

If you want to experiment with it:

 

Attachment(s): 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Thu. Mar 15, 2018 - 02:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
As you know an "3.141592" is a string, and not a float.
Sorry I meant to type:

Serial.println(3.141592);

Both, of course, "just work". That's part of the point - would someone re-implementing this from scratch even know what C++ "overloading" actually was?

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

Paulvdh wrote:
 "arduino" could have been a great teaching platform

AIUI, that was not the goal?

AIUI,  the goal was for non-programmers to get stuff done - not to learn programming.

 

a lot of silly things for no apparent reason whatsoever apart from doing ther own thing. Why on earth did they have to invent that ".ino" file name extension?

And invent "Sketch" and "Shield".

 

And do that stupid spacing on the shield (sic) connectors

 

 

 

However, despite all that, it cannot be denied that it has brought a whole load of people into programming & electronics who probably would not otherwise have done.

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

@Paulvdh: But it is open-source - isn't it ? 

 

cheeky

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

awneil wrote:
@Paulvdh: But it is open-source - isn't it ?
Yes it is. And despite all it's shortcommings and sillyness there is also a lot of good functionality in it as Clawson keeps pointing out :)

 

Sometimes I'm even tempted to fork "arduino" cleaning some parts up a bit by converting more to C++ and ditching all the pre-instantiated classes.

the "digitalWrite()" contraption also has to go in that case. I know it's usable for toggling a led or similar, but it also gets used for clocking in data to TFT lcd panels.

Changing a single line of code almost doubled the performance of the TFT (But it was still to slow for anything but static text on a 16MHz AVR).

Who ever dared to release that code on the internet should be shot, or at leased be banned from writing software or using computers or something.

I've looked briefly into templates for re-configureable I/O across different processors families. (I have AVR atSAM3 and STM32) It looks very promising, but writing the templates properly requires quite an effort.

 

awneil wrote:
... that stupid spacing on the sic connectors..
And I see that horrible connector spacing appearing on completely unrelated boards from manufactures such as ST, Ti, NXP, Nordic and others. Plea to all manufacturers: Stop copying stupid ideas. Try to make something universal and easily reusable / extandable for your development boards. A good way is to use 2-row 2.54mm headers. It's pretty easy to make a custom cable with some IDC connectors and a piece of flatcable without soldering.

The https://en.wikipedia.org/wiki/UEXT connector is also a good idea if this connectivity fits you development board.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

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

clawson wrote:

Apart from a "better editor" I'm not sure what the perceived advantage of AS7 is?

 

Well, the editor is not just better, it's much better. The simulator can also be useful sometimes.

But yeah, most Arduino users that want to "upgrade" to AS7 have a poor understanding of how much complexity Arduino hides from them.

 

I can speak from my own experiencecheeky but it was worth it, now I have a reasonable knowledge of C++, and of how to use gcc and avrdude.

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

El Tangas wrote:
most Arduino users that want to "upgrade" to AS7 have a poor understanding of how much complexity Arduino hides from them.
Exactly my point.

Hiding the complexity in the way they have done is a very bad mistake. The complexity has to be there to get things done. Now way around that, but it could be there in an accessible way as a learning platform. To examine and extend. And a decent IDE is mandatory for that.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

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

Paulvdh wrote:
Plea to all manufacturers: Stop copying stupid ideas.

Sadly, that's not gonna happen

 

sad

 

There is now such a vast wealth of "shields" (sic) in the stupid format that to ignore them would be to cut off one's own nose just to spite one's face.

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

Yes,  it is unfortunate that the Arduino headers do not fit 2.54mm matrix boards.

But there are third party Protoshields that enable you to solder prototype external electronics.

 

From a user's point of view,   the shields are robust for both electrical and mechanical connections.

 

The Arduino INO file looks after library lookup and forward declarations.

These are hard concepts for a new user.

It is relatively easy to port a sketch from Uno, Due, Zero, STM32, Teensy, ... if you stick to core functions.

 

MBED requires you to select libraries manually.   And forward declarations are the User responsibility.

MBED provides some "universal" classes and functions that allow you to write programs that will run on NXP, ST, TI, ...

You end up with similar overhead as Arduino digitalWrite().    Just that ARM works faster.

You can also end up with programs that might run on NXP but not ST

 

I probably edit Arduino C++ library code with Notepad++ and sketches with the Arduino IDE.   Build with the Arduino IDE.

 

Note that you can configure the Arduino IDE to use an external editor.

And you can configure the IDE to do many extra things if it suits you.

 

At the end of the day,   the Arduino is designed for punters to "get projects and ideas done".    And succeeds pretty well.

 

David.

Last Edited: Thu. Mar 15, 2018 - 04:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Paulvdh wrote:
Hiding the complexity in the way they have done is a very bad mistake

 

But as has already been pointed out, teaching programming was NOT the point of Arduino! 

 

If you have a better idea for teaching programming, start a kickstarter project and promote it instead of belly 'achin' about Arduino.

It's here and no amount of complaining will change that....    Move along...

 

A better idea would be to produce a set of tutorials for how to move from Arduino to real programming, by showing what is in Arduino

and expanding/explaining it to those who want to learn the "hidden" secrets and become real programmers.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

ki0bk wrote:
from Arduino to real (sic) programming,

 

surprise

 

real programmers

Who, as we know, don't eat quiche ...

 

wink

 

EDIT

 

Further reference: 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: Thu. Mar 15, 2018 - 04:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am going to have quiche for tea this evening.     I just call it "flan".

 

 

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

Well, I just hope nothing unmentionable hits the flan ...

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

david.prentice wrote:

I am going to have quiche for tea this evening.     I just call it "flan".

A generation or so ago...

 

Me to #1 Daughter, preschool aged:  "Mmmm--look at the nice quiche Mom made [eggs, bacon, etc. in a crust in a pie pan].  Do you want a piece?"

#1 Daughter:  "No, I won't eat quiche.  I don't like it."

Me:  "Are you sure you don't want a piece?  You'll like it."

#1 Daughter:  "No!  I won't eat it."

Me:  "Well, OK.  Do you want some scrambled eggs and bacon, with some crust, instead?"

#1 Daughter:  "Yeah, Daddy, I'll have some of that instead of quiche."

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.