Date post: | 13-Apr-2018 |
Category: |
Documents |
Upload: | hussam-gujjar |
View: | 222 times |
Download: | 0 times |
of 21
7/25/2019 Lec2 Hardware Connections
1/21
MICROPROCESSOR BASE
EMBEDDED SYSTEM
DESIGN
Syed Ali Jabir
Lecture
2
Email:
mailto:[email protected]:[email protected]7/25/2019 Lec2 Hardware Connections
2/21
PIC18F4520 PIN CONNECTIONS
7/25/2019 Lec2 Hardware Connections
3/21
PIC18F4520 PIN CONNECTIONS
Vdd (Vcc)
Two pins
+5V
Some PIC18F family members have lower voltage for Vdd
Reduces noise
Reduces power consumption
Voltage level can be changed setting appropriate bits in
configuration register
7/25/2019 Lec2 Hardware Connections
4/21
PIC18F4520 PIN CONNECTIONS
Vss (GND)
Two pins
Typically multiple pins for Vcc and GND help reduce
noise in high frequency systems
7/25/2019 Lec2 Hardware Connections
5/21
PIC18F4520 PIN CONNECTIONS
`MCLR
Pin 1 is the Master CLear Reset
It is an input and active-LOW
When low pulse is applied, the microcontroller will
reset and terminate all activities
Also called Power-On Reser (POR)
7/25/2019 Lec2 Hardware Connections
6/21
PIC18F4520 PIN CONNECTIONS
`MCLR
Typical connections
Vdd
MCLR
10K
Vdd
MCLR
10K
270Push
Button
7/25/2019 Lec2 Hardware Connections
7/21
PIC18F4520 PIN CONNECTIONS
`
OSC1 & OSC2
PIC18F can be operated in 10 different oscillator modes
We can select the mode by setting bits FOSC3:FOSC0, in
configuration register 1H
Mostly a quartz crystal of up to 40MHz is connected to
input pins OSC1 and OSC2
7/25/2019 Lec2 Hardware Connections
8/21
PIC18F4520 PIN CONNECTIONS
OSC1 & OSC2
1 LP Low Power Crystal
2 XT Crystal/Resonator
3 HS High Speed Crystal/Resonator
4 HSPLL High Speed Crystal/Resonator with PLL enabled
5 RC External Resistor/Capacitor with FOSC/4 output on RA6
6 RCIO External Resistor/Capacitor with I/O on RA6
7 INTIO1 Internal Oscillator with FOSC/4 output on RA6 and I/O on R
8 INTIO2 Internal Oscillator with I/O on RA6 and RA7
9 EC External Clock with FOSC/4 output
10 ECIO External Clock with I/O on RA6
7/25/2019 Lec2 Hardware Connections
9/21
PIC18F4520 PIN CONNECTIONS
OSC1 & OSC2
7/25/2019 Lec2 Hardware Connections
10/21
`
`
` `
` `
`
`
PIC18F4520 PIN CONNECTIONS
Ports
A
B
CD
E`
7/25/2019 Lec2 Hardware Connections
11/21
PIC18F4520 PIN CONNECTIONS
RECAP
Which pin is used for reset in PIC18F4520 ?
MCLR is active - ?
How many Vdd and Vcc pins are there in PIC18F4520 ?
7/25/2019 Lec2 Hardware Connections
12/21
PIC18F4520 PIN CONNECTIONS
Configuration Registers
7/25/2019 Lec2 Hardware Connections
13/21
PIC18F4520 PIN CONNECTIONS
CONFIG1H register and Oscillator Clock Source
Located at address 0x300001
Is used for clock oscillator settings
7/25/2019 Lec2 Hardware Connections
14/21
11XX External RC oscillator, CLKO function
101X External RC oscillator, CLKO function o
1001 Internal oscillator block, CLKO function on RA6, po
1000 Internal oscillator block, port function on RA
0111 External RC oscillator, port function on
0110 HS oscillator, PLL enabled (Clock Frequency =0101 EC oscillator, port function on RA6
0100 EC oscillator, CLKO function on RA
0011 External RC oscillator, CLKO function o
0010 HS oscillator
0001 XT oscillator
0000 LP oscillator
PIC18F4520 PIN CONNECTIONS
CONFIG1H register and Oscillator Clock Source
FOSC3:FOSC0
Oscillator Selection
bits
7/25/2019 Lec2 Hardware Connections
15/21
PIC18F4520 PIN CONNECTIONS
Instruction Cycle Time
In PIC18F microcontrollers, instruction cycle time is based on of the
provided to OSC pins
So if we use 4MHz crystal
4MHz/4 = 1MHz
Inst. cycle time = 1/1MHz = 1us
Compute Instruction cycle time for 10MHz crystal
7/25/2019 Lec2 Hardware Connections
16/21
PIC18F4520 PIN CONNECTIONS
CONFIG2L register and reset voltage
Located at address 0x300002
Is used for providing stable voltage and clock frequency during reset
An internal power up timer (PWRT) provides a fixed delay during po
which keeps CPU in reset state until power supply stabilizes
Another internal oscillator startup timer (OST) does the same for cry
7/25/2019 Lec2 Hardware Connections
17/21
PIC18F4520 PIN CONNECTIONS
CONFIG2L register and reset voltage
Microcontroller can malfunction if power source provided to Vdd pins
Brown Out Reset Voltage (BORV) lets the user set a minimum voltage b
microcontroller goes into reset state
For a high speed crystal of 40MHz, Vdd = 5V and BORV = 4.5V
For low power systems BORV = 1.8V
Once the voltage stabilizes, program continues execution from the sam
7/25/2019 Lec2 Hardware Connections
18/21
PIC18F4520 PIN CONNECTIONS
CONFIG2H register and watch dog timer
Located at address 0x300003
WATCH DOG TIMER is used to force the microcontroller into the known state o
when the system is hung up or out of control due to execution of incorrect sequ
Problems can happen due to corruption of program memory caused by
Power surge
Electrically noisy environment Inadvertent changes to PC
WDT will force the system into a state of reset/sleep from which it can recover
USES
Prevent a system from going into infinite loop due to software bug
Catch events that cause the system to hang
7/25/2019 Lec2 Hardware Connections
19/21
PIC18F4520 PIN CONNECTIONS
CONFIG4L register and background debugger
Located at address 0x300006
DEBUG
If PIC18F is connected to an in-circuit debugger (Pickit) RB6 and RB7 pins
cannot be used as general purpose I/O
STVREN
Stack Full/Underflow Reset Enable
LVP
Used for low-voltage in-circuit serial programming (ICSP) via pin RB5
7/25/2019 Lec2 Hardware Connections
20/21
PIC18F4520 PIN CONNECTIONS
Setting CONFIG registers in MPLAB C18 compil
#include
#pragma config OSC = HS
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = OFF
#pragma config DEBUG = OFF, LVP = OFF
void main (void)
{
..
..
.
}
7/25/2019 Lec2 Hardware Connections
21/21
REFERENCES
PIC18F4520 datasheet