1 / 21

MicroChip

MicroChip. UNCA ECE 406 April 11, 2007. MicroChip processors. Very popular in embedded systems Small instruction set About 35 instructions Many with built-in A-to-D MPLAB IDE Used in the Boe-Bot Cheap. Some processors. PIC10F200 8-bit microcontroller PIC24FJ128GA

alijah
Télécharger la présentation

MicroChip

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MicroChip UNCA ECE 406 April 11, 2007

  2. MicroChip processors • Very popular in embedded systems • Small instruction set • About 35 instructions • Many with built-in A-to-D • MPLAB IDE • Used in the Boe-Bot • Cheap

  3. Some processors • PIC10F200 • 8-bit microcontroller • PIC24FJ128GA • 16-bit microcontroller • dsPIC30 • 16-bit Digital Signal Controllers • Serial EEPROM • In many protocols

  4. Harvard architecture • Program memory • Holds instructions • Vector table • Data memory • Register file • Access to I/O • Some special purpose registers • Two for indirect access

  5. Data memory • General purpose registers • May be as small as 8 bytes • May be in “banks” • May be “unimplemented” • CPU control registers • For I/O, etc. • Operation status (Z and C bits) • Accumulator and W registers • May be used to store arithmetic results

  6. W register • Heavily used in smaller processors • To add 33h and 34h and store in 37h MOVE 33h, W ADDF 34h, W MOVWF 37h • Larger processors • Arrays of W registers • Accumulators for fixed point operators

  7. ALU ops on low-end processors • Three categories, according to destination • Always in W register • Always in a file register • Could be either a file register or W register • Generally a single bit specifies which one

  8. Common operands • Assuming a low-end chip • Possible operands • k, a constant (literal) – probably 0 to 255 • f, a file register – limit depends on the chip • d, chooses between W and the file register • Either W or F • b, a bit index – 0 to 7

  9. Destination always W

  10. Destination always file register

  11. Destination is either -- 1 d can be either F or W All set Z bit

  12. Destination is either -- 2 All these involve the C bit There is also a DC (digit carry) bit for add and subtract d can be either F or W All set Z bit

  13. Destination is either -- 3 d can be either F or W All set Z bit

  14. Unconditional branches • Build an infinite loop with the GOTO loop ADDLW 20h,F ADDLW 2 GOTO loop • Generally you’ll need a GOTO in the reset vector ORF 0h reset GOTO start

  15. Skipping for a conditional Sometimes you can skip the next instruction The Z, C, and DC bits are stored in the STATUS register

  16. An ordinary C program tot = 0 ; for (i=25; i != 0; --i) tot = tot + i ;

  17. A PIC program I EQU 30h ; define I to be file register 30h TOT EQU 31h ; define TOT to be register 31h CLRF TOT ; TOT = 0 MOVLW 25 ; W = 25 MOVWF I ; I = W = 25 FORL MOVF I,W ; W = I ADDF TOT,W ; TOT = TOT + W = TOT + I DECFZ I ; I = I – 1 GOTO FORL ; skip if I is 0 FORE: .... ; out of the loop

  18. Special file registers • File registers may be used for • Input and output pins • Program counter • Status bits • Analog-to-digital converters • Timers • “Memory” mapping • Examples are from PIC10F200

  19. Status register • Register 03h • Time-out • Wake-up • Z bit -- 2 • DC bit – 1 • C bit -- 0

  20. To test if equal • C code if (F20 == F21) F25 = 7 • PIC code MOVWF 20h ; W = F20 SUBWF 21h,W ; W = F20-F21 BTFSS STATUS,Z GOTO labelX ; skip if Z bit set MOVLW 7 ; W = 7 MOVWF 25h ; F25 = 7 labelX ...

  21. To test if less than • C code if (F20 < F21) F25 = 7 • PIC code MOVWF 20h ; W = F20 SUBWF 21h,W ; W = F20-F21 BTFSS STATUS,C GOTO labelX ; skip if C bit set MOVLW 7 ; W = 7 MOVWF 25h ; F25 = 7 labelX ...

More Related