PIC18F45K20-E/P Microchip Technology, PIC18F45K20-E/P Datasheet - Page 29

32KB, Flash, 1536bytes-RAM, 36I/O, 8-bit Family,nanowatt XLP 40 PDIP .600in TUBE

PIC18F45K20-E/P

Manufacturer Part Number
PIC18F45K20-E/P
Description
32KB, Flash, 1536bytes-RAM, 36I/O, 8-bit Family,nanowatt XLP 40 PDIP .600in TUBE
Manufacturer
Microchip Technology
Series
PIC® XLP™ 18Fr

Specifications of PIC18F45K20-E/P

Core Processor
PIC
Core Size
8-Bit
Speed
48MHz
Connectivity
I²C, SPI, UART/USART
Peripherals
Brown-out Detect/Reset, HLVD, POR, PWM, WDT
Number Of I /o
35
Program Memory Size
32KB (16K x 16)
Program Memory Type
FLASH
Eeprom Size
256 x 8
Ram Size
1.5K x 8
Voltage - Supply (vcc/vdd)
1.8 V ~ 3.6 V
Data Converters
A/D 14x10b
Oscillator Type
Internal
Operating Temperature
-40°C ~ 125°C
Package / Case
40-DIP (0.600", 15.24mm)
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With
DM240313 - BOARD DEMO 8BIT XLPAC164112 - VOLTAGE LIMITER MPLAB ICD2 VPPDM164124 - KIT STARTER FOR PIC18F4XK20
Lead Free Status / RoHS Status
Lead free / RoHS Compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC18F45K20-E/PT
Manufacturer:
Microchip Technology
Quantity:
10 000
3.3
© 2009 Microchip Technology Inc.
LESSON 3: ROTATE LED
This lesson builds on the previous two lessons to introduce defining global variables
and code sections, and to add rotation to the LED display. It will light up LED 0, then
shift it to LED 1, then to LED 2 and on up to LED 7, and back to LED 0.
In this and following lessons, please open the lesson workspace in the MPLAB IDE
upon starting the lesson.
3.3.1
In the source code file 03 Rotate LED.c for Lesson 3 the global variable,
LED_Number, is declared as in Figure 3-16.
FIGURE 3-16:
The directive #pragma udata is used prior to declaring the variable LED_Number to
indicate to the compiler that the following declarations are data variables that should be
placed in the PIC18FXXXX file registers. This differs from PC compilers where
instructions and variables share the same memory space due to the Harvard
architecture of the PIC18FXXXX as discussed in Section 2.1 of this document.
There are two directives for use with #pragma when defining variables:
Data declarations can also be given a section name. The section name may be used
with a Linker Script SECTION entry to place it in a particular area of memory. See
Section 2.9 of the “MPLAB C18 C Compiler User’s Guide” (DS51288) for more
information on using sections with Linker Scripts. Even without a Linker Script section,
the #pragma udata directive may be used to specify the starting address of the data
in the file registers. For example, to place LED_Number at the start of file register Bank
3 declare the udata section as:
Other variables declared in a udata or idata section will be placed at subsequent
addresses. For instance, the 16-bit integer
address 0x301 and 0x302
Note that function local variables will be placed on the software stack.
Key Concepts
/**
#pragma udata // declare statically allocated uninitialized variables
unsigned char LED_Number; // 8-bit variable
- The directives #pragma udata and #pragma idata are used to allocate
- The directive #pragma code is used to indicate a section of instructions to
- The directive #pragma romdata is used for constant (read-only) data
- Constant data can be stored in program memory so as not to use up file
udata
idata
#pragma udata mysection = 0x300 unsigned char
LED_Number; // 8-bit variable unsigned int
AnotherVariable;
memory for static variables in the file registers.
be compiled into the program memory of the PIC18FXXXX.
stored in the program memory. This is used with the keyword rom.
register RAM.
V
A
Allocating File Register Memory
R
Uninitialized data. The following data is stored uninitialized in the file register
space.
Initialized data. The following data is stored in the file register space. The initial-
ization values are stored in program memory, and then moved by the start-up
initialization code into file registers before program execution begins.
I
A
PICkit™ 3 Debug Express Lessons
B
LESSON 3 GLOBAL VARIABLE DECLARATION
L
E
.
S
*************************************************/
AnotherVariable above would occupy
DS41370C-page 25

Related parts for PIC18F45K20-E/P