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

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
© 2009 Microchip Technology Inc.
T0PS2:T0PS0 = 000
And finally:
TMR0ON = 0
To configure Timer0 with these settings, the binary value 0b0000100 is written to
T0CON.
The PIC18F45K20 has 3 other configurable timers: Timer1, Timer2 and Timer3. More
information on all four timer modules can be found in the PIC18F45K20 Data Sheet
(DS41303), Sections 11 through 14.
3.5.2
Open the lesson source code file 05 Timer.c and header file 05 Timer.h in editor
windows if they are not open already.
Note that in 05 Timer.h two custom enumerated variable types have been defined:
typedef enum { LEFT2RIGHT, RIGHT2LEFT}
typedef
This allows us to declare variables using these types and initialize them in main():
LEDDirections
BOOL
The Direction variable keeps track of which direction the LEDs are rotating in, and
SwitchPressed remembers if the switch has been pressed or not, as the LED
rotation direction should only be changed once when it is pressed.
The following code before the while(1) loop sets up the Timer0 module as discussed
previously.
Using the line numbers in the comments as references, let’s discuss the function of
each line in setting up the timer.
Line 1 clears the TMR0IF flag in the INTCON SFR. This bit flag is set whenever the
timer overflows (rolls over), so the program will poll it to know when the LED rotation
delay is up. However, the flag will not reset by hardware, it must be reset in software
so the program makes sure it is clear before starting the timer.
Line 2 loads the settings into T0CON to configure the timer as discuss previously in this
lesson.
Line 3 clears the TMR0H buffer. Remember that TMR0H only buffers the high byte of
the timer. The ‘0’ value will not actually be written to the timer upper byte until TMR0L
is written.
Line 4 clears TMR0L, which also causes TMR0H to be written to the high byte of the
timer. Thus, the entire 16-bit timer is loaded with the hex value 0x0000.
// Init Timer
INTCONbits.TMR0IF
T0CON = 0b00001000;
// T0CON
TMR0H = 0;
TMR0L = 0;
T0CONbits.TMR0ON
Since the prescaler is not assigned, these bits are “don’t care.”
This bit turns the timer on and off. It’s set to zero now as the timer will be turned on
once it is has been set up.
SwitchPressed
Exploring the Lesson 5 Source Code
enum
=
0b00000001;
PICkit™ 3 Debug Express Lessons
{FALSE, TRUE} BOOL;
Direction
LEDDirections;
=
=
1;
=
0;
FALSE;
=
//
//
(ignore commented line for now)
//
//
//
LEFT2RIGHT;
line
line
line
line
line
1
2
3
4
5
DS41370C-page 35

Related parts for PIC18F45K20-I/ML