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

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
3.7
© 2009 Microchip Technology Inc.
LESSON 7: ANALOG-TO-DIGITAL CONVERTER (ADC)
Lesson 7 builds on the previous lesson by using the on-chip ADC to read the demo
board potentiometer voltage. The result is used to vary the LED rotation time delay so
that the potentiometer controls the LED rotation speed.
3.7.1
Simply put, an ADC takes the ratio of an input voltage to a reference voltage and
represents it as a number. This number is dependent on the bits of resolution of the
ADC. For example, the 10-bit resolution of the PIC18F45K20 ADC means that 1024
numbers from 0-1023 are available to represent the voltage ratio. In mathematical
terms,
ADC Value = (V
If V
makes sense in that V
Knowing the reference voltage and solving the equation for V
to be converted back into a voltage:
V
The PIC18F45K20 ADC may be referenced to the device V
voltage reference. In this lesson, the ADC is referenced to the PIC18F45K20 Starter Kit
Demo Board V
for this device.
The ADC can convert the voltage from any one of 13 channels on the PIC18F45K20.
These analog input channels, numbered AN0 up to AN12, are shared with digital
microcontroller pins and must be configured as analog inputs to be used with the ADC.
The ADC is configured and controlled by 5 Special Function Registers: ANSEL,
ANSELH, ADCON0, ADCON1 and ADCON2. These are covered in detail in the next
section.
3.7.2
Looking at the schematic of the 44-Pin Demo Board in the Appendix, the potentiometer
(RP1) output is connected to the RA0/AN0 pin of the PIC18F45K20.
The basic steps needed to convert the ADC voltage on this pin are:
1. Configure the RA0/AN0 pin as an analog input in ANSEL.
2. Set the ADC voltage references in ADCON1.
3. Set the result justification, ADC clock source, and acquisition time in ADCON2.
4. Select the channel and turn on the ADC in ADCON0.
5. Start the conversion in ADCON0.
#1: To use a pin as an analog input, it must not be used by other peripheral functions
multiplexed on the same pin. The pin TRIS bit must be set to ‘1’ (input) and the ANSEL
bit associated with RA0 should be set to ‘1’ (analog input). However, we still want
RB0/AN12 configured as a Digital input to for the switch. Therefore, we will clear ‘0’ the
AN12 bit in ANSELH.
Key Concepts
IN
- An Analog-to-Digital Converter is used to convert an analog voltage level
- The ANSEL, ANSELH, ADCON0, ADCON1, and ADCON2 SRFs configure
- A timer register can be written to a value that will cause a timer overflow at a
IN
= (ADC Value/1023) * V
into a digital number representing the voltage.
and control the on-chip ADC.
specific time interval required by the application.
= 2.5Volts, and V
PIC18F45K20 ADC Basics
ADC Configuration and Operation
DD
IN
, which is supplied by PICkit 3. This voltage is typically around 3.3V
/V
PICkit™ 3 Debug Express Lessons
REF
IN
REF
) * 1023
is half of V
= 5.0Volts, then the ADC Value is (2.5/5)*1023 = 511. This
REF
REF
, so the ADC value is half of 1023.
DD
IN
voltage or an external
allows the ADC Value
DS41370C-page 45

Related parts for PIC18F45K20-I/ML