Microchip Technology DM164130-9 Manual Do Utilizador
PICkit™ 3 Starter Kit User’s Guide
DS41628B-page 34
2012 Microchip Technology Inc.
2.15 DATA EEPROM MEMORY
The data EEPROM is a nonvolatile memory array, separate from both the data RAM,
and program memory, which is used for long-term storage of program data. The
EEPROM is not directly mapped in either the register file or program memory space,
but is indirectly addressed through special SFRs. The EEPROM is readable and
writable during normal operation.
The PIC16F1829 and PIC18F14K22 have 256 bytes of EEPROM on board.
The EEPROM is rated for high erase/write cycle endurance. A byte write automatically
erases the location and writes the new data. Please see Section 3.14 “Lesson 13:
EEPROM” for more information.
and program memory, which is used for long-term storage of program data. The
EEPROM is not directly mapped in either the register file or program memory space,
but is indirectly addressed through special SFRs. The EEPROM is readable and
writable during normal operation.
The PIC16F1829 and PIC18F14K22 have 256 bytes of EEPROM on board.
The EEPROM is rated for high erase/write cycle endurance. A byte write automatically
erases the location and writes the new data. Please see Section 3.14 “Lesson 13:
EEPROM” for more information.
2.16 PROGRAMMING BASICS
This section will briefly discuss essential assembler and ‘C’ basics. There are better
suited tutorials on ‘C’ programming on the web if the user wishes to learn more.
This guide uses the XC8 compiler v.1.00 for both the PIC16F1829 and PIC18F14K22.
Later versions of the compiler will also work. Looking at the XC8 user’s guide would be
a very good start. One of the great benefits of using ‘C’ is that it is very portable and will
build in most compilers with no problem.
The assembly is not compiled, but rather assembled by a utility called MPASM. This
guide uses MPASM assembler v5.43, which is a universal assembler for all PIC1X
devices.
A key advantage of using a high-level language (such as C) is that the programmer
does not need to understand the architecture of the microprocessor being used. Knowl-
edge of the architecture is left to the compiler which will take the ‘C’ and compile it into
assembly. When using assembly, the programmer must use the PIC device’s instruc-
tion set and understand the memory map. A positive benefit of assembly is not only the
knowledge gained, but also the code size will be considerably smaller.
suited tutorials on ‘C’ programming on the web if the user wishes to learn more.
This guide uses the XC8 compiler v.1.00 for both the PIC16F1829 and PIC18F14K22.
Later versions of the compiler will also work. Looking at the XC8 user’s guide would be
a very good start. One of the great benefits of using ‘C’ is that it is very portable and will
build in most compilers with no problem.
The assembly is not compiled, but rather assembled by a utility called MPASM. This
guide uses MPASM assembler v5.43, which is a universal assembler for all PIC1X
devices.
A key advantage of using a high-level language (such as C) is that the programmer
does not need to understand the architecture of the microprocessor being used. Knowl-
edge of the architecture is left to the compiler which will take the ‘C’ and compile it into
assembly. When using assembly, the programmer must use the PIC device’s instruc-
tion set and understand the memory map. A positive benefit of assembly is not only the
knowledge gained, but also the code size will be considerably smaller.
2.16.1
MPASM™ Assembler Operation
All of the lessons written in are absolute code. This means that everything that the
assembler needs is contained in the source files. This process is shown below.
assembler needs is contained in the source files. This process is shown below.
FIGURE 2-12:
MPASM ASSEMBLER OPERATION
When a source file is assembled in this manner, all variables and routines used in the
source file must be defined within that source file, or in files that have been explicitly
included by that source file. If assembly proceeds without errors, a hex file will be gen-
erated that contains the executable machine code for the targeted PIC device. This file
can then be used by the debugger to test code execution, and by a device programmer
to program the microcontroller.
source file must be defined within that source file, or in files that have been explicitly
included by that source file. If assembly proceeds without errors, a hex file will be gen-
erated that contains the executable machine code for the targeted PIC device. This file
can then be used by the debugger to test code execution, and by a device programmer
to program the microcontroller.
2.16.2
XC8 Operation
The compiler does all of the translation involved, which is needed to take the high-level
code down to a level in which the PIC device understands.
code down to a level in which the PIC device understands.
explains how
this is done.
code.asm
code.hex
Programmer
MPASM™
assembler
assembler
MCU