CodeVisionAVR User Manual (13tr)
CodeVisionAVR User Manual (13tr)
4.2 Comments
The character string "/*" marks the beginning of a comment.
The end of the comment is marked with "*/".
Example:
/* This is a comment */
/* This is a
multiple line comment */
__eeprom
__flash
__interrupt
__task
_Bool
_Bit
break
bit
bool
case
char
const
continue
default
defined
do
double
eeprom
else
enum
extern
flash
float
for
goto
if
inline
int
interrupt
long
register
return
short
signed
sizeof
sfrb
sfrw
static
struct
switch
typedef
union
unsigned
void
volatile
while
4.4 Identifiers
An identifier is the name you give to a variable, function, label or other object.
An identifier can contain letters (A...Z, a...z) and digits (0...9), as well as the underscore character (_).
However an identifier can only start with a letter or an underscore.
Case is significant; i.e. variable1 is not the same as Variable1.
Identifiers can have up to 64 characters.
The bit or _Bit data types are not allowed as the type of an array element, structure/union member,
function parameter or return value.
In order to use the bool data type, the stdbool.h header file must be #included in the source files
where this data type is referenced.
/* type definitions */
typedef unsigned char byte;
typedef struct {
int a;
char b[5];
} struct_type;
/* variable declarations */
byte alfa;
If either of the operands is of type float then the other operand is converted to the same type.
If either of the operands is of type long int or unsigned long int then the other operand is converted
to the same type.
Otherwise, if either of the operands is of type int or unsigned int then the other operand is converted
to the same type.
Thus char type or unsigned char type gets the lowest priority.
void main(void) {
int a, c;
long b;
/* The long integer variable b will be treated here as an integer */
c=a+(int) b;
}
void main(void) {
unsigned char a=30;
unsigned char b=128;
unsigned int c;
For these operators, the result is to be written back onto the left-hand side operand (which must be a
variable). So the compiler will always convert the right hand side operand into the type of left-hand
side operand.
4.10 Operators
The compiler supports the following operators:
+ -
* /
% ++
-- =
== ~
! !=
< >
<= >=
& &&
| ||
^ ? :
<< >>
-= +=
/= %=
&= *=
^= |=
>>= <<=
sizeof
After being freed, the memory block is available for new allocation.
If ptr is null then it is ignored.
float sqrt(float x)
float floor(float x)
float ceil(float x)
splits the floating point number x into integer and fractional components.
The fractional part of x is returned as a signed floating point number.
The integer part is stored as floating point number at ipart.
float exp(float x)
returns ex .
float log(float x)
float log10(float x)
float sin(float x)
returns the sine of the floating point number x, where the angle is expressed in radians.
float cos(float x)
returns the cosine of the floating point number x, where the angle is expressed in radians.
float tan(float x)
returns the tangent of the floating point number x, where the angle is expressed in radians.
float sinh(float x)
returns the hyperbolic sine of the floating point number x, where the angle is expressed in radians.
float cosh(float x)
returns the hyperbolic cosine of the floating point number x, where the angle is expressed in
radians.
float tanh(float x)
returns the hyperbolic tangent of the floating point number x, where the angle is expressed in
radians.
float asin(float x)
returns the arc sine of the floating point number x (in the range -PI/2 to PI/2).
x must be in the range -1 to 1.
float acos(float x)
returns the arc cosine of the floating point number x (in the range 0 to PI).
x must be in the range -1 to 1.
float atan(float x)
returns the arc tangent of the floating point number x (in the range -PI/2 to PI/2).
returns the arc tangent of the floating point numbers y/x (in the range -PI to PI).
The LCD functions do support both the XMEGA and non-XMEGA chips.
The following LCD formats are supported in alcd.h: 1x8, 2x12, 3x12, 1x16, 2x16, 2x20, 4x20, 2x24
and 2x40 characters.
The allocation of LCD module signals to the I/O ports must be specified in the Project|Configure|C
Compiler|Libraries|Alphanumeric LCD menu.
The LCD power supply and contrast control voltage must also be connected according to the module
data sheet.
Example:
void main(void)
{
/* initialize the LCD for 2 lines & 16 columns */
lcd_init(16);
initializes the LCD module, clears the display and sets the printing character position at row 0 and
column 0. The numbers of columns of the LCD must be specified (e.g. 16). No cursor is displayed.
This is the first function that must be called before using the other high level LCD Functions.
void lcd_clear(void)
clears the LCD and sets the printing character position at row 0 and column 0.
sets the current display position at column x and row y. The row and column numbering starts
from 0.
void lcd_putchar(char c)
displays at the current display position the string str, located in RAM.
displays at the current display position the string str, located in FLASH.
displays at the current display position the string str, located in EEPROM.
Example:
void main(void) {
/* disable interrupts */
#asm("cli")
/* 100µs delay */
delay_us(100);
/* ............. */
/* 10ms delay */
delay_ms(10);
/* enable interrupts */
#asm("sei")
/* ............. */
}