Micro-processor vs. Micro-controller

18
Micro-processor vs. Micro-controller

description

Micro-processor vs. Micro-controller. PIC16F877. 40pin DIP CMOS technology RISC CPU 35 single word instructions DC-20MHz clock DC-200ns instruction cycle. PIC 16F877. Clock/Pipeline. Program Memory/Stack. Instruction Set. W EQU H'0000' ; standard definitions - PowerPoint PPT Presentation

Transcript of Micro-processor vs. Micro-controller

Page 1: Micro-processor vs. Micro-controller

Micro-processorvs.

Micro-controller

Page 2: Micro-processor vs. Micro-controller

PIC16F877• 40pin DIP• CMOS technology• RISC CPU• 35 single word instructions• DC-20MHz clock

– DC-200ns instruction cycle

Page 3: Micro-processor vs. Micro-controller

PIC 16F877

Page 4: Micro-processor vs. Micro-controller

Clock/Pipeline

Page 5: Micro-processor vs. Micro-controller

Program Memory/Stack

Page 6: Micro-processor vs. Micro-controller
Page 7: Micro-processor vs. Micro-controller
Page 8: Micro-processor vs. Micro-controller
Page 9: Micro-processor vs. Micro-controller
Page 10: Micro-processor vs. Micro-controller

Instruction Set

• Default destination

• STATUS Register

• Subtraction (Borrow Flag)

W EQU H'0000' ; standard definitionsF 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

Page 11: Micro-processor vs. Micro-controller

Bit, Byte, Literal/Control Instruction Formats

Page 12: Micro-processor vs. Micro-controller
Page 13: Micro-processor vs. Micro-controller

Tool 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.

Page 14: Micro-processor vs. Micro-controller

Lab Exercise:Failing loop test

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

#device PIC16F877 *=8 ADC=8void main(){

int c;for (c=9;c<=255;c++);

}

Page 15: Micro-processor vs. Micro-controller

Working loop test (1)

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

#device PIC16F877 *=8 ADC=8void main(){

int c;for (c=9;c<=254;c++);

}

Page 16: Micro-processor vs. Micro-controller

Working loop test (2)

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

#device PIC16F877 *=8 ADC=8void main(){

long c;for (c=9;c<=255;c++);

}

Page 17: Micro-processor vs. Micro-controller

Another loop Fails

#device PIC16F877 *=8 ADC=8void main(){

int c;c=9;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 2809 goto 0x9 000A 0063 sleep

Page 18: Micro-processor vs. Micro-controller

While Loop OK!

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

#device PIC16F877 *=8 ADC=8void main(){

int c;c=9;do { } while (c++!=255);

}