Upload
adamwaiz
View
213
Download
0
Embed Size (px)
Citation preview
7/30/2019 pic18 hardware interfacing
1/9
The University of Texas at Arlington
1
Lecture 8
Hardware Connections
CSE 3442/5442
22
PIC18F458 Pin Diagram
DIP (dual in line package) shown QFP (quad flat package) and LLC
(leadless chip carrier) is also available
Vdd typical 5V but can beset; 2 pins
Vss (GND) 2 pins (groundbounce noise reduction)
OSC1 and OSC2: forexternal quartz oscillators
0-40MHz, configurable MCLR master clearreset creates power onreset
7/30/2019 pic18 hardware interfacing
2/9
3
PIC18F458 Power-On Reset Circuit
At MCLR:
PC, WREG, SP reset to 0 TRISA-TRISE reset to FF
4
Minimum Connections on a Pic18F(With a Crystal)
7/30/2019 pic18 hardware interfacing
3/9
5
Configuration Registers
In ROM beyond addressable
CONFIG directive in the sourcecode is used to write to it, e.g., CONFIG OSC=HS
CONFIG OSCS = OFF OR CONFIG OSC=HS , OSCS = OFF
MPLAB can directly manipulatethem inside a project
Can be accessed through tablereads and writes from the
microcontroller CONFIG5 and up are in general for
code protection settings
6
CONFIG1H - Oscillator
FOSC default is RC (111) on chip oscillator with RCcircuit attached to OSC1
EC = external oscillatorconnected to OSC1
HSPLL, HS, XT, LP, arecrystal options with stabilityand power consumption (inthis descending order)differences (HSPLL
quadruples the frequency) There is an internal 32kHz
oscillator that can beenabled by the OSCEN bit
7/30/2019 pic18 hardware interfacing
4/9
7
Clocks
8
CONFIG2L Initial Transients
Controls stable voltage andfrequency during reset
Power up timer (PWRT)keeps the processor startup so that supply voltagecan be stabilized
Oscillator start up timerdoes the same for theoscillator
Brown out suspends the
processor if supply voltagefalls below a set level
Recall: the higher thefrequency the higher of asupply voltage we need
e.g., CONFIG BORV = 45
e.g., CONFIG BOR = ON
e.g., CONFIG PWRT = ON
7/30/2019 pic18 hardware interfacing
5/9
9
CONFIG2H Rottweilers
Errrr, watchdog timers
Can verify if the systemstill is executingmeaningful instructionsor is stuck (ROMcorruption, noises, PCfailures) and issue areset
WDTPS determines
the time-oute.g., CONFIG WDT = ON
10
CONFIG4L Debuggers, etc.
There are specialpurpose in-circuitdebuggers that can beused with PICs (RB6and RB7 unusable)
SVREN: Stack hasonly 31 locations if itover (or under) flowswe can ask for a reset
LVP: low voltage incircuit programming bit(RB5 becomesunusable)
e.g., CONFIG DEBUG = OFF
7/30/2019 pic18 hardware interfacing
6/9
11
LIST Directive
The LIST directive can be used to tell theassembler about our code reading needs
LIST P=18F452, F=INTHX32, MM=OFF, ST=OFF, X=OFF
Macro expansion (on)X={ON/OFF}
List file to contain symbol list (on)ST={ON/OFF}
Hex,dec, or oct (hex)R=radix
Set microcontroller typeP=type
Lines per page for prints (60)N=nnn
List file to contain memory map (on)MM={ON/OFF}
Hex file output {INHX32 (32bit ROM address), INHX8M(16bit ROM address), INHX8S (split two files one for highone for low bytes)}
F=format
Set column width for prints (132)C=nnn
Set tab space (8)B=nnn
12
How About C?
It is simple to do all this from C as well:insert a #pragma in front of config
E.g., #pragma config OSC=HS
7/30/2019 pic18 hardware interfacing
7/9
13
So, Whats in a HEX File?
BB: how many bytes in theline, max value 0x10H
AAAA: ROM address spacewhere data needs to go (only16 bits!)
TT: 00 means hex file iscontinuing 01 means it is over;in INHX32: 02 segmentaddress, 04: HHHH is used toswitch to another bank(A31;A16)
HH: Data (at most 16 in a
line see BB) CC: checksum
INHX8M
INHX32
14
We have the Hex File, What Now?
We need to burn the code onto themicrocontroller
Three basic methods: Off-circuit: the microcontroller is programmed as a
stand alone chip and is then inserted into the circuit
In-circuit: microcontroller has to set aside pins thatare used to program it while inside the circuit
Boot loader: a special code running on themicrocontroller, allowing it to accept code from any ofits interfaces (boot loader needs to be burned withone of the previous two methods)
7/30/2019 pic18 hardware interfacing
8/9
15
Off-circuit Programming
Special purpose programming tools need to be used
Usually high voltages are needed Chip manufacturer usually sell them but many third parties do it as well Specs on how it needs to work are provided by the chip manufacturer
Usually can be built at home easily (may not be important) Usually have zero insertion force sockets (ZIF)
Have to be careful about electrostatic discharge (ESD)
16
In-circuit Programming
In circuit SerialProgramming (ICPS)uses RB7 and RB6
These pins can be
reused afterprogramming but thedesigner needs tomake sure they donot interfere
7/30/2019 pic18 hardware interfacing
9/9
17
Boot loader
See our QwikFlash boards
Takes away ROM space from thedeveloper
Can use any communication methodsavailable to the microcontroller
Code space for boot loader must bereserved and protected
May be a good choice for development butusually not for final product
18
Summary
Microcontrollers need external connections
Usually there are many options for clock sources(some microcontrollers have two clock sources)
Microcontrollers have to be configured (byburning configuration values to special registers)
After code is compiled and linked it needs to be
burned onto the microcontroller (for which thereare three general methods)