Beruflich Dokumente
Kultur Dokumente
n mn hc Thit K Lun L.
......................................................................................................................................................... I
I.2.
c im chnh. ................................................................................................................... 4
I.3.
S khi ............................................................................................................................ 5
I.4.
I.7.
I.9.
c im chung............................................................................................................ 39
I.10.2
I.10.3
DMA ............................................................................................................................ 40
I.10.3
I.10.4
I.10.5
I.11. CAN.................................................................................................................................... 44
I.11.1
nh ngha.................................................................................................................... 44
I.11.2
I.11.3
a ch b nh .............................................................................................................. 46
I.11.4
nh ngha.................................................................................................................... 48
I.12.2
I.12.3
I.13.2
I.13.3
nh ngha.................................................................................................................... 59
I.14.2
I.14.3
I.14.4
I.15.2
I.15.3
II
I.15.4
Kt ni vt l ................................................................................................................ 70
I.15.5
I.15.6
I.16.2
I.16.3
I.16.4
I.16.5
III
Phc Lc Hnh
IV
Ph Lc Bng
VI
LI CM N
Trn thc t khng c s thnh cng no m khng gn lin vi nhng
s h tr, gip d t hay nhiu, d trc tip hay gin tip ca ngi khc.
Trong sut thi gian t khi bt u hc tp ging ng i hc n nay,
em nhn c rt nhiu s quan tm, gip ca qu Thy C, gia nh
v bn b.
Vi lng bit n su sc nht, em xin gi n qu Thy C Khoa
Khoa Hc & K Thut My Tnh Trng i Hc Bch Khoa Thnh Ph
H Ch Minh cng vi tri thc v tm huyt ca mnh truyn t vn
kin thc qu bu cho chng em trong sut thi gian hc tp ti trng. V
c bit, trong hc k ny, Khoa t chc cho chng em c tip cn vi
mn hc m theo em l rt hu ch i vi sinh vin ngnh K Thut My
Tnh cng nh tt c cc sinh vin thuc cc chuyn ngnh Khoa Hc K
Thut khc. l mn hc n Thit K Lun L.
Em xin chn thnh cm n Thy Nguyn Quc Tun tn tm hng
dn chng em trong nhng bui ni chuyn, tho lun v lnh vc vi x l.
Nu khng c nhng li hng dn, dy bo ca thy th em ngh bi thu
hoch ny ca em rt kh c th hon thin c. Mt ln na, em xin chn
thnh cm n thy.
Bi thu hoch c thc hin trong khong thi gian gn 4 tun. Bc
u i vo thc t, tm hiu v lnh vc vi x l, kin thc ca em cn hn
ch v cn nhiu b ng. Do vy, khng trnh khi nhng thiu st l iu
chc chn, em rt mong nhn c nhng kin ng gp qu bu ca qu
Thy C v cc bn hc cng lp kin thc ca em trong lnh vc ny
c hon thin hn. Sau cng, em xin knh chc qu Thy C trong Khoa
Khoa Hc & K Thut My Tnh v Thy Nguyn Quc Tun tht di do
sc khe, nim tin tip tc thc hin s mnh cao p ca mnh l truyn
t kin thc cho th h mai sau.
Trn trng.
TP HCM, ngy 2 thng1 nm 2014
Trang 1
LI M U
Trang 2
Trang 3
I.2. c im chnh.
Bng di y l nhng c im khc bit ca h LPC2300.
Bng 1 c im tng qut LPC2300
Part
Local
Bus
SRAM
(kB)
Flash
(kB)
EMC
USB/
GP
SRAM
(kB)
USB
device
USB
Host/
OTG
Ethernet
Ethernet
GP
SRAM
(kB)
CAN
channels
SD/
MMC
ADC
channels
GPIO
pins
LPC2361
64
No
Yes
Yes
No
16
No
70
LPC2362
32
128
No
Yes
Yes
Yes
16
No
70
LPC2364
128
No
Yes
No
Yes
16
No
70
LPC2365
32
256
No
Yes
No
Yes
16
No
70
LPC2366
32
256
No
Yes
No
Yes
16
No
70
LPC2367
32
512
No
No
No
Yes
16
Yes
70
LPC2368
32
512
No
Yes
No
Yes
16
Yes
70
LPC2377
32
512
Mini
No
No
Yes
16
Yes
104
LPC2378
32
512
Mini
Yes
No
Yes
16
Yes
104
LPC2387
64
512
No
16
Yes
Yes
Yes
16
Yes
70
LPC2388
64
512
Mini
16
Yes
Yes
Yes
16
Yes
104
Trang 4
I.3. S khi
Trang 5
Trang 6
Trang 7
Trang 8
Trang 9
General use
0x0000 0000 to
0x3FFF FFFF
on-chip NV
memory and
fast I/O
on-chip RAM
0x4000 0000 to
0x7FFF FFFF
0x8000 0000 to
0xDFFF FFFF
off-chip
memory
0xE000 0000
to
0xEFFF FFFF
0xF000 0000 to
0xFFFF FFFF
APB
peripherals
AHB
peripherals
Trang 10
Trang 11
Trang 12
Trang 13
Trang 14
Trang 15
Trang 16
Trang 17
Trang 18
Trng hp ngoi l
Reset.
Undefined Instruction.
Software Interrupt.
Prefetch Abort (instruction fetch memory fault).
Data Abort (data access memory fault).
Reserved.
IRQ.
FIQ.
Hot ng
Hardware
activation by
any Reset
User
Flash
mode
Software
activation by
boot code
User
RAM
mode
User
External
Memory
mode
Software
activation by
user program
Software
activation by
user code
Cch s dng.
The Boot Loader alwaysexecutes after any reset. The Boot ROM interrupt
vectors are mapped to the bottom of memory to allow handling
exceptions and using interrupts during the Boot Loading process. A sector
of the Flash memory(the Boot Flash) is available to hold part of the Boot
Code.
Activated by the Boot Loader when a valid User Program Signature is
recognized in memory and Boot Loader operation is not forced. Interrupt
vectors are not re-mapped and are found in the bottom of the Flash
memory.
Activated by a User Program as desired. Interrupt vectors are re-mapped
to the bottom of the Static RAM
Activated by a User Program as desired. Interrupt vectors are re-mapped
to external memory bank 0
Trang 19
I.4.5.2
Boot ROM c phn vng trn cng ca b nh, mt chng trnh d chim nhiu
hay t b nh u khng nh hng n v tr ca Boot ROM hoc khng thay i phn vng
ca vc t ngt Boot ROM.
Phn vng b nh c cp pht li cho php thc hin qu trnh ngt nhng ch
khc nhau, p dng cho vng vect ngt (32 bytes) v c 32 bytes m rng. M iu khin
vic phn vng c ct gi a ch t 0x0000 0000 v 0x0000 003F. Chng trnh trong b
nh Flash c c iu khin FIQ lu 0x0000 001C. Vect cha trong SRAM, b nh ngoi
v Boot ROM phi cha a ch n iu khin ngt tht s mt cch trc tip hay gin tip
hng qua mt cu lnh khc.
C ba l do cu hnh ny c la chn:
1. cung cp cho cc x l FIQ trong b nh Flash li th l khng phi mt mt
ranh gii b nh gy ra bi nh x li vo ti khon.
2. Gim thiu s cn thit phi cho SRAM v khi ng vector ROM gii quyt
vi bt k gii hn gia khng gian m.
3. cung cp khng gian lu tr cc hng s vt ra ngoi phm vi ca nhng
cu lnh chuyn ng cnh.
Phn vng li b nh bao gm c boot ROM v vector interrupt, tip tc xut hin
trong b nh gc thm vo cc a ch phn vng li b nh
I.4.5.3
iu khin phn vng b nh thay i phn vng ca nhng vector ngt xut hin
a ch 0x0000 0000. M chng trnh s c php chy nhng vng nh khc v iu
khin nhng ngt.
I.4.5.3.1 Thanh ghi iu khin phn vng b nh (MEMMAP 0xE01FC040)
Trang 20
Description
7:2 -
Reset
value
00
Boot Loader Mode. Interrupt vectors are re-mapped to Boot 00
ROM.
01
User Flash Mode. Interrupt vectors are not re-mapped and
reside in Flash.
10
User RAM Mode. Interrupt vectors are re-mapped to Static
RAM.
11
User External Memory Mode (available on LPC2377/78 and
LPC2388 only).
Warning: Improper setting of this value may result in incorrect
operation of the device.
Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
I.4.5.3.2 Ghi ch s dng iu khin phn vng b nh.
Trang 21
Trang 22
Reset.
Brown-Out Detection.
Ng nhp ngoi to ngt.
iu khin/ Thng s h thng.
Bo mt v Tm li code.
AHB configuration.
Mi chc nng c mt hay nhiu thanh ghi ca ring n. Nhng bit khng cn thit trong thanh
ghi s c gi li cho nhng m rng v sau. Nhng chc nng khng lin quan vi nhau khng chia
s chung bt c thanh ghi no.
I.5.2 Chn kt ni ngoi ca khi iu khin h thng.
Bng sau y th hin nhng chn kt ni ngoi lin quan n nhng chc nng ca khi iu
khin h thng.
Bng 8 B nh mc thp cho thy qu trnh ti phn vng b nh
Pin name Pin
direction
EINT0 Input
EINT1
EINT2
EINT3
RESET
Input
Input
Input
Input
Pin description
External Interrupt Input 0- An active low/high level or falling/rising
edge general purpose interrupt input. This pin may be used to wake up
the processor from Idle or Power-down modes.
External Interrupt Input 1- See the EINT0 description above.
External Interrupt Input 2- See the EINT0 description above.
External Interrupt Input 3- See the EINT0 description above.
External Reset input- A LOW on this pin resets the chip, causing
I/O ports and peripherals to take on their default states, and the
processor to begin execution at address 0x0000 0000.
Trang 23
Description
Access Reset
value
Address
R/W
R/W
R/W
0x00
0x00
0x00
0xE01F C140
0xE01F C148
0xE01F C14C
R/W
see
text
0xE01F C180
R/W
AHBCFG2
R/W
External interrupts
EXTINT
External Interrupt Flag Register
EXTMODE External Interrupt Mode register
EXTPOLAR External Interrupt Polarity Register
Reset
RSID
Reset Source Identification Register
R/W
0x08
0xE01F C1A0
I.5.4 Reset
C 4 cch Reset trn LPC2300:
Trang 24
Trang 25
Trang 26
II.4.5.1
Thanh ghi cha 1 bit cho tng ngun Reset ring bit. Di y l bng th hin s
tng tc gia 4 ngun Reset.
Bng 10 S tng tc gia 4 ngun Reset
Bit
Symbol
POR
EXTR
WDTR
BODR
Description
Reset
value
Assertion of the POR signal sets this bit, and clears all of the other bits See
in this register. But if another Reset signal (e.g., External Reset) text
remains asserted after the POR signal is negated, then its bit is set. This
bit is not affected by any of the other sources of Reset
Assertion of the RESET signal sets this bit. This bit is cleared by POR, See
but is not affected by WDT or BOD reset.
text
This bit is set when the Watchdog Timer times out and the See
WDTRESET bit in the Watchdog Mode Register is 1. It is cleared by text
any of the other sources of Reset.
This bit is set when the 3.3 V power reaches a level below 2.6 V.If the See
VDD(DCDC)(3V3) voltage dips from 3.3 V to 2.5 V and backs up, the text
BODR bit will be set to 1.If the VDD(DCDC)(3V3) voltage dips from
3.3 V to 2.5 V and continues to decline to the level at which POR is
asserted (nominally 1 V), the BODR bit is cleared. If the
VDD(DCDC)(3V3) voltage rises continuously from below 1 V to a
level above 2.6 V, the BODR will be set to 1. This bit is not affected
by External Reset nor Watchdog Reset. Note:Only in case when a reset
occurs and the POR = 0, the BODR bit indicates if the
VDD(DCDC)(3V3)voltage was below 2.6 V or not.
I.5.5
External interrupt.
Vi x l LPC2300 bao gm bn u vo External interrupt. Ngoi ra, External interrupt c
kh nng wakeup CPU t ch Power iu ny c iu khin bi thanh ghi INTWAKE.
Bng 11 Cc thanh ghi ca External interrupt
Name
EXTINT
EXTMODE
EXTPOLAR
Description
Trang 27
EINT0
EINT1
EINT2
EINT3
Reset
value
In level-sensitive mode, this bit is set if the EINT0 function is selected for 00
its pin, and the pin is in its active state. In edge-sensitive mode, this bit is
set if the EINT0 function is selected for its pin, and the selected edge occurs
on the pin.
In level-sensitive mode, this bit is set if the EINT1 function is selected for
its pin, and the pin is in its active state. In edge-sensitive mode, this bit is
set if the EINT1 function is selected for its pin, and the selected edge occurs
on the pin.
In level-sensitive mode, this bit is set if the EINT2 function is selected for
its pin, and the pin is in its active state. In edge-sensitive mode, this bit is
set if the EINT2 function is selected for its pin, and the selected edge occurs
on the pin.
In level-sensitive mode, this bit is set if the EINT3 function is selected for
its pin, and the pin is in its active state. In edge-sensitive mode, this bit is
set if the EINT3 function is selected for its pin, and the selected edge occurs
on the pin.
EXTMODE0
EXTMODE1
EXTMODE2
EXTMODE3
Value Reset
value
0
00
1
0
1
0
1
0
1
EXTPOLAR0
EXTPOLAR1
EXTPOLAR2
EXTPOLAR3
Value Reset
value
0
00
1
0
1
0
1
0
1
Trang 28
Trang 29
VICFIQStatus
VICRawIntr
VICIntSelect
VICIntEnable
VICIntEnClr
VICSoftInt
VICSoftIntClear
VICProtection
VICSWPriority
Mask
VICVectAddr0
VICVectAddr1
to
VICVectAddr31
VICVectPriority
0
Description
Trang 30
R/W
0xF
0xFFFF
F204 to
0xFFFF
F264
Trang 31
Khi status interrupt c vai tr : cha cc thng tin v cc interrupt hin ti v sinh ra FIQ
Khi vectored interrupt cha thng tin v vector IRQ v a ch cn nhy ti khi c interrupt
Khi priority and generation: c nhim v chn interrupt no s lm, v a ch no s nhy
ti.
I.7.4 Ngun Interrupt
Bng 16 S kt ni ca ngun Interrupt n VIC
Block
Flag(s)
WDT
ARM Core
ARM Core
TIMER0
TIMER1
UART0
UART1
PWM1
I2C0
SPI, SSP0
SSP 1
PLL
RTC
System Control
(External Interrupts)
VIC
Hex
0
1
2
3
4
Channel # and
Mask
0x0000 0001
0x0000 0002
0x0000 0004
0x0000 0008
0x0000 0010
0x0000 0020
0x0000 0040
0x0000 0080
0x0000 0100
9
10
0x0000 0200
0x0000 0400
11
0x0000 0800
12
13
0x0000 1000
0x0000 2000
14
15
0x0000 4000
0x0000 8000
Trang 32
ADC0
I2C1
BOD
Ethernet
USB
CAN
SD/ MMC
interface
GP DMA
Timer 2
Timer 3
UART 2
UART 3
I2C2
I2 S
16
17
18
19
20
21
0x0001 0000
0x0002 0000
0x0004 0000
0x0008 0000
0x0010 0000
0x0020 0000
22
0x0040 0000
23
0x0080 0000
24
0x0100 0000
25
0x0200 0000
26
0x0400 0000
27
0x0800 0000
28
0x1000 0000
29
0x2000 0000
30
31
0x4000 0000
0x8000 0000
Trang 33
Trang 34
IOSET
IODIR
IOCLR
Access Reset
value
PORTn Register
Address & Name
R/W
NA
R/W
0x0
R/W
WO
Trang 35
Bng 20 a ch thanh ghi GPIO (local bus accessible registers - enhanced GPIO features)
Generic
Name
Description
Access Reset
value
FIODIR
FIOPIN
FIOSET
FIOCLR
0x0
PORTn Register
Address & Name
FIO0DIR - 0x3FFF C000
FIO1DIR - 0x3FFF C020
FIO2DIR - 0x3FFF C040
FIO3DIR - 0x3FFF C060
FIO4DIR - 0x3FFF C080
FIO0MASK - 0x3FFF
C010
FIO1MASK - 0x3FFF
C030
FIO2MASK - 0x3FFF
C050
FIO3MASK - 0x3FFF
C070
FIO4MASK - 0x3FFF
C090
FIO0PIN - 0x3FFF C014
FIO1PIN - 0x3FFF C034
FIO2PIN - 0x3FFF C054
FIO3PIN - 0x3FFF C074
FIO4PIN - 0x3FFF C094
Trang 36
Description
IntEnR
IntEnF
IntStatR
RO
IntStatF
RO
IntClr
WO
IntStatus
RO
0x0
Trang 37
while(1)
{
for(delay = 0;delay<0x10000;delay++)
// delay
{
;
}
IOCLR1 = ~flasher;
IOSET1 = flasher;
//shift led
flasher
0x00010000;
//
Tng
}
}
I.10.
Ethernet
Bng 22 Bng vit tt, nh ngha trong phn ny
Ch vit tt
AHB
CRC
DMA
Double-word
FCS
Fragment
Frame
Half-word
LAN
MAC
MII
MIIM
Octet
Packet
PHY
RMII
Rx
TCP/IP
nh ngha
Advanced High-performance bus
Cyclic Redundancy Check
Direct Memory Access
64 bit entity
Frame Check Sequence (CRC)
A (part of an) Ethernet frame; one ormultiple fragments can add up to a single
Ethernet frame
An Ethernet frame consists of destination address, source address, length
type field, payload and frame check sequence
16 bit entity
Local Area Network
Media Access Control sublaye
Media Independent Interface
MII management
An 8 bit data entity, used in lieu of "byte" by IEEE 802.3
A frame that is transported across Ethernet; a packet consists of a preamble,
a start of frame delimiterand an Ethernet frame.
Ethernet Physical Layer
Reduced MII
Receive
Transmission Control Protocol / Internet Protocol. The most common
Trang 38
Tx
VLAN
WoL
Word
I.10.1 c im chung
Ethernet c nhng h tr c bn sau:
10 or 100 Mbps PHY devices bao gm 10 Base-T, 100 Base-TX, 100 Base-FX, and 100
Base-T4.
Ph hp vi IEEE 802.3 v 802.3xFull Duplex Flow Control and Half Duplex.
Truyn dn linh hot.
H tr VLAN frame.
Qun l b nh :
Truyn dn c lp ng thi nhn c b nh m nh x vo shared SRAM.
Qun l DMA vi phn tn / tp hp DMA km theo mng m t khung.
Traffic c ti u ha bng buffering and pre-fetching.
Tnh nng nng cao:
Nhn v lc d liu.
H tr frame Multicast v broadcast cho ch truyn v nhn.
T ng chn FCS (CRC) cho truyn.
C th la chn frame hnh truyn t ng padding.
C th nhn ch Promiscuous.
T ng backoff khi ng v truyn li frame.
H tr qun l nng lng bng clock switching.
H tr qun l nng lng bng Wake-on-LAN.
Trang 39
Trang 40
Type
Output
Output
Input
Input
Input
Input
Pin Description
Transmit data enable
Transmit data, 2 bits
Receive data, 2 bits
Receive error.
Carrier sense/data valid
Reference clock
Type
Output
Input/Output
Pin Description
MIIM clock
MI data input and output
Trang 41
Address
R/W Description
0xFFE0 0000
0xFFE0 0004
0xFFE0 0008
0xFFE0 000C
0xFFE0 0010
0xFFE0 0014
0xFFE0 0018
0xFFE0 001C
0xFFE0 0020
0xFFE0 0024
0xFFE0 0028
0xFFE0 002C
0xFFE0 0030
0xFFE0 0034
0xFFE0 0038 to
0xFFE0 00FC
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
WO
RO
RO
SA0
SA1
SA2
0xFFE0 0040
0xFFE0 0044
0xFFE0 0048
0xFFE0 004C to
0xFFE0 00FC
R/W
R/W
R/W
0xFFE0 0100
0xFFE0 0104
0xFFE0 0108
0xFFE0 010C
0xFFE0 0110
0xFFE0 0114
0xFFE0 0118
0xFFE0 011C
0xFFE0 0120
0xFFE0 0124
0xFFE0 0128
0xFFE0 012C
0xFFE0 0130 to
0xFFE0 0154
R/W
RO
R/W
R/W
R/W
RO
R/W
R/W
R/W
R/W
R/W
RO
0xFFE0 0158
0xFFE0 015C
0xFFE0 0160
RO
RO
RO
Control registers
Command
Status
RxDescriptor
RxStatus
RxDescriptorNumber
RxProduceIndex
RxConsumeIndex
TxDescriptor
TxStatus
TxDescriptorNumber
TxProduceIndex
TxConsumeIndex
TSV0
TSV1
RSV
Trang 42
0xFFE0 0164 to
0xFFE0 016C
FlowControlCounter
FlowControlStatus
Rx filter registers
RxFliterCtrl
RxFilterWoLStatus
RxFilterWoLClear
HashFilterL
HashFilterH
0xFFE0 0170
0xFFE0 0174
0xFFE0 0178 to
0xFFE0 01FC
R/W
RO
0xFFE0 0200
0xFFE0 0204
0xFFE0 0208
0xFFE0 020C
0xFFE0 0210
0xFFE0 0214
0xFFE0 0218 to
0xFFE0 0FDC
RO
R/W
WO
WO
PowerDown
R/W
0xFFE0 0FF4
0xFFE0 0FF8
Trang 43
I.11.
CAN
I.11.1 nh ngha
Controller Area Network (CAN) l mt giao thc truyn thng hiu sut cao trong truyn thng
d liu ni tip. CAN Controller c thit k nhm mc ch cung cp chc nng ca giao thc
CAN.
Vi iu khin vi b iu khin CAN trn chip ny c s dng xy dng mng li khu
vc no mt cch mnh nht bng cc h tr thng qua kim sot thi gian thc vi mc bo
mt rt cao. Mt s ng dng l : t, cng nghip, v cc mng tc cao cng nh chi ph thp,
ghp ni cc h thng dy in. Kt qu l h thng dy in gim mnh v nng cao kh nng sa
cha v gim st.
Khi CAN c thit k vi h tr ng thi nhiu CAN bus v d nh gateway, switch, hoc
router. Module CAN bao gm hai yu t: the controller v the Acceptance Filter.
Tt c cc thanh ghi v b nh RAM c truy cp vi 32 bit.
I.11.2 Kin trc
Khi iu khin CAN bao gm cc khi :
APB Interface
Acceptance Filter
Vectored Interrupt Controller (VIC)
CAN Transceiver
Common Status Registers
Trang 44
Khi giao din APB (AIB) cung cp quyn truy cp vo tt c cc thanh ghi iu khin CAN.
B qun l giao din logic (IML) bin dch cc lnh t CPU, kim sot a ch thanh ghi CAN
v cung cp thng tin trng thi v interrupt t CPU.
B m truyn dn (TXB) l giao din gia qun l Interface Management Logic (IML) v Bit
Stream Processor (BSP). Mi Transmit Buffer c th lu tr tt c thng tin c truyn trn mng
CAN c vit bi CPU v c bi BSP.
Trang 45
B qun l li Logic (EML) chu trch nhim v hn ch li. EML c thng bo li t BSP
v sau thng bo cho BSP v IML v thng k li.
Bit Timing Logic (BTL) kim sot serial CAN Bus line v x l cc Bus line lin quan n Bit
Timing. BTL cn dng ng b trn phn cng (hard synchronization) cng nh ti ng b trn
phn mm (soft synchronization) nu cn thit trong tng lai.
Bit Stream Processor (BSP) l mt chui, kim sot lung d liu gia Transmit Buffer,
Receive Buffers v CAN Bus.
CAN controller self-tests bao gm hai ty chn sau : Global Self-Test (thit lp cc yu cn t
nhn bit trong ch bnh thng - normal Operating Mode) v Local Self-Test (thit lp cc yu cn
t nhn bit trong ch t kim tra - Self Test Mode).
I.11.3 a ch b nh
Bng 26 a ch b nh ca khi CAN
Address Range
0xE003 8000 - 0xE003 87FF
0xE003 C000 - 0xE003 C017
0xE004 0000 - 0xE004 000B
0xE004 4000 - 0xE004 405F
0xE004 8000 - 0xE004 805F
Used for
Acceptance Filter RAM.
Acceptance Filter Registers.
Central CAN Registers.
CAN Controller 1 Registers.
CAN Controller 2 Registers.
Description
MOD
IER
BTR
Bus Timing
EWL
CMR
GSR
ICR
CAN2 Register
Address &
Name
CAN2MOD 0xE004 8000
CAN2MOD 0xE004 8004
CAN2MOD 0xE004 8008
CAN2MOD 0xE004 800C
CAN2MOD 0xE004 8010
CAN2MOD 0xE004 8014
CAN2MOD 0xE004 8018
Trang 46
SR
Status Register
RO
RFS
R/W
RID
Received Identifier
R/W
RDA
R/W
RDB
R/W
TFI1
R/W
TID1
R/W
TDA1
R/W
TDB1
R/W
TFI2
TID2
R/W
TDA2
R/W
TFI3
TID3
R/W
TDA3
R/W
TDB2
TDB3
R/W
R/W
R/W
R/W
Trang 47
I.12.
USB
I.12.1 nh ngha
Universal Serial Bus (USB) l 1 bus c bn dy h tr lin kt gia mt my ch vi mt hoc
nhiu (ln n 127) thit b ngoi vi. B iu khin my ch cp pht bng thng cho USB vi cc
thit b gn vo thng qua giao thc token. Cc bus h tr cm vo v cu hnh ng cho cc thit b.
Mi giao dch c vn hnh bi cc b iu khin my ch.
I.12.2 Kin trc
Trang 48
B giao din thanh ghi: cho php CPU iu khin hot ng ca cc thit b iu khin USB.
N cng cung cp mt cch vit truyn d liu n b iu khin v c nhn d liu t b iu
khin.
B DMA v giao din bus ch: Khi c kch hot cho mt thit b u cui, d liu chuyn
n DMA gia RAM nh vo AHB bus v b m ca thit b u cui trong EP_RAM.
GoodLink: Good USB connection indication c cung cp thng qua cng ngh GoodLink.
Khi cc thit b c cu hnh thnh cng th cc n LED s ON vnh vin v trong qu trnh
suspend th LED s OFF.
I.12.3 a ch thanh ghi
Bng 28 a ch thanh ghi thit b USB
Name
Description
Address
R/W
0x0000 0000
0xFFE0 C110
R/W
RO
0x0000 0000
0x0000 0000
0xFFE0 CFF4
0xFFE0 CFF8
R/W
RO
R/W
WO
WO
WO
0x8000 0000
0x0000 0010
0x0000 0000
0x0000 0000
0x0000 0000
0x00
0xE01F C1C0
0xFFE0 C200
0xFFE0 C204
0xFFE0 C208
0xFFE0 C20C
0xFFE0 C22C
RO
R/W
WO
WO
WO
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0xFFE0
0xFFE0
0xFFE0
0xFFE0
0xFFE0
R/W
WO
R/W
0x0000 0003
0x0000 0000
0x0000 0008
0xFFE0 C244
0xFFE0 C248
0xFFE0 C24C
RO
RO
WO
WO
R/W
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0xFFE0 C218
0xFFE0 C220
0xFFE0 C21C
0xFFE0 C224
0xFFE0 C228
WO
0x0000 0000
0xFFE0 C210
C230
C234
C238
C23C
C240
Trang 49
USBCmdData
DMA registers
USBDMARSt
USBDMARClr
USBDMARSet
USBUDCAH
USBEpDMASt
USBEpDMAEn
USBEpDMADis
USBDMAIntSt
USBDMAIntEn
USBEoTIntSt
RO
0x0000 0000
0xFFE0 C214
RO
WO
WO
R/W
RO
WO
WO
RO
R/W
RO
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0x0000 0000
0xFFE0 C250
0xFFE0 C254
0xFFE0 C258
0xFFE0 C280
0xFFE0 C284
0xFFE0 C288
0xFFE0 C28C
0xFFE0 C290
0xFFE0 C294
0xFFE0 C2A0
WO
0x0000 0000
0xFFE0 C2A4
WO
0x0000 0000
0xFFE0 C2A8
RO
0x0000 0000
0xFFE0 C2AC
WO
0x0000 0000
0xFFE0 C2B0
WO
0x0000 0000
0xFFE0 C2B4
RO
0x0000 0000
0xFFE0 C2B8
WO
0x0000 0000
0xFFE0 C2BC
WO
0x0000 0000
0xFFE0 C2C0
UART
Trang 50
Vic truyn tn hiu ca UART : cng tng t nh th, CPU truyn d liu vo trong buffer
trong thanh ghi UnTHR (UART TX Holding Register FIFO), sau d liu t thanh ghi ny c
chuyn sang thanh ghi dch (UnTSR) v t t truyn ra ngoi thng qua chn TXD
V tc truyn d liu UART cho php cho thit lp tc baud thng qua cc thanh ghi.
V ta phi t tm ra tc baud no hp l nht (tc xc sut li trn ng truyn t nht) Vn
ny s c tho lun trong phn sau.
Cc s thit lp interrupt trong thanh ghi UnIER v UnIIR
Thng tin t vic truyn nhn (2 chn TX v RX) c lu trong thanh ghi UnLSR.
Thng tin iu khin nm trong thanh ghi UnLCR
Trang 51
Trang 52
THRE interrupt
I.13.3.5 UnDLL - UART Divisor Latch LSB Register v UnDLM - UART Divisor
Latch MSB Registers (U0DLL - 0xE000 C000, U1DLL - 0xE001 0000 , U1DLM - 0xE001
0004 , U2DLL - 0xE007 8000, U3DLL - 0xE007 C000 v U0DLM - 0xE000 C004, U2DLL
- 0xE007 8004, U3DLL - 0xE007 C004 khi DLAB = 1)
Trang 53
UnDLL l mt phn ca UART Baud Rate Generator. Thanh ghi UnDLL v UnDLM
dng chia mt s 16 bit, thanh ghi UnDLL cha 8 bit thp cn thanh ghi UnDLM cha 8
bit cao.
I.13.3.6 UnFCR - UART FIFO Control Register (U0FCR - 0xE000 C008, U1FCR
- 0xE001 0008, U2FCR - 0xE007 8008, U3FCR - 0xE007 C008)
UnFCR thanh ghi iu khin cc hot ng ca UARTn Rx v TX FIFOs
I.13.3.7 UnLCR - UART Line Control Register (U0LCR - 0xE000 C00C, U1LCR 0xE001 000C , U2LCR - 0xE007 800C, U3LCR - 0xE007 C00C)
UnLCR thit lp cc nh dng truyn v nhn.
I.13.3.8 UnLSR - UART Line Status Register ((U0LSR - 0xE000 C014, U1LCR 0xE001 000C, U2LSR - 0xE007 8014, U3LSR - 0xE007 C014)
UnLSR cha cc thng tin v vic truyn nhn (li, thanh ghi cha d liu ang rng ).
I.13.3.9 UnSPR - UART Scratch Pad Register (U0SCR - 0xE000 C01C, U1SCR 0xE001 001C , U2SCR - 0xE007 801C U3SCR - 0xE007 C01C)
UnSCR khng nh hng n hot ng UARTn. Thanh ghi ny cho php vit and /
or v c theo quyt nh ca ngi dng.
I.13.3.10 UnACR - UART Auto-baud Control Register (U0ACR - 0xE000 C020,
U1ACR - 0xE001 0020 , U2ACR - 0xE007 8020, U3ACR - 0xE007 C020)
UnACR kim sot qu trnh o tc clock / d liu v c th c c v vit theo
ca ngi dng.
I.13.3.11 UFDR - UART Fractional Divider Register (U0FDR - 0xE000 C028,
U1FDR - 0xE001 0028 , U2FDR - 0xE007 8028, U3FDR - 0xE007 C028)
UFDR kim sot clock pre-scaler ca cc baud rate v c th c c/vit theo
ca ngi dng.
I.13.3.12 Auto Flow Chart
khi ng cho UART u tin ta phi thit lp chn TXD v RXD cho n
UART3 (c chn TXD3 l P0.0 hay P4.28 v RXD3 l P0.1 hay P4.29)
Trang 54
Mode 0: Baud rate c tnh ton da trn 2 cnh xung ca chn RX (1 cnh
xung l ca Start bit v 1 cnh xung l ca tn hiu d liu)
Trang 55
Mode 1: Baud rate c tnh ton gia cnh xung v cnh ln ca Start bit (n
chnh l di ca Start bit)
16 215
16 (2 + + + )
16 256 + (1+
Trang 56
Trang 57
0x01
#define IER_THRE
0x02
#define IER_RLS
0x04
Kim tra c cho php gi nu cho php th a 1 byte d liu vo thanh ghi
UnTHR, tt c cho php gi.
Kim tra thanh ghi UnLSR, nu bit 0 Receive Data Ready RDR l 1 tc l ang c
d liu
VD khi ng UART0
#define IER_RBR
0x01
#define IER_THRE
0x02
#define IER_RLS
0x04
Trang 58
I.14.
SPI
I.14.1 nh ngha
SPI l giao din kt ni full duplex. SPI c th x l masters v slaves c kt ni thng
qua cc bus. Ch c th giao tip gia mt master v mt slave trn giao din trong mt truyn d
liu nht nh. Trong mt truyn d liu, master lun lun gi 8-16 bit d liu cho cc slave, v slave
lun lun gi mt byte d liu n master.
Trang 59
Data sampled
settings
CPOL = 0, CPHA = 0
CPOL = 0, CPHA = 1
CPOL = 1, CPHA = 0
CPOL = 1, CPHA = 1
Description
Access Reset
Address
Value
S0SPCR
0x00
0xE002 0000
0x00
0xE002 0004
0x00
0xE002 0008
0x00
0xE002 000C
0x00
0xE002 001C
S0SPDR
S0SPCCR
S0SPINT
Trang 60
I.14.3.1
Symbol
Value
Description
Reset
Value
1:0
BitEnable
CPHA
CPOL
MSTR
LSBF
Trang 61
SPIE
11:8
BITS
15:12 -
1000
1001
1010
1011
1100
1101
1110
1111
0000
Trang 62
I.14.3.2
Reset
Value
2:0 -
Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined.
ABRT
Slave abort. When 1, this bit indicates that a slave abort has occurred. This 0
bit is cleared by reading this register.
MODF
Mode fault. when 1, this bit indicates that a Mode fault error has occurred.
This bit is cleared by reading this register, then writing the SPI0 control
register.
ROVR
Read overrun. When 1, this bit indicates that a read overrun has occurred.
This bit is cleared by reading this register.
WCOL
Write collision. When 1, this bit indicates that a write collision has
occurred. This bit is cleared by reading this register, then accessing the SPI
data register.
SPIF
SPI transfer complete flag. When1, this bit indicates when a SPI data
transfer is complete. When a master, this bit is set at the end of the last cycle
ofthe transfer. When a slave, this bit is set on the last data sampling edge
of the SCK. This bit is cleared by first reading this register, then accessing
the SPI data register.
Note:this is not the SPI interrupt flag. This flag is found in the
SPINT register.
I.14.3.3
Thanh ghi d liu 2 chiu cung cp kh nng truyn v nhn cho SPI. D liu truyn
th c cung cp nh SPI v c vit vo thanh ghi ny. Tng t d liu nhn t SPI cng
c c t thanh ghi ny. Khi mt master hot ng, thanh ghi s bt u vic vit d liu,
Trang 63
khi SPIF status c set th d liu truyn b block, ng thi trng thi thanh ghi s khng
c c na.
I.14.3.4
Reset
Value
Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined
7:1 Test
SPI test mode. When 0, the SPI operates normally. When 1, SCK will 0
always be on, independent of master mode select, and data availability
setting.
I.14.3.6
Symbol
Description
Reset
Value
2:0
Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined.
ABRT
Slave abort.
MODF
Mode fault.
ROVR
Read overrun.
Trang 64
WCOL
Write collision.
SPIF
I.14.3.7
Trang 65
I.15.
I2C
ng b bng xung tun t cho php nhiu thit b vi tc truyn nhn khc nhau
giao tip trn cng mt knh.
Trang 66
6
5
4
3
2
1
0
I2EN
STA
STO
SI
AA
1
0
0
0
0
Trong ch ny, bit R/W nn l 0, tc l ghi. Byte u tin gi i ch a ch ca
thit b nhn (7 bit) v bit R/W quyt nh chiu ca d liu. Giao tip I2C s khi ng vo
ch Master truyn khi chng trnh phn mm gn STA = 1. Giao tip I2C s gi tn hiu
START khi knh truyn rnh. Sau khi START c truyn, bit SI s c gn = 1, v gi tr
ca thanh ghi I2STAT l 0x08. Byte gm a ch ca Slave v bit R/W c truyn vo thanh
ghi I2DAT, sau bit SI c xo = 0. Bit SI c xo bng cch gn 1 vo bit SIC trong
thanh ghi I2CONCLR.
Sau khi truyn byte cha a ch Slave v bit R/W, v ACK c tr v, bit SI li c
gn = 1, thanh ghi I2STAT lc ny c th mang gi tr 0x18, 0x20 hay 0x38 ( ch Master);
0x66, 0x78 hay 0xB0 ( ch Slave).
Trang 67
Hnh 33 Ch Master nhn chuyn thnh Master truyn sau khi gi START lp li
I.15.3.3 Ch Slave nhn
D liu s c gi t Master n, thit lp ch ny, thanh ghi I2ADR v
I2CONSET phi c thit lp nh sau:
Bng 36 Thanh ghi I2CnCONSET c s dng trong ch Slave
Bit
7
Symbol Value
-
6
5
4
3
2
1
0
I2EN
STA
STO
SI
AA
1
0
0
0
1
Sau khi cc thanh ghi I2ADR v I2CONSET c thit lp, giao tip I2C s ch n
khi n c gn a ch. Nu bit R/W l 0, giao tip ny l Slave nhn, ngc li, n s tr
thnh Slave truyn. Sau khi byte cha a ch Slave v bit R/W c nhn, SI c gn = 1 v
KHOA HC & K THUT MY TNH
n Thit K Lun L GVHD : Nguyn Quc Tun
Thc hin : Nguyn Thanh Bi Minh Chin
Trang 68
Trang 69
I.15.4 Kt ni vt l
Type
Input/Ouput
Input/Ouput
Description
I2C serial Data
I2C serial Clock
Trang 70
Trang 71
Trang 72
Description
Access Reset
Name
value
0x00
I2CONSE
I2C
Status
Register.During
I2C RO
0xF8
mode, data to be
0x00
Trang 73
I2SCLL
0x04
I2C clock
0x04
I2CONCL
Trang 74
Symbol
1:0 2
3
4
5
6
7
Description
Reserved. User software should not write ones to reserved bits. The value
read from a reserved bit is not defined.
Assert acknowledge flag.
I2C interrupt flag.
STOP flag.
START flag.
I2C interface enable.
Reserved. User software should not write ones to reserved bits. The value
read from a reserved bit is not defined.
AA
SI
STO
STA
I2EN
-
Reset
Value
NA
0
0
0
0
0
-
Symbol
1:0 2
3
4
AA
SIC
-
5
6
7
STAC
I2ENC
-
Description
Reserved. User software should not write ones to reserved bits. The value
read from a reserved bit is not defined.
Assert acknowledge Clear bit
I2C interrupt Clear bit.
Reserved. User software should not write ones to reserved bits. The
value read from a reserved bit is not defined.
START flag Clear bit.
I2C interface Disable bit.
Reserved. User software should not write ones to reserved bits. The value
read from a reserved bit is not defined.
Reset
Value
NA
0
0
0
0
0
-
Trang 75
Trang 76
I.16.
TIMER
Trang 77
I.16.3.6 Prescale Counter register (T0PC - T3PC, 0xE000 4010, 0xE000 8010,
0xE007 0010, 0xE007 4010)
TnPC kim sot phn chia PCLK bi mt s gi tr khng i trc khi n c p
dng cho Timer Counter. iu ny cho php kim sot phn gii ca b m thi gian so
vi thi gian ti a trc khi trn b m thi gian.
I.16.3.7
MRn lin tc so snh gi tr vi Timer Counter : khi hai gi tr bng nhau th cc hot
ng s t kch hot. Hot ng c th l to ra mt interrupt, reset Timer Counter, ng b
m v c iu khin bi thanh ghi MCR.
I.16.3.8 Match Control Register (T[0/1/2/3]MCR - 0xE000 4014, 0xE000 8014,
0xE007 0014, 0xE007 4014)
MCR c s dng kim sot nhng g hot ng c thc hin khi mt MRn
bng gi tr Timer Counter.
I.16.3.9
Trang 78
Trang 79
Trang 80
dng
th
chng
trnh
RealView
MDK-ARM
Microcontroller
Development Kit.
o Mt s chng trnh v d chy trn board MCB2300.
o File hng dn s dng ca board MCB2300.
Chng
trnh
chy
trn
board
MCB2300
th
tm
thy
Trang 81
1 cng COM RS-232 nu s dng cch np bng ISP thng qua cng giao tip
download/debug.
serial.
KHOA HC & K THUT MY TNH
n Thit K Lun L GVHD : Nguyn Quc Tun
Thc hin : Nguyn Thanh Bi Minh Chin
Trang 82
II.16.6.1 Ci t board.
Board MCB2300 dng ngun in t cng USB.
Trang 83
II.16.6.2
Kt ni vi U-LINK.
Trang 84
Danh sch th xung Max JTAG Clock dng ch nh xung JTAG cao nht
c dng giao tip vi board th nghim. Nn chn gi tr 200 kHz board
MCB2300 hot ng tt nht.
ULINK2 JTAG c thm chn RTCK (Return Clock). Nu s dng adapter ULINK2, chng ta
c th thit lp Max JTAG Clock l 200 kHz hoc RTCK.
J9 v J10 : ON.
J13 : OFF.
Trang 85
Trang 86
Jumper
State Description
J1 - USB (D-)
ON
J2 - USB (D+)
ON
J3 - AOUT
ON
J4 -
--
Not used
J5 - UMODE
ON
J6 - AD0.0
ON
J8 - INT0
ON
J9 - RST
ON
J10 - ISP
OFF
J11 - LED
ON
J13 - ETM
ON
Enables the Embedded Trace Macrocell (so that the USB soft-connect and
the LED's can be used)
Trang 87
PH LC
IU KHIN LED
Trn board MCB2300 gm c 8 con led nh, t P2.0 n P2.7. s dng ta ch vic set cc chn
l chn output. iu ny c th c thc hin thng qua hm LED_Init.
/* Function that initializes LEDs
*/
void LED_Init(void) {
PINSEL10 = 0;
FIO2DIR
= 0x000000FF;
*/
FIO2MASK = 0x00000000;
}
Ngoi ra iu khin cng nh xut gi tr nht nh ra LED ta dng hm bt - LED_On, tt LED_Off v xut - LED_Out.
/* Function that turns on requested LED
*/
*/
*/
*/
*/
}
KHOA HC & K THUT MY TNH
n Thit K Lun L GVHD : Nguyn Quc Tun
Thc hin : Nguyn Thanh Bi Minh Chin
Trang 88
IU KHIN LCD
Trn board MCB2300 c mt LCD 16x2 (16 ct v 2 hng) v bin tr dng chnh tng
phn. Vic s dng LCD ny s kh n gin nu nh ta c cc hm b tr t th vin LCD.h v
LCD_4bit.c vi cc hm tng ng vi chc nng nht nh nh sau:
Thit lp LCD controller
void lcd_init
(void);
Xa mn hnh LCD
void lcd_clear
(void);
Xut k t ra LCD
void lcd_putchar (char c);
Thit lp v tr ca cursor trn LCD, column v line tng ng vi s ct v hng ca LCD.
void set_cursor
Trang 89
KT LUN
Ti liu tham kho
[1] Trang WEB www.nxp.com
[2] Trang WEB www.keil.com
[3] User manual LPC23xx
[4] a cd LPC_3_2007
[5] Tng quan vi x l LPC2378. Hng dn s dng board MCB2300 ng Vit Hng,
Trn Trung Tn.
Kt lun
Cng vic lm c:
Nghin cu kin trc v tp lnh ARM7
Nghin cu v s dng board MCB2300
Nghin cu 1 s chc nng c bn ca LPC2378
Interrupt
Ethernet
Timer
CAN
USB
UART
SPI
I2C
Chy led
ng h hin th LCD
Trang 90