programming languages

Status
Not open for further replies.

aaay

New member
Hi,

I am a bit confused as I am not sure what language is used to program the boards (3+). Is it that cryptic style language with ports and registers (resembling assembly language PORTD |= (1<<6) ) or the modern Arduino C(++). Kindly advise.

thanks,

Amr
 
Like for Arduino's UNO it uses the IDE C(++) language.

There are code bits just like that for UNO hardware port manipulations represented on the left in that statement by PORTD. Everything to the right after that is just C's assignment with an "or" of the right side value:: ( 1<<6) which in C says shift the immediate value of '1' 6 places left.

There is full 'c' and C++ language as supported by the compiler. Working with a Microcontroller introduces 'system' defined hardware ports/addresses that resolve out for Teensy with PJRC defined header values for the hardware - just like Arduino Hardware UNO/Lenardo/Due/...
 
If you are looking at what you can and cannot do, installing teensyduino is free
https://www.pjrc.com/teensy/td_download.html
And you can look at the examples, modify them for what you are trying to do and confirm you can at least get it to compile.
If you already have a working Arduino install it may be helpful to make a copy of the working directory and install Teensyduino onto that to make uninstalling easier should you decide not to buy any hardware.
 
level of experience with other boards wasn't indicated? If starting with Teensy or moving from Arduino's AVR chips seeing that the 32 bit ARM chips often have different PORTS and interface methods will show up if trying to use AVR code. Often that is taken care of in that common libraries have been ported to work with Teensy's 32 bit ARM - assuming you aren't looking at the Teensy 2.x family of AVR compatibles.

But rest assured - unless ASM is invoked - all the code used is c or C++
 
hi aaay,

the language used for teensy is c/c++ (c++ originated from c). So u can decide, which language you want to programm with, but if mixing them, be careful not to write bad confusing code.
There are lots of tutorials, where u can learn c/c++ e.g. at the website www.tutorialspoint.com, www.learncpp.com and so on.

(resembling assembly language PORTD |= (1<<6) ) or the modern Arduino C(++).

Well, what you just wrote is "far" (<- well not that far, but far enough :D) away from assambly language.
The code you just shared is common C and is code for manipulating a single bit in a variable (here: bit 6 (for programmers bit 5) in var "PORTD" [PORTD is a hardwareport/register] is set to 1).

In my opinion, the "arduino c(++)" is anything but modern...its more a step of backwards than progress. The reason: if you are learing Arduino and choose the wrong tutorials, you will be lead to a wrong picture of programming microcontrollers and programming in c/c++.
For the common user, to set a Hardware pin high to e.g. drive an LED, you can write "digitalWrite(13, HIGH);" and everything seems to be nice...BUT for a man, knowing about microcontrollers, assambly language and c, the function "digitalWrite();" is totally ***** (<- many bad words, sry) --> the reason: if you use C lanuguage correct, you could create a frequency on a Hardware pin with an Arduino Uno (driven with 16MHz) with 2 MHz...you will NEVER reach such speed with the "digitalWrite();" function, cause its written in a bad style. For this reason (very much thanks to him!!) PaulStoffregen, the creator of teensy, programmed the better written function "digitalWriteFast();" which will be able to create a much faster frequency.

So why i am writing this all...
Arudino/teensy is a very great and low cost possibilty to learn about microcontrollers, using some LED, then using a keyboard, and more and more by time and then doing great stuff with it.
BUT I would love to recommend it to you, and anyone else who will read this thread, first read a tutorial on C to get a much better understanding of Arduino. It should be a tutorial about c for microcontrollers and not e.g. c for windows!!
C is not so much to read and processed relatively quickly to get a rough overview, it will not hurt! :)
(it's kind of "you cannot fight, what you don't see" ;-) )
 
I would like first to thank you all for the great replies, all are pretty much appreciated. I have been working with Arduino and MBED for some time now. MBED was an upgrade path from Arduino but I do not feel comfortable with the online IDE. With Teensy, I presume, I will make use of my Arduino background.
 
You can count on Teensy working with the Arduino IDE - to the extent possible as well or better than prior hardware - that is PJRC's focus and The Arduino IDE is the only supported DEV platform.
 
I would beg to differ with this sentiment.

BUT I would love to recommend it to you, and anyone else who will read this thread, first read a tutorial on C to get a much better understanding of Arduino. It should be a tutorial about c for microcontrollers and not e.g. c for windows!!
C is not so much to read and processed relatively quickly to get a rough overview, it will not hurt! :)

If anything, the success of Arduino over the last 10 years has shown learning the easy-but-incomplete way first and then later digging deeper into the internals is a far more successful learning approach.

It's easy to say "it will not hurt" when you're highly experienced. But the reality for the vast majority of people is too much focus on low-level details too early in the learning curve does indeed hurt. Attrition rates in college engineering programs and the long pre-Arduino history of hobbyist electronics show pretty clearly just how badly it hurts most people.

My advice is to use digitalWrite() and whatever other easy Arduino stuff you can to get some initial success. Focus on getting things working first. Use libraries and copy example code. Building on initial success is crucial for motivation. Learning is a human process.

You can always dig into how digitalWrite() and everything else really works when you're curious. It's pretty amazing how complex those details get, especially with USB. Even among experts, I believe you'll find very few people who really know all the USB stack stuff including the subtle details of how host controllers actually schedule bandwidth. There are parts, like details of CAN bus and higher level protocols using CAN for transport, that I personally don't know well yet (but are on my bucket list...) These microcontrollers are becoming more powerful and more complex every year. I suspect relatively few people who are experts with 10+ years of experience could tell you how the advanced timer features and the DMA controller work together, since those sorts of capabilities are relatively new and very complex to fully understand at the lowest level.

When you want to know the details, of course dive in. Some of the low level stuff like GPIO isn't terribly complex to learn. But if you're just getting started, the path to success for most people is to use the easy stuff first, ask the hard questions of how it really works internally sometime later.
 
Building on initial success is crucial for motivation.
yes, you are complete right with this.

Attrition rates in college engineering programs and the long pre-Arduino history of hobbyist electronics show pretty clearly just how badly it hurts most people.
well yes, i really understand what you mean. But to tell from my experience, one of the most bad things happend to me, while learning to programm, were things i'd like to work, and sometimes did this "copy & paste" stuff, but just one missing information to me made it not work. Sometimes, to find this informations can be very hard to find. What luck, today you can "google" more and more, cause people are going to share their knowledge. Even when studying you sometimes will be thrown into task you have to solve, but the informations you need you have to find on our on and nobody will show you where.

Learning is a human process.
oh yes it is! But don't forget: learning new habits is easier than putting off bad habits.

But lets do not argue here.
Go into it! Don't give up! You can do great stuff with microcontrollers! =) And when you cannot solve something - one day you will find the missing information you need to know ;-)
 
Status
Not open for further replies.
Back
Top