Show Posts
Pages: [1] 2 3 ... 9
1  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 24, 2013, 05:54:13 pm
I mean that in a classical C ide if you write a function w/out declaring it it will not work.

You know, you've been busy explaining that the IDE is "not C" but I'm not convinced you know much about C yourself. The above claim for example. This compiles and runs on my Mac in a "classical C IDE":

Code:
#include <stdio.h>

void foo ()
  {
  printf ("Hello, world!\n");
  }

int main ()
  {
  foo ();
  return 0;
  }

I have a function there (foo) which is not declared (only defined).


I changed declared by defined. My mistake, but this not allow a failure to all things said before. And you should know all my argument by reading the previous example, instead of make central reasoning of your discussion to a single term (that is important difference, I know and you're right). But, letting it go...

For sure you've not understand my english and sorry for that.
In my previous example, WHERE is the definition of PinMode? I've defined and declared a(), but not PinMode.
I'm trying to say that in this case the foo() function will return, depending on compiler, a warning or not but your code will work. In Arduino if I use, for instance, "PinMode" (like the foo() in the example) without writing (a definition) something like "PinMode(etc etc) { the whole function }" as you've DONE here with foo, this is still working .
 In a classical IDE, if I want to use the code inside the PinMode() function, I need to define it (and declare it), before main, in a header or something, like you DID here with foo() function. So you are saying basically the same of what I'm saying: in Arduino you don't have to declare AND DEFINE functions while in a classical IDE, of course, you have to do it. Of course they are declared somewhere, but is hidden. I don't know how to be more explicit and clear, sorry. btw This lead to a different programming approach. And is a step even before understanding functions. So, coming to understanding function part of the answer....

Quote
Plus, if you use a "classical C IDE" to address, say, your disk drive on your Windows PC, you don't look up the datasheet for the driver chips in the disk drive do you? You use the stdio library, which does who-knows-what? And that calls device drivers. I bet you don't know exactly what they do either. And you write text to the screen, and are happy to use the video drivers that the manufacturer, or operating system vendor, supply. And you don't write to their forums complaining that you want to know how they work, do you? If so, please provide a link to your post.

This is MCU programming, and looking at datasheet and know about hardware being programmed is the philosophy that differ from an MPU programming. MPU is a part of PC, MCU is not: your example is incoherent. Moreover, An Mcu could be a part of the HDD, and if we are developing this, yes, you have to know the datasheet but could not the final user, obviously.
Your example could be ironically distorted: if a final HDD should follow standards of communication to exchanging data, and the rest is managed by the embedded mcu, the final user should know this standard. Or if it is a final user of a PC, could not know anything. Are you following me? Well, saying that, if Arduino can be used without knowing anything of the hardware and is considered educational, so also turning on a PC and hear the HDD grinding loudly could be educational as well.

To add one more thing, if you use the printf() in a PC you can ignore the functions and all management, at least at basics level of your application (I've never done something big with PC programs, I'm not a SW Engineer and I'm not good at all in programming: but I know basics at least and this is what we are talking about). But in an MCU, if you write "Hello World" somewhere, the core of understanding an MCU is to know how to connect those streams to you hardware so you have to know datasheet. If you want to make everything optimized, you can write your function managing single character and so on... This discussion is for someone who want to know how to program in the real world (maybe like companies do), not for the "artist" o the very newbie. It's obvious that an artist should have the chance of not reading datasheet, as the philosophy of Arduino is.

Hope to be understood. Otherwise, I apologize.
2  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 24, 2013, 08:26:02 am
It's also designed as a cheap educational board. What is your problem with that, exactly?
Well, it was not my question, but since you asket to me, i've something to say. If someone can learn C but not the real approach to mcu programming, i.e. reading datasheet to make initializations, which are a already made on Arduino libs, what someone could learn from that except the C++ language?
Of course you can do something different like rewriting functions ecc as we said before, but is not the purpose of the educational platform, otherwise someone would not written those functions.

Quote
I don't understand that, sorry.

I mean that in a classical C ide if you write a function w/out declaring it it will not work. But here the approach is simplified, as also westfw said before, and necessary has been automagically included. so i think that programming with the Arduino IDE pretending that can work as the same way of more classical IDEs is meaningless, am i right? Just to know whar are "limitations and differences" between these IDEs
3  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 24, 2013, 03:55:45 am
Quote
An MCU pure-C language allows you to predict a single clock cycle
Only if you use inline assembler.
Yes, it was to underlying how more high level functions make trivial this prevision. In fact Arduino, used with it's whole hw/sw system, is not recommended for mission critical applications, even if MCU it self can be.

Quote
It always does.  You only need the #includes to get access to libraries.  Here we see a blank main compiling just fine with no include files, for x86, avr, and pic24:
BillW-MacOSX-2<10005> cat >minimal.c
int main()
{
}
BillW-MacOSX-2<10006> gcc minimal.c
BillW-MacOSX-2<10007> avr-gcc minimal.c
BillW-MacOSX-2<10008> /Applications/microchip/xc16/v1.10/bin/xc16-gcc minimal.c
BillW-MacOSX-2<10009>  

cc5x (for 8bit PICs) didn't like it; apparently they don't allow main() to return int, and then it didn't like that I declared it with a return value and then didn't provide it...


Ok, but those examples are not working if properly burned on chip. But something rude like that:
Code:
void a();

void a()
{
Serial.begin(9600);
  pinMode(1, OUTPUT);
}

int main(){
while(1){
pinMode(1, OUTPUT);
  }
  return 0;
}

compiles well. So it doesn't recognize syntax only, but include also the necessary. And here comes up my original question, how? The approach to this C/C++ language so it's different to another C/C++ language. How? And why, if it is the same exactly? thank you smiley
4  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 21, 2013, 02:46:33 pm


Nor does automatically providing the base #include files.
Then explain to me why the main() fuction above is working "without them". (I'm talking about user implementation of headers, of course that thay are automatically added, as I said before)

Quote
but Arduino *is* C (well, C++)
http://arduino.cc/en/Guide/Introduction
"The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment."
And
"The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. SImilarly, you can add AVR-C code directly into your Arduino programs if you want to."
Why shoud they make this separation of categories if it is exactly the same? For the last sentence about adding code, is true, since is everything surfing on C/C++ luckily.

http://arduino.cc/en/Reference/HomePage, at the bottom.
"The Arduino language is based on C/C++. "
So they are incorrect. The forum is intended to checking purposes too.

Quote
It uses a very standard C compiler, and has access to the same avr-libc implementation that you'd be using if you were using Atmel Studio 6 to program the same chips. 
I know. I never said that the mechanism is different, I'm talking about the user approach.

Quote
"Wiring" isn't "a language based on C", either.
Could be interesting. So, same as Arduino?

Quote
Nor can you call yourself a "C Programmer" after the typical 1-semester university class that happens to use C.
I'd like a lot if would be only a semester. Unfortunately I've finished those years...

Quote
(I guess you could have an interesting argument about whether avr-g++ is really C++, given that it doesn't have a C++ runtime library...)

I nevere asked it to my self, is not my field and since is accepted as a standard in AVRs and I use C tipically.
5  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 21, 2013, 09:25:11 am
In a real C I've to include all header files, which your
Code:
int main ()
  {
  return 0;
  }

don't have: everything is still quite hidden, giving a different approach to a pure C. I've to digg if I want to see everything even in this case.
You know what was the misunderstanting? PaulS and you might have right, but not because Arduino Language is C/C++, but if you mean that is BASED on it. It is written on this site too (Arduino.cc  smiley ), and is different to me.
That means for me which you don't have to learn C (applied on MCUs) to use it thanks to the libraries developed ready to help you, learning only -how- to use libraries and not how to create them. You can do it, since all language is no more than high level functions -written- in C, so it's quite natural that I can write in C too.
"Based on" means that you have some differences, like Setup() and loop(), pre-written in C, which is the goal of the IDE. Of course, you can write in almost-pure C like you said before. In real pure-C environment no one write those things, except for stdio stuff et similia. So, it's C, but not with a pure approach (if you don't want to). It's a slight difference. Under this point PaulS have right, you can use the same language if you want.

But this leads to the next answer:
For fake things I mean someone that says which is able to program a microcontroller and knows C because have used Arduino. Most of them don't know how to use printf() functions (those famous already made, but are STANDARD functions, not like Arduino ones), are not capable to manage registers in a microcontroller and embarrassing stuff like that, all of this from people saying that are capable to program an MCU, or are not capable to use a Timer because "they never used" it before (never used explicitly, of course), while it is a mandatory knowledge about that. And thise because they was think that this was "pure" C, expecting to have some (and simple) stuff already made, where in some environment is NORMAL (and sometimes mandatory if you need particular configurations) doing it by your self and does not require too much time.

But this leads to the next answer:
configurations are intended like the procedure to follow for setting and activating of USART module, to say one example.

Maybe understanding the difference between BASED ON and IT IS could be the key to understand each other.   smiley In a way I said what you say, but a bit more precise. This little difference is the success of Arduino, one can't deny that. I'm happy for this, I've an Arduino Duemilanove too, but I find ethically right to explain well things. It's important for newbies or "people who don't care right know" (i.e. artists w/out a kind of knowledge, of course).


This is the reason why companies don't use Arduino, and in almost all universities is recommended to be used only for proto-proto-prototyping, translating to see only if the idea work. An MCU pure-C language allows you to predict a single clock cycle, which you can't in Arduino IDE (this is said by Arduino "staff" makers that work in Turin, during a presentation). Which is fundamental saying that is BASED on C and for learn a good C programming manner is not the best using the IDE. And this is not (only) my idea.
6  Using Arduino / Programming Questions / Re: TWI/I2C on: October 20, 2013, 06:06:08 pm
Quote
something different from Arduino Language like C
The "Arduino language" IS C (and C++). Get over it.

You've right if you modify the Arduino core files as we talked about few days ago. The final user have a different approach, he/she will use the SW layer developed in C/C++, but this layer is made to hide this C language. It could be written a pure C too, but it's not mandatory to make a working sketch. So it can't be C. The C programming NEVER require a setup() and loop() functions, which are mandatory in a Wiring language. The C programming require a lot of headers added somewhere and the final user should know them. Here are hidden in wiring.c/h files and so on. in the IDE there is not C, there is C-like.
People like Davide Gomba, which have worked along Massimo Banzi and responsible for some big Maker spaces, said that you can program it w/out having any knowledge in programming. Do you think you able to program in C w/out knowledge? The C work is made by the Arduino team and is made for people that have different goals than learn C or are new in this field. Like I did years ago.
People that make thing done with Arduino, even the prettiest, can't say that they are able to use C if they never studied it.

If you want, you can apply the scientific method. Take AS6 and write your project written in Arduino IDE inside the Atmel IDE and see what you have to do to make it work. Could be very educational for you knowledge, maybe one day you will understand this too.

Your "get over it" make a sense of little irritation against me, I hope not, I simply said a fact. If someone don't want to understand (I hope not you), is not my business to insist on it.

Btw, I hope Resinator tell us something when he will solve his though, helping community inside this forum. smiley-wink
7  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 20, 2013, 05:39:07 pm
It simple, I don't like to read fake things on Arduino on the Arduino site. There are too many people that can be manipulated by those (unintentionally) fake informations on this site.
And unfortunately I've some reasons to think this.  smiley-sad
8  Using Arduino / Programming Questions / Re: TWI/I2C on: October 20, 2013, 04:03:44 pm
In my opinion, if someone want to use something different from Arduino Language like C, it's mandatory reading the datasheet  and make proper libraries maybe, if you want, copying pieces of code from the arduino core or using google. According to Resinator purposes.  smiley
9  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 20, 2013, 03:53:30 pm
Read http://en.wikipedia.org/wiki/C%2B%2B or google "C++ constructor"

Oh ok, I see... I'm only an analog electronic engineer, not good enough in programming  terms used in C++ (I used it only few times)

Quote
There are now two separate hardware projects, Wiring and Arduino, using the Wiring environment and language
Finally one that support my thesis and read my links, Arduino is programmed in WIRING ENVIRONMENT AND LANGUAGE (Arduino is a kind of a comm€rcial spin-off of Wiring). Since it's born from Wiring, use the same tools. Of course, it's another project with other libraries, and of course IS BASED on Wiring, but substantially is Wiring. Writing a dummy row like "digitalWrite(ledPin, HIGH);" is NOT C++ like Paul says. I can't read this blasphemy jajaj
This "dummy row" follow the Wiring language with different libraries. And it said even in the Arduino IDE itself, I can't see why should be different.
Try to be not manupulated by the market, like someone that the other day said that the Arduino boards are made to barely cover the cost production only because they are "good people" or some excuse like that.
10  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 20, 2013, 02:59:35 pm
Quote
Are you telling me that Arduino is NOT using Wiring, based on an open source Java language named Processing.
The IDE is written in Java. The Arduino is not programmed in Java. It is programmed in C++.

Again, tell me how is called that language.
I knew that "the Wiring IDE is a cross-platform application written in Java which is derived from the IDE made for the Processing programming language".  It's neither C++, libs are witten in C++, you simply use the Wiring interface. You should know that.

Read.
http://en.wikipedia.org/wiki/Wiring_(development_platform)

Btw, when you wrote "except for constructors".. WHO are they? Who are constructors? What does it mean constructor?
11  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 20, 2013, 12:14:40 pm
Quote
No any clues at this moment?
I don't even have a clue what your problem is. I think the ball is on your court.

Maybe you've lost my latest post smiley

This is the central part of problem, that I can't know in advance:

What about changing frequency and still using Wiring? I can do that because I can simply write in registers (all of them are well declared and r/w able) and regardless the change of pwm freqency will work or not, I trying to understand when the PWM freq default setting is loaded after reset state, so I can know where to put in my code my new freq setting and make sure that this setting will remain forever until I will choose to change it -explicitly- again.

It seems to be pretty clear what I'm trying to understand. The ball is yours too now smiley-razz
12  Using Arduino / Programming Questions / Re: TWI/I2C on: October 20, 2013, 07:16:52 am
So you want to learn C better. Great choice it gives you a really solid base of microcontrollers programming, since it's standard (and so easily portable out of the Arduino world) and used for every microcontrollers and makes you able to read efficiently datasheets.
If I undesrtand well, you have already programmed using Atmel Studio but you've never used I2C? Well, if you know C programming, it's simply matter of reading chapter related to I2C on datasheet.

Keep in mind that if these reading are the firsts, you may pass some days w/out making something work. It's normal, but after that period, you can read with some ability every mcu datasheet. But seems this is not your case.

Sorry if I misunderstand.
13  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 20, 2013, 06:59:16 am
No any clues at this moment? smiley
14  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 17, 2013, 04:21:23 pm

Whether you need to go back to pure C is completely up to you.
What's your specific issue that you're trying to solve?

First of all, thanks for the help.
For NOW, I just need to explore possibilities and compatibilities of programming rule, if they can be compatible with a pure C approach w/out rewriting Arduino libraries, otherwise the simplification of Wiring goes away and became simpler to use a classical C. For example, is too simple the PWM approach to justifying a newbie to use Wiring language, but what about changing frequency and still using Wiring? I can do that (not now, to be honest, I don't have any Arduino here right now) because I can simply write in registers (all of them are well declared) and regardless the changing freq will work or not, I trying to understand when the PWM freq default setting is loaded after reset state, so I can know where to put in my code my new setting and make sure that this setting will remain forever until I will choose to change it -explicitly- again.

I hope to be explained smiley
15  Using Arduino / Programming Questions / Re: Programming registers and function recalling on: October 17, 2013, 06:02:19 am
You can use avr-size to check out the compiled sizes in your temp directory. And avr-objdump -x to disassemble your elf file and find out what gets linked into your final binary.

It tell that a.out is not a file. How can I use this avr-objdump? Here, I've never used before those commands and seems not too easy understand directories organisation.

Coming to my post: wiring.c has a fully configuration. But when those functions are called? If I don't want to call them anymore during execution and/or neither at reset, should I coming back again and write in pure C in an IDE like AtmelStudio? Or there is some kind of control w/out rewriting functions inside wiring.c?
Pages: [1] 2 3 ... 9