I have been trying to find the source code for anaologwrite()
I have wasted a lot of time and just seem to be running round in circles only finding the description not the a link to the source :
This is called "language reference" why is there not link to the source code?
I also looked at the fade example code expecting to find include statements or something but there's nothing.
avr-libc does not seem to have anything to do with these "helper functions" either , so where is the real code that the IDE is hiding from the naive user who does not know how to program?
The examples are nice what to "get something to happen".
I have run the "fade" example but I do not want a PWM running at 490Hz.
The IDE would be a lot more use if I could click on "analogwrite" function name and it would open a new window displaying the code of that function.
These libs are fine for blinking LEDs but it would be of much more use if it gave an easy path to the details of what you need when you want to start doing some real world hardware control
If someone could point me at the source code for these high level functions it would be very helpful.
how silly of me not to look in a file called wiring_analog.c for code that programs a digital output.
I'd found the header declaration in Arduino.h but was having trouble finding the actual c code.
I'm still trying to understand the structure of Arduino code. The on-line doc is not much help when it calls a sketch a program when it does not have any includes or anything. There is an implicit structure that I have not found documented. I'm sure it is , it's just well hidden, rather than being clearly stated in the "language reference".
As far as I have found in several hours trudging around the so-called language reference it does not map out an overview of the true structure of an arduino program in terms a programmer looks for.
I had not found out where this source gets installed at that point.
That was the basic question that was the subject of this post. I don't see anywhere obviously visible that says : the source code is installed locally in ..... and a copy of the current stable release is to be found here http ....
Sure, now I know there is a locally installed copy of the source I can search it with grep.
ardnut:
maybe I have not woken up properly yet but...
#'Arduino.h
void analogWrite(uint8_t, int);
#wiring_analog.c
void analogWrite(uint8_t pin, int val)
In C++ the names of the arguments aren't necessary in the declarations. They're also not necessary (or recommended) in the definitions if you don't want to use the passed values in the function.
I guess after a while through forums googling etc. you finally get to figure out how it all works. I just don't find it clearly documented.
A "sketch" is not a program. It does not have main() and does not have any #includes to indicate where it finds the various helper functions it uses.
Now it's fine to load and example and flash a LED. Cool. Now I want to find out how to control the hardware to do a real job.
Rather than pretending a GPIO line is an analog output, I need a PWM.
First thing I need to know is the frequency it operates at. I need to look at the full source code , not the noddy helper helper function descriptions that carefully don't tell you anything that might frighten me.
Where is main(), what is the search path for source and include files?
Assuming I need more control than just blindly calling high level helper functions, I need the big picture and source code from the top down , not sanitised "script" files which is essentially what a sketch is.
This is not a high school discovery project , I want to use the hardware.
Now the IDE offers some degree of hardware abstraction avoiding porting between different boards and also communicates with the bootloader. No need to reinvent the wheel.
Some of the high level functions will be handy and should speed up development but I will also need to dig deeper at certain points like PWM frequency. Is it suitable out of the box, if not how do I change it?
Maybe I just haven't found it.
thx
PS I now know some of this but the key question is one of documentation. I should not have to be posting forum questions and trawling google for snippets of information. Where's the doc?
Really, it is. Use AVR Studio, if you don't like the way the IDE works. Head over to AVR Freaks (http://www.avrfreaks.net/). Nobody is forcing you to use the Arduino IDE.
You could look up PWM on the Arduino site and find the frequency is about 490 Hz. And then find what you can do to change that -and- the timing consequences. All that without reading a line of source. You might find it simpler to turn a pin on and off yourself. Someone who can check the IDE source should have No Problem doing that.
Or you can do like some others; set up a PWM and use another pin to see what it's doing. Or if you have a scope then find out even quicker and easier.
If you really want to 'get serious' then get to the ATMEL site and download the docs on the MCU you're running then get the tools to do AVR assembly, join the AVR Freaks forum and get as close to the metal as you can, or mix Arduino C++ and AVR assembly -- there's a nice get-you-started page on the AVR LibC site linked to down on the lower right of the Reference (for beginners) page of the Arduino site.
ATMEL has loads of docs, never short you on docs, it does cost some but maybe that's why you get the complete serious-up professional bundle. They give you everything but talent!
The people on this forum have no control over the language reference section. Nada. So being aggressive is just going to annoy the very people who might help you, and be ignored by whoever writes the reference.
Like I said I've found most of that now but only by trawling google and the forums and it took a long time find it.
If you strip the last element of those URLs it seems none of those articles is linked from its parent directory. Indeed Code directory itself is not linked from playground homepage.
That confirms my point that a lot of this is hit and miss , not properly documented.
Maybe I just haven't found it.
So it would seem.
It would seem what? That is there is clear centralised documentation that I have not yet found? That you post three unlinked snippets rather than one URL I had missed, seems to suggest the opposite.
This is not a high school discovery project
Really, it is. Use AVR Studio, if you don't like the way the IDE works. Head over to AVR Freaks (http://www.avrfreaks.net/). Nobody is forcing you to use the Arduino IDE.
Yeah right , the step in that logic is : of course it's documented it's open source.
Or, it's free, what more do you want?
It seems clear from the replies here that the answer is "No. There's not clear doc but after about six months you find you way around , then you become a guru like us. "
It seems a few replies are sincerely trying to be helpful but there is not short answer like I've missed key reference site.
Trawling google and the forums seems to be about all you get.
The idea of a rapid development board seems appealing and I noted a couple of advantages for what I'm doing above. That's why I've bought one and spent a lot of time looking into the feasibility of using it.
GoForSmoke:
Or you can do like some others; set up a PWM and use another pin to see what it's doing. Or if you have a scope then find out even quicker and easier.
LOL, Yeah, like I could use a scope to work out the frequency response of an op-amp if I really wanted to. The usual way is read the doc. Most products provide this in a clear centralised place.