arduino .h files

hy am a nooby to micro controllers and the arduino development bored
but am loving it to be honest.

lately i have been attempting a project with it and part of the work i have to do for college is understanding the .h files how the codes for the compiler are written ( in assembly for the ATD and PWM )

i cant seem to find any info on that anywhere .. if anyone knows how to or what should i do exactly to get the information i want please tell.

Ps: am still reading the Atmels user manual.

thank you

A .h file is not meant to be a standalone file that the compiler understands. It is meant to be included in a .cpp or .c file, that the compiler does understand.

Understanding a .h file is as easy (or difficult) as understanding a .c or .cpp file.

i honestly dont understand .. i want the files that have all the asembly codes for the microcontorller basicly .. the ones that have all the movb to bla bla

setting output ports to ports h or b as an example ..

amongest other things

to see how the ADC and pwm are programmed

or how the boot looder on the chip miniplates the files :frowning: am i makeing since ?

PS: thank you for replaying

What you're asking for is not necessarily going to be in .h files is the thing; I suspect you have a mistaken understanding of what .h files are.

That said, poke around in the hardware\cores\arduino directory. There's a fair bit of inline assembly in the .c and .cpp files. That said, if you're interested in learning assembly then you're probably better served by going ahead and looking at an AVR assembly tutorial like this one http://www.avr-asm-download.de/beginner_en.pdf and buying/building yourself a programmer instead of using the Arduino bootloader.

A sketch for the Arduino is a .pde file that contains only a portion of the program. There is no main(), for instance.

The sketch can include .h files. When the Arduino IDE's Verify button is selected, there is a lot of stuff that happens. A .cpp file is created, with function prototypes for all functions defined in the .pde file. A main function is added.

Then, the compiler is invoked. A pre-processor is run to deal with all the #include, #define, #ifdef, etc. statements. Then, syntax parsers and a variety of other functions are invoked, to make sure that the code is valid, to allocate storage space, to convert the C statements to assembler instructions, etc.

A number of other .cpp files may be compiled, too. The end result is a .o file.

Then, a linker is invoked to combine the appropriate sections from the .o files, perform memory translation, optimization, etc., resulting in a .exe (or .hex for the Arduino).

The intermediate files are not stored.

If you want to capture all the intermediate files, there are compiler options to do that, but they are not set by the Arduino IDE.

There are ways to invoke the compiler directly, and set the compiler and linker options. The resulting .hex can then be uploaded to the Arduino, but not by using the IDE.

There are tools for reading the .o files, which can reveal a lot about how the compiler works. There was another thread recently that had some links.

Perhaps you are talking about the ".hex" files that usually used as the "last step" before loading the code into the microcontroller? (these contain only "object code" - pure numbers - rather than assembly code, but they're closer to what you're asking about than .h files.)

When you compile and upload a sketch "MySketch", the arduino environment creates an "Applet" directory underneath /My Documents/Arduino/MySketch/Applet, and assorted intermediate format files (include .hex files) are stored there. The more interesting files are the .o (intermediate object) and .elf (final object) files. While these are not in a form that can be directly loaded into the microcontroller, they DO contain additional symbolic information that allows you to do things like create a mixed object code/assembly code/C code listing using tools like avr-objdump. See http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1193790150/1#1 and/or search the forums for "objdump"...

Even the low-level functions (writing PWM, reading ADC) in the arduino environment are written in C or C++.
You can find them somewhere in the arduino install directory .../hardware/cores/arduino/wiring_analog.c and similar. (of course, the object code from these appears in your sketchs .elf file, and will show up in the dump produced by objdump...)

ok, another Qustion then.

the arduino is based on atmel chips right ?

so lets say if i go to the data sheets and check out what bets to send to have an 8bit adc or 10 bit dc or how to set up the pwm ... etc stuff like that with normal microcontrollers ...

what i wana know is how dose the arduino do that :open_mouth: how dose it .. tranform the code ... from the c we write .. to what ever the chip undersatands ...

and again am sorry am a biggner here .. please bare with me plus english is not my first language. so am having a hard time just reading the posts the data shets .. references .. code examples ..

would my answer be in the .o files .. and if soo how do i access or open those files ?

would anyone be aware of how the atmel chip dose stuff with out the arduino boot loader or the sketch software .. if so and u have links please post them here ..

am learning alot by your replays thank you all.

The Arduino does not convert the C code to something the chip understands. That is the job of the compiler and linker.

The compiler/linker that the arduino.exe uses is the avr-gcc compiler.

It operates just like any other compiler. The (hidden) header files that are linked in are included from the WinAVR program, on Windows. These header files provide mappings from the analog or digital pin numbers to ports on the various atmel chips.

Reading and writing to those ports is, then, exactly the same as any other micro-controller.

i 've been reading up in the forums for the past couple of hours .. i think i understand now some what of whats going on .. the .o files and .elf files .. avr-obje file has to be linked somehow to the sketch code to complie or create sorry a another program in assembly .. this is mostly what am intrested in seeing all the codes in assembly so i can compare them to the atmel data sheet and see how the code is constructed. its actully killing me cuz i am " A NOOB " yes .. lol
i honeslty cant tell what am doing but am loving these arduino chips or kits .. i have the mega which am trying to do alot with at the moment .. and its not bad at all ( for a to do enviorment ) not as a learning enviorment ..

again am learning alot by your replays please keep on replying and teach this noob