NUMBER BASES Different number bases can be used in PICC Lite to describe integer numbers. Table 4.1 lists the valid number bases. STRUCTURES Structures are used to collect related items together. For example, the details of a person can normally be stored as unsigned char name[80]; unsigned char surname[80]; unsigned int age;
Continue reading…
Uncategorized
PROGRAMMING PIC MICROCONTROLLERS IN C:ASCII CONSTANTS
ASCII CONSTANTS The PICC Lite compiler supports a number of ASCII constants which can be used in programs instead of their numeric values. The following are constants the frequently used: Character constants are used by enclosing them in single quotes. For example, the variable temp can be assigned the null character by writing: temp = […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:BANK1 QUALIFIER AND ARRAYS
BANK1 QUALIFIER The bank1 type qualifier is used to store static variables in RAM bank 1 of the microcontroller. By default, variables are stored in bank 0 of the RAM. In the following example, the static integer variable temp is stored in bank 1: static bank1 int temp; ARRAYS An array is a collection of […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:PERSISTENT VARIABLES AND ABSOLUTE ADDRESS VARIABLES
PERSISTENT VARIABLES Normally, the initial values of variables are cleared to zero when the program starts up (i.e. whenever reset is applied to the microcontroller). The persistent qualifier prevents a variable from being cleared at start-up. In the following example, the variable max is declared persistent and as a result its value is not cleared […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:STORING VARIABLES IN THE PROGRAM MEMORY
STORING VARIABLES IN THE PROGRAM MEMORY In PICC Lite, variables are normally stored in the RAM memory of the target microcontroller since the value of a variable is expected to change during the running of a program. There are many variables whose values do not change during the lifetime of a program, and these variables […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C: STATIC VARIABLES AND VOLATILE VARIABLES
STATIC VARIABLES Static variables are usually used in functions. A static variable can only be accessed from the function in which it was declared. The value of a static variable is not destroyed on exit from the function, instead its value is preserved and becomes available again when the function is next called. Static variables […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:PICC LITE VARIABLE TYPES
PICC LITE VARIABLE TYPES The PICC Lite compiler supports the following basic data types: • bit • unsigned char • signed char • unsigned int • signed int • long • unsigned long • float • double Bit A bit can store a Boolean variable (a 0 or a 1). Bit variables are usually used […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:COMMENTS IN PROGRAMS
COMMENTS IN PROGRAMS Comments can be used in programs for clarification purposes. The comment lines are ignored by the compiler. There are two ways of including comments in a program. One way is to use double slashes (‘//’) before a comment line. Any characters after the double slashes (‘//’) are ignored by the compiler. For […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C:VARIABLES
VARIABLES In C, a variable must be declared before it can be used in a program. Variables are usually declared at the beginning of any block of code. Every variable has a name and a value – the name identifies the variable and the value stores data. There is a rule governing what a variable […]
Continue reading…
PROGRAMMING PIC MICROCONTROLLERS IN C
Microcontrollers have traditionally been programmed using the assembly language. This lan- guage consists of various mnemonics which describe the instructions of the target microcon- troller. An assembly language is unique to a microcontroller and cannot be used for any other type of microcontroller. Although the assembly language is very fast, it has some major disad- […]
Continue reading…