Where to find avr/io.h and avr/io.cpp

Hello All,

Another probably very trivial question.

I am trying to locate either on my hard drive or the WWW, files, part of the the Arduino 'core' libraries. The .h files. I found in the .....
\hardware\tools\avr\avr\include\avr\ on the hard drive, no sign of the .cpp files there.
During my searching, for some time now, I have seen directories containing both files or even more than 2 ( probably on the internet ) but I am not
able to locate them any longer.

For Arduino users this question might be a very basic, most likely a dumb one. As a new user though, I do not understand why it is
that the subject of "include files" is so poorly covered? Actually it is not covered at all by the Arduino documentation as a far as I can see.
Many other subjects are covered over and over and in great detail.

I am quite frustrated that I have to ask these kind of very basic things. Years ago I did some, be it hobby work, with
Turbo C , Java, Visual C, and the subject of finding Include files and so on, never came even up.

Is there any reason for this? It seems to be a very basic requirement for people that like to do more then turning LED's
HIGH and LOW. I do not dare to think what would happen if I wanted to do some math with the Arduino.
I see on the other hand, that the Arduino boards are used for much more exciting tasks than LED' operations!

What surprises me even more is the fact that for most Arduino users young, old, new, experienced, this appears to be
no point?? What am I missing here?

In the Arduino documentation are numerous spots where examples of code are listed. Not sure at this point whether any
or how many of those use #include files. If any are present though, one would expect directions how to make this work.

BTW I believe I can actually make the same point for a subject like "Arduino core library".....

My thanks in advance,

Rein Smit

avr/io.h and avr/io.cpp ... I am trying to locate either on my hard drive or the WWW, files, part of the the Arduino 'core' libraries

io.h is part of AVR Libc not the Arduino Core...

io.cpp is not part of the Arduino world.

As a new user though, I do not understand why it is that the subject of "include files" is so poorly covered?

A Google search has 817,000,000 hits. Which leads me to believe that you may be able to find the subject of "include files" documented in other places. Which also makes me wonder why anyone would want the Arduino folks writing "include file" documentation instead of working on the IDE, Core, Libraries, or boards.

I do not dare to think what would happen if I wanted to do some math with the Arduino

Do you actually own an Arduino (compatible) board?

Hi,

I own 2 UNO boards and an USBtinyISP board.

Don't understand what that answer has to do with my remark of wanting to use an UNO board to do some calculations.

It clear that you as a Global moderator are not able to help me. Your answer is as hundred's of others on this board.
Sending people in no man's land like "why don't you read the manual"

I am trying to find in the manual an answer why I can't compile this this little routine:

#include <avr/interrupt.h>
#include <avr/io.h>

#define INIT_TIMER_COUNT 6
#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT

int ledPin = 13;
int int_counter = 0;
volatile int second = 0;
int oldSecond = 0;
long starttime = 0;

// Aruino runs at 16 Mhz, so we have 1000 Overflows per second...
// 1/ ((16000000 / 64) / 256) = 1 / 1000
ISR(TIMER2_OVF_vect) {
RESET_TIMER2;
int_counter += 1;
if (int_counter == 1000) {
second+=1;
int_counter = 0;
}
};

void setup() {
Serial.begin(9600);
Serial.println("Initializing timerinterrupt");
//Timer2 Settings: Timer Prescaler /64,
TCCR2 |= ((1<<CS22) | (0<<CS21) | (0<<CS20));
// Use normal mode
TCCR2 |= (0<<WGM21) | (0<<WGM20);
// Use internal clock - external clock not used in Arduino
ASSR |= (0<<AS2);
TIMSK |= (1<<TOIE2) | (0<<OCIE2); //Timer2 Overflow Interrupt Enable
RESET_TIMER2;
sei();
starttime = millis();
}

void loop() {
if (oldSecond != second) {
Serial.print(second);
Serial.print(". ->");
Serial.print(millis() - starttime);
Serial.println(".");
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
oldSecond = second;
}
}

Your remark about:

io.h is part of AVR Libc not the Arduino Core...

io.cpp is not part of the Arduino world.

shows clearly that you are more of a policeman than a helpful member of this group.

It should be quite clear why why I ask the question in the first place.

Thanks for those helpful answers anyway.

Rein Smit

2 Likes

shows clearly that you are more of a policeman than a helpful member of this group

Yup. That's me. Baton swingin' hippie beatin' jackboot thug.

And, to prove that you are correct about me, I'll let someone else help you.

2 Likes

I am trying to find in the manual an answer why I can't compile this this little routine:

Perhaps if you told us what board you were trying to compile this for, and what errors you are getting, and why you think that this board-specific code should compile for your board, we could help you.

And, if you checked your attitude at the door, that would help.

1 Like

Hello PaulS,

Thanks for your reply.

First an answer to your question.

I am new to this project. Though, I have been doing a lot of reading, searching, etc and assume that many on this forum do the same.
Perhaps in doing so I have gotten the impression that programming these boards is simple etc etc. On YouTube and in many pages,
I believe, it is to a certain extent sold as such.

I have a pair of UNO boards and looked up a couple of small programs that do interest me. They are mostly related to analog sampling
and a number of those programs need include files.

So what I found is that, whatever I tried I could not get "include files" added in the Library files and thus it would not compile. All kind of
messages about undefined names, unknown variables. etc.

Since my last writing, I have been able to figure how to add those special libraries. I still think is not very well explained on the ARDUINO
home page how to do it, but now that I know, how to do it, I can live with the indicated procedure. And could explain others, if I saw it
asked for.

So this problem has been solved.

I can imagine that you think I have an attitude and that might well be so but that is not my intention.

I asked a reasonable question, I think, and got attacked and thrown out of the section as "no ARDUINO" related, I figure.
Reason, I took a an AVR .h file as a name for an include file. When I said a remark about calculating, I was asked whether I owned
a Arduino board!

As said I am new to this FORUM and have to get probably used to Moderators moderating without any real reason. ( Just an opinion )
That's what triggered it.

Assuming that the moderator is familiar with the Arduino software, and I am sure he is, I had expected he would answer the question. It was
after all about Arduino's way to add files to a collection. He could have added a remark that the question did not really belong
in the particular section. That would have been no problem for me .

This kind of Forums are of course very useful in particular for newcomers as myself and I just have to get used to the procedures,
I guess.

More over, I am always very thankful to receive an answer especially when it helps solving a problem.

So thanks for your response and I hope, I could explain what happened.

Regards,

Rein Smit

Rein;

Your not the first to have problem about installed 3rd party contributed library files. It is covered in the getting Arduino Development Environment document in the Getting Started section located at the main site, but it's pretty far down the doc and most users are at that time so happy to just get the board working that the later importance of this topic gets lost I Think. So I'm glad you figured it out, but lets leave this cookie trail for future searches for the subject.

Anwhere, here is how it's explained:

Libraries
Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from the Sketch > Import Library menu. This will insert one or more #include statements at the top of the sketch and compile the library with your sketch. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its #include statements from the top of your code.

There is a list of libraries in the reference. Some libraries are included with the Arduino software. Others can be downloaded from a variety of sources. To install these third-party libraries, create a directory called libraries within your sketchbook directory. Then unzip the library there. For example, to install the DateTime library, its files should be in the /libraries/DateTime sub-folder of your sketchbook folder.

And of course is located in this doc: http://arduino.cc/en/Guide/Environment#libraries

Make sure these 'names' (TCCR2...) do actually exist for your type of microcontroller/board. The datasheet is your friend. I may be wrong, but I think I've read stuff like TCCR2A or TCCR2B somewhere else. Not in your code at least.

Hi Paul,

Thanks again. I had seen that part, but obviously it did not click here.

I did not get that one has to enter libraries via the sketch book. I guess Arduino does it that way as some
form of file management.

( sketch book , sketch folder, for sketches to contain )
( libraries for libraries for libraries to contain )

The to add libraries have also to go via the sketch book. Once you know and understand it. it is no big point.

Because I did not follow that path but manually loaded the files in a Libraries/libraries directory and then they would not show up!

Anyway.

While you are at it. How can I locate non Arduino libraries such as for instance avr/interrupt and avr/io or perhaps the math library?

Just went to a stk500 get sync() lock up ( loadup failure problem ) But managed to get it fixed via a reset - bootloader-loading - other sketch loading operation. It
worked after 5 trials.

Regards,

Rein Smit

Hi,

Thanks for response on the 'TCCR2' et al names.

I just listed that program at the beginning of this thread as an example of a program where one needed to include a library.

Part of the misunderstanding did arise as it concerned /avr/.... libraries, I think.

My original question was on how to load the include libraries so that I could call and use them in the sketch files.

I thought that the TCCR2 etc names are defined in the avr/interrupt.h file. I guess at this point they are registers of the controller.

Have not really looked into this as I do not quite understand the concept of having counters preload and then overlaoding and use
the overload condition as a divider. I understand the idea but not quite the code here how to do it.

So thanks much for you reaction.

Regards,

Rein Smit

Ah, OK.

In case you will need it in the future, look at ".../include/avr/io.h" for register name definitions. Or the datasheet :wink:

Fine.

Thanks

Rein Smit

A good idea, is to use a free program like TotalCommander, and set it to search for the file.
io.h can be found in ArduinoINSTALLED\Arduino\hardware\tools\avr\avr\include\avr