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 are known as constants. It is possible to store the constants in the flash (or EPROM) program memory of the target microcontroller. The size of the RAM memory is very limited in many microcontrollers and storing some of the variables in the program memory releases valuable RAM memory locations. A variable is stored in the program memory if it is preceded by the keyword const. In the following example, the variable sum is stored in the RAM memory, but the variable pi is stored in the program memory of the microcontroller:

Programming PIC Microcontrollers in C-0109

Leave a comment

Your email address will not be published. Required fields are marked *