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

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
PICkit™ 3 Debug Express
FIGURE 3-19:
DS41370C-page 28
/**
#pragma udata // declare statically allocated uninitialized variables
unsigned char LED_Number; // 8-bit variable
/**
// declare constant data in program memory starting at address 0x180
#pragma romdata Lesson3_Table = 0x180
const rom unsigned char LED_LookupTable[8] = {0x01, 0x02, 0x04, 0x08,
#pragma
void
{
}
LED_Number
TRISD
while
{
}
V
D
main
LATD = LED_LookupTable[LED_Number];
LED_Number++;//
if
LED_Number
Delay1KTCYx(50);//
A
E
code//
=
(1)
R
C
(LED_Number
(void)
// use lookup table to output one LED on based on LED_Number value
0b00000000;//
I
L
=
A
A
declare
0;//
=
LESSON 3 “ROTATE LED” SOURCE CODE
Here is the basic flow of our Rotate LED program:
3.3.4
In the MPLAB IDE, build the Lesson 3 project and program the code into the demo
board using the PICkit 3 Programmer.
The demo board LEDs will rotate from LED 0 up to LED 7 and then back to LED 0.
B
R
Initialize Variables and I/O Port
Loop Forever with the while(1) statement:
0;//
L
A
initialize
rotate
==
E
T
executable
Delay
(Loop End)
PORTD
8)
go
S
I
Build and Program the Lesson 3 Code
*************************************************/
O
display
back
The global variable LED_Number, which holds the number of the LED we cur-
rently want on, is set to ‘0’ for the first LED.
The TRISD register bits are all set to ‘0’, so that all 8 port D pins RD0-RD7 are
outputs.
Set the I/O Port to turn on an LED.
Rotate the LED number
Delay
200ms
50
bits
N
S
instructions
to
x
*******************************************/
7:0
by
1000
LED
The number of the LED to turn on, LED_Number, is used an index
to the array LED_LookupTable which returns a value with a bit set
corresponding to the LED to be turned on. This value is written to
the LATD register to turn on the one LED.
The LED number is incremented to the next LED. The if state-
ment checks to see if it has been incremented past the last LED. If
so, it is reset to the first LED, number 0.
As in Lesson 2, a “delays” library function is used to create a time
delay.
1
are
0.
=
0x10, 0x20, 0x40, 0x80};
50,000
all
outputs
cycles;
(0)
200ms
@
1MHz
© 2009 Microchip Technology Inc.

Related parts for PIC18F45K20-E/P