Pages: [1]   Go Down
Author Topic: Documentation for special/system variables/constants?  (Read 324 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure if that's the correct name for them. I mean the variables that access things in the PC when compiling the sketch - things like PC system time.  I also mean variables that access the registers in the arduino  like I found in this example below for interrupts (if I understand how it works, it is directly setting registers in the atmel chip).   I just haven't been able to locate the documentation for them.

Code:
//set timer1 interrupt at 1Hz
  TCCR1A = 0;// set entire TCCR1A register to 0
  TCCR1B = 0;// same for TCCR1B
  TCNT1  = 0;//initialize counter value to 0
  // set compare match register for 1hz increments
  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS10 and CS12 bits for 1024 prescaler
  TCCR1B |= (1 << CS12) | (1 << CS10);  
  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
« Last Edit: February 10, 2013, 09:59:48 pm by digimate » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just haven't been able to locate the documentation for them.
They are all defined in the data sheet for the processor you are using.
Do a search for ATmega 328 and pick the top PDF
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 652
Posts: 50854
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just haven't been able to locate the documentation for them.
Have you looked at the Atmel documentation for your chip?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I am not looking for the documentation on the atmel chip.  I am looking for the documentation of the language used to write sketches.  It seems this language has special variables to access things - like the register example I gave, and also things like the PC system time (useful for setting RTC's at compile time). Another example would be the name of the routine it looks for when it encounters an interrupt.

I just haven't found where they are documented.  I looked here file:///usr/share/arduino/reference/index.html, but can't see it.

This page has examples of special variables for many languages so you can see what I mean http://rosettacode.org/wiki/Special_variables
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The definitions are scattered through the Arduino installation, but for example the register addresses you asked about used are defined under board-specific files under hardware\tools\avr\avr\include\avr\.

They aren't documented as part of the Arduino runtime environment, I suppose on the basis that they aren't part of the API - they are part of the implementation. It's possible to bypass the Arduino library and access the hardware directly, and obviously various clever people have done that - and some of them have documented what they did and how it works - but those definitions are not documented as part of the API.

You mentioned the __DATE__ and __TIME__ preprocessor directives. There are some macros and directives which are defined by the C++ language, and others that are added by the GCC compiler that Arduino uses. These are also not part of the Arduino API and so are not covered by the Arduino documentation, but you're free to look up the language specification and compiler behaviour for yourself if it interests you.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The definitions are scattered through the Arduino installation, but for example the register addresses you asked about used are defined under board-specific files under hardware\tools\avr\avr\include\avr\.

They aren't documented as part of the Arduino runtime environment, I suppose on the basis that they aren't part of the API - they are part of the implementation. It's possible to bypass the Arduino library and access the hardware directly, and obviously various clever people have done that - and some of them have documented what they did and how it works - but those definitions are not documented as part of the API.

I see.   So, if I read you correctly, the example I read on setting the timer to execute an interrupt is bypassing a normal way to do it.     Obviously so did I smiley.    So I should look for a library the makes it easier to set up an interrupt routine then?

You mentioned the __DATE__ and __TIME__ preprocessor directives. There are some macros and directives which are defined by the C++ language, and others that are added by the GCC compiler that Arduino uses. These are also not part of the Arduino API and so are not covered by the Arduino documentation, but you're free to look up the language specification and compiler behaviour for yourself if it interests you.

Ah, so I will look up some references on C++ and GCC then.  I guess it never occurred to me, being new to how it all works, that I could use native C++ stuff inside a sketch.
Logged

Pages: [1]   Go Up
Jump to: