PIC18F45K20-I/ML Microchip Technology, PIC18F45K20-I/ML Datasheet - Page 21

IC PIC MCU FLASH 16KX16 44QFN

PIC18F45K20-I/ML

Manufacturer Part Number
PIC18F45K20-I/ML
Description
IC PIC MCU FLASH 16KX16 44QFN
Manufacturer
Microchip Technology
Series
PIC® XLP™ 18Fr

Specifications of PIC18F45K20-I/ML

Program Memory Type
FLASH
Program Memory Size
32KB (16K x 16)
Package / Case
44-QFN
Core Processor
PIC
Core Size
8-Bit
Speed
64MHz
Connectivity
I²C, SPI, UART/USART
Peripherals
Brown-out Detect/Reset, HLVD, POR, PWM, WDT
Number Of I /o
35
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 ~ 85°C
Processor Series
PIC18F
Core
PIC
Data Bus Width
8 bit
Data Ram Size
1.5 KB
Interface Type
CCP/ECCP/EUSART/I2C/MSSP/SPI
Maximum Clock Frequency
64 MHz
Number Of Programmable I/os
36
Number Of Timers
4
Maximum Operating Temperature
+ 85 C
Mounting Style
SMD/SMT
3rd Party Development Tools
52715-96, 52716-328, 52717-734, 52712-325, EWPIC18
Development Tools By Supplier
PG164130, DV164035, DV244005, DV164005, PG164120, DV164136
Minimum Operating Temperature
- 40 C
On-chip Adc
14-ch x 10-bit
Package
44QFN EP
Device Core
PIC
Family Name
PIC18
Maximum Speed
64 MHz
Operating Supply Voltage
2.5|3.3 V
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 PIC18F4XK20AC164322 - MODULE SOCKET MPLAB PM3 28/44QFN
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
FIGURE 3-8:
© 2009 Microchip Technology Inc.
/**
#pragma config FOSC = INTIO67
#pragma config WDTEN = OFF, LVP = OFF
/**
#include
/**
void
{
}
C
I
D
main
TRISD
LATDbits.LATD7
while
;
O
N
E
"p18f45K20.h"
N
C
C
(void)
F
L
L
=
(1)
I
U
A
0b01111111;//
G
D
R
LESSON 1 “HELLO LED” SOURCE CODE
When this code is built, programmed into the PIC18F45K20 microcontroller and
executed, it will turn on the LED connected to I/O pin RD7 by driving the pin high. Let’s
discuss the elements of the code that makes this happen:
U
E
A
=
R
S
T
1;//
#pragma config
#include
TRISD
LATDbits.LATD7
while(1)
A
**************************************************/
I
T
O
PORTD
Set
I
N
LAT
O
S
bit
PICkit™ 3 Debug Express Lessons
N
*******************************************/
register
7
to
B
I
output
bit
Pragma is a directive that has meaning for a specific compiler.
It is used in MPLAB C with attributes to convey
implementation-dependent information to the compiler. Here it
is used with the config directive, which defines the states of
the PIC18FXXXX Configuration bits. This will be discussed in
more detail in Lesson 2.
The p18f45k20.h file is included as this device-specific
header file contains definitions for the variables used to
access the Special Function Registers (SFRs) of the
microcontroller. Some useful macros such as Nop() and
ClrWdt() are also defined in this header.
This variable is used to access the SFR of the same name,
and is defined in the included microcontroller header file
p18f45k20.h. The TRIS (tri-state) registers are used to set
the directions of the pins in the associated I/O port, in this
case pins RD0 to RD7. A TRISD bit value of ‘0’ sets the pin to
an output. A value of ‘1’ sets a pin to be an input. With the
binary value of 0b01111111 we set RD7 to an output and
RD6-RD0 to inputs.
The LATDbits struct is also defined in p18f45k20.h and
gives access to the individual bits in the LATD SFR. (There is
also a TRISDbits struct for accessing bits of TRISD, and a
LATD variable defined to access the entire byte-wide register.)
The LATD (latch) register is used to set the output state of the
RD7-RD0 pins. A bit value of ‘1’ sets an output pin to a high
state. Bits for pins defined in the TRIS register as inputs do not
have an effect. Setting LATDbits.LATD7 = 1 will output a
high level on RD7, turning on LED 7 on the demo board.
In this case of code running on an embedded microcontroller,
there is no operating system to return to when the code
finished executing. Therefore, an infinite C while loop is
used to keep the microcontroller running and prevent it from
exiting main() and trying to execute undefined memory
locations.
T
S
7
(0);
******************************/
to
turn
bits
on
6:0
LED
are
inputs
(1)
DS41370C-page 17

Related parts for PIC18F45K20-I/ML