Presentation is loading. Please wait.

Presentation is loading. Please wait.

Micro-processor vs. Micro-controller

Similar presentations


Presentation on theme: "Micro-processor vs. Micro-controller"— Presentation transcript:

1 Micro-processor vs. Micro-controller

2 PIC16F877 40pin DIP CMOS technology RISC CPU
35 single word instructions DC-20MHz clock DC-200ns instruction cycle

3 PIC 16F877

4 Clock/Pipeline

5 Program Memory/Stack

6

7

8

9

10 Instruction 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 sublw 2

11 Bit, Byte, Literal/Control Instruction Formats

12

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

14 Lab Exercise: Failing loop test
#device PIC16F877 *=8 ADC=8 void main() { int c; for (c=9;c<=255;c++); } movlw 0x0 A movwf 0xA goto MAIN nop MAIN clrf 0x4 F movlw 0x1F andwf 0x3 movlw 0x9 A movwf 0x21 AA incf 0x21 000A goto 0x9 000B sleep

15 Working loop test (1) #device PIC16F877 *=8 ADC=8 void main() { int c;
for (c=9;c<=254;c++); } movlw 0x0 A movwf 0xA goto MAIN nop MAIN clrf 0x4 F movlw 0x1F andwf 0x3 movlw 0x9 A movwf 0x21 FF movlw 0xFF 000A subwf 0x21,W 000B btfsc 0x3,0x0 000C 280F goto 0xF 000D 0AA incf 0x21 000E goto 0x9 000F sleep

16 Working loop test (2) #device PIC16F877 *=8 ADC=8 void main() {
long c; for (c=9;c<=255;c++); } movlw 0x0 A movwf 0xA goto MAIN nop MAIN clrf 0x4 F movlw 0x1F andwf 0x3 A clrf 0x22 movlw 0x9 A movwf 0x21 000A 08A movf 0x22 000B 1D btfss 0x3,0x2 000C goto 0x11 000D 0AA incf 0x21 000E btfsc 0x3,0x2 000F 0AA incf 0x22 A goto 0xA sleep

17 Another loop Fails #device PIC16F877 *=8 ADC=8 void main() { int c;
do{}while (c++ <= 255); } movlw 0x0 A movwf 0xA goto MAIN nop MAIN clrf 0x4 F movlw 0x1F andwf 0x3 movlw 0x9 A movwf 0x21 goto 0x9 000A sleep

18 While Loop OK! #device PIC16F877 *=8 ADC=8 void main() { int c; c=9;
do { } while (c++!=255); } movlw 0x0 A movwf 0xA goto MAIN nop MAIN clrf 0x4 F movlw 0x1F andwf 0x3 movlw 0x9 A movwf 0x21 movf 0x21,W 000A 0AA incf 0x21 000B 00F movwf 0x77 000C 0A incf 0x77,W 000D 1D btfss 0x3,0x2 000E goto 0x9 000F sleep


Download ppt "Micro-processor vs. Micro-controller"

Similar presentations


Ads by Google