short summary of C-programming language for AVR microcontrollers

Variable Types

typebitsrange
bit 1 0,1
char 1 –128 to 127
unsigned char 1 0 to 255
short  2 –32768 to 32767
unsigned short
2 0 to 65535.
int 2 –32768 to 32767
unsigned int
2 0 to 65535
long 4 –2147483648 to 2147483647
long unsigned
4 0 to 4294967295
float 4 –3.4e38 to +3.4e38
double. 8 1.7e308 to +1.7e308

 

 

 

 

 

 

 

 

 

Operators

=
Assignement operator
+ Addition

Subtraction
/
Division
*
Multiplication
Remainder
count++  post increment
++count pre increment
count-- post decrement
--coun pre decrement

 Logical Operators

! Boolean NOT (unary operator)
&& Boolean AND (binary operator)
| | Boolean OR (binary operator)

 Bitwise Operators

Negation (unary operator)
Bitwise AND
Bitwise OR
Bitwise exclusive XOR
>>  Right shift of bits (equivalent to division by 2)
<< Left shift of bits (equivalent to multiplication by 2)

 

 

 

 

 

 

 Relational Operators

==  Equal
! =  Not equal
Greater than
Less than
>=  Greater than or equal to
<=  Less than or equal to

 


 I/O Port management

  • DDRx Data direction register
  • PORTx Data output register
  • PINx Data input register 

Header Files

io.h The file reads the microcontroller name from the MAKE file and includes automatically the specific corresponding header file. The file defines the I/O port adresses, bit names, vector adresses etc
interupt.h This file includes the interups vector names.
delay.h this file include two accurate delay functions: _delay_ms and _delay_us.
pgmspace.h This file is used to store and retrieve constants from the program memory