Title: Micro-processor vs. Micro-controller
1Micro-processorvs.Micro-controller
2PIC16F877
- 40pin DIP
- CMOS technology
- RISC CPU
- 35 single word instructions
- DC-20MHz clock
- DC-200ns instruction cycle
3PIC 16F877
4Clock/Pipeline
5Program Memory/Stack
6(No Transcript)
7(No Transcript)
8(No Transcript)
9(No Transcript)
10Instruction Set
- Default destination
- STATUS Register
- Subtraction (Borrow Flag)
W EQU H'0000' standard definitions F
EQU H'0001' ...to avoid having to write
numbers incf var,W W var 1, var
is unchanged incf var,F var var 1,
W is unchanged
addlw -2 sublw 2
11Bit, Byte, Literal/Control Instruction Formats
12(No Transcript)
13Tool Chain (MPLAB/CCS)
- Programming facilities
- Pre-processor functions
- Code checking/warning
- Prepared include/library files
- Debug without hardware
- limited programming cycles
- safety -- bugs may blow equipment
- Debug with equipment
- on-line view of register values help to track
down problems.
14Lab ExerciseFailing loop test
device PIC16F877 8 ADC8 void main() int
c for (c9clt255c)
0000 3000 movlw 0x0
0001 008A movwf 0xA
0002 2804 goto MAIN
0003 0000 nop
0004 0184 MAIN
clrf 0x4 0005
301F movlw 0x1F
0006 0583 andwf 0x3
0007 3009 movlw 0x9
0008 00A1 movwf 0x21
0009 0AA1
incf 0x21 000A 2809
goto 0x9
000B 0063 sleep
15Working loop test (1)
device PIC16F877 8 ADC8 void main() int
c for (c9clt254c)
0000 3000 movlw 0x0
0001 008A movwf 0xA
0002 2804 goto MAIN
0003 0000 nop
0004 0184 MAIN
clrf 0x4 0005
301F movlw 0x1F
0006 0583 andwf 0x3
0007 3009 movlw 0x9
0008 00A1 movwf 0x21
0009 30FF
movlw 0xFF 000A 0221
subwf 0x21,W
000B 1803 btfsc 0x3,0x0
000C 280F goto 0xF
000D 0AA1 incf 0x21
000E 2809 goto
0x9 000F 0063
sleep
16Working loop test (2)
device PIC16F877 8 ADC8 void main() long
c for (c9clt255c)
0000 3000 movlw 0x0
0001 008A movwf 0xA
0002 2804 goto MAIN
0003 0000 nop
0004 0184 MAIN
clrf 0x4 0005
301F movlw 0x1F
0006 0583 andwf 0x3
0007 01A2 clrf 0x22
0008 3009 movlw 0x9
0009 00A1
movwf 0x21 000A 08A2
movf 0x22
000B 1D03 btfss 0x3,0x2
000C 2811 goto 0x11
000D 0AA1 incf 0x21
000E 1903
btfsc 0x3,0x2 000F 0AA2
incf 0x22
0010 280A goto 0xA
0011 0063 sleep
17Another loop Fails
device PIC16F877 8 ADC8 void main() int
c c9 dowhile (c lt 255)
0000 3000 movlw 0x0
0001 008A movwf 0xA
0002 2804 goto MAIN
0003 0000 nop
0004 0184 MAIN
clrf 0x4 0005
301F movlw 0x1F
0006 0583 andwf 0x3
0007 3009 movlw 0x9
0008 00A1 movwf 0x21
0009 2809
goto 0x9 000A 0063
sleep
18While Loop OK!
device PIC16F877 8 ADC8 void main() int
c c9 do while (c!255)
0000 3000 movlw 0x0
0001 008A movwf 0xA
0002 2804 goto MAIN
0003 0000 nop
0004 0184 MAIN
clrf 0x4 0005
301F movlw 0x1F
0006 0583 andwf 0x3
0007 3009 movlw 0x9
0008 00A1 movwf 0x21
0009 0821
movf 0x21,W 000A 0AA1
incf 0x21
000B 00F7 movwf 0x77
000C 0A77 incf 0x77,W
000D 1D03 btfss
0x3,0x2 000E 2809
goto 0x9 000F 0063
sleep