PIC微控制器

PIC微控制器(PIC microcontroller),是一種使用哈佛結構精簡指令集微控制器,由Microchip公司研發而成。

PIC microcontrollers

PIC的架構是明顯的最低限度。它具有以下特點:

  • 分離式的和(哈佛結構)
  • 少量的固定長度指令
  • 指令是單週期執行(4時鐘週期),僅流程轉移指令(call, goto, return, 成立時的條件跳躍)需兩個指令週期
  • 所有 RAM 位置均可當作作為算數或其他運算的源寄存器或目的寄存器使用
  • 一個用於存放的返回地址
  • 較小的定址空間,但使用多個 bank 的方式(每個 bank 通常為 128 字節),來存取較大的 RAM
  • 暫存器、等均映射在空間中
  • 程序計數器也是映射到空間和寫入(這是用來執行間接跳躍)

歷史

GI 的 PIC1655A, 於台灣封裝

PIC 微控制器源自於 1980 年代由通用儀器所推出的 PIC1650 系列,當時的 PIC 是周邊介面控制器(Peripheral Interface Controller)的簡稱。

GI 的微電子部門於 1987 年分拆成為 Microchip Technology (微芯) 公司。

PIC 產品系列

PIC 的產品線寬廣,型號眾多,現有數百種,各主要系列如下:

8-bit(資料寬度)微控制器

使用哈佛結構,指令碼與資料的位元寬度可以不同。但各指令的指令碼長度均相同。

  • Baseline 系列 (12-bit 指令碼)
  • PIC10F : 6 接腳
  • PIC12C5 , PIC12F5 : 8 接腳
  • PIC16C5 , PIC16F5 : 14 以上接腳
  • Midrange (中階) 系列 (14-bit 指令碼)
  • PIC12C6 , PIC12F6 : 8 接腳
  • PIC16 : 14 以上接腳
  • PIC16F1 : 新推出的 Enhanced Midrange (強化中階) 系列
  • PIC18 (8-bit 裡的高階) 系列 (16-bit 指令碼)
  • PIC18 : PIC18C , PIC18Fxxx , 少數早期的 PIC18Fxxxx
  • PIC18 Extended : 目前絕大多數的 PIC18Fxxxx, PIC18FxxJxx, PIC18FxxKxx
  • flash 产品:
  • microchip 收购SST,拥有flash 产品

16-bit(資料寬度)微控制器

相當於不具 DSP 相關功能的 dsPIC 微控制器

  • PIC24 系列
  • PIC24F
  • PIC24H

32-bit(資料寬度)微控制器

  • PIC32 : 採用 MIPS 的 M4K 內核,與其他 PIC 不同。

dsPIC 微控制器(16-bit 資料寬度)

  • dsPIC30F
  • dsPIC33F

8-bit PIC 的指令集

PIC的指令十分精簡,只有35個,簡單易學,故執行速度比8051快。其指令集又分成12-bit PIC instruction set,和14-bit PIC instruction set.

12-bit PIC instruction set
Opcode(二進制)助記體說明
0000 0000 0000NOPNo operation
0000 0000 0010OPTIONLoad OPTION register with contents of W
0000 0000 0011SLEEPGo into standby mode
0000 0000 0100CLRWDTReset watchdog timer
0000 0000 01ffTRIS fMove W to port control register (f=1..3)
0000 001 fffffMOVWF fMove W to f
0000 010 xxxxxCLRWClear W to 0 (a.k.a CLR x,W)
0000 011 fffffCLRF fClear f to 0 (a.k.a. CLR f,F)
0000 10d fffffSUBWF f,dSubtract W from f (d = f − W)
0000 11d fffffDECF f,dDecrement f (d = f − 1)
0001 00d fffffIORWF f,dInclusive OR W with F (d = f OR W)
0001 01d fffffANDWF f,dAND W with F (d = f AND W)
0001 10d fffffXORWF f,dExclusive OR W with F (d = f XOR W)
0001 11d fffffADDWF f,dAdd W with F (d = f + W)
0010 00d fffffMOVF f,dMove F (d = f)
0010 01d fffffCOMF f,dComplement f (d = NOT f)
0010 10d fffffINCF f,dIncrement f (d = f + 1)
0010 11d fffffDECFSZ f,dDecrement f (d = f − 1) and skip if zero
0011 00d fffffRRF f,dRotate right F (rotate right through carry)
0011 01d fffffRLF f,dRotate left F (rotate left through carry)
0011 10d fffffSWAPF f,dSwap 4-bit halves of f (d = f<<4 | f>>4)
0011 11d fffffINCFSZ f,dIncrement f (d = f + 1) and skip if zero
0100 bbb fffffBCF f,bBit clear f (Clear bit b of f)
0101 bbb fffffBSF f,bBit set f (Set bit b of f)
0110 bbb fffffBTFSC f,bBit test f, skip if clear (Test bit b of f)
0111 bbb fffffBTFSS f,bBit test f, skip if set (Test bit b of f)
1000 kkkkkkkkRETLW kSet W to k and return
1001 kkkkkkkkCALL kSave return address, load PC with k
101 kkkkkkkkkGOTO kJump to address k (9 bits!)
1100 kkkkkkkkMOVLW kMove literal to W (W = k)
1101 kkkkkkkkIORLW kInclusive or literal with W (W = k OR W)
1110 kkkkkkkkANDLW kAND literal with W (W = k AND W)
1111 kkkkkkkkXORLW kExclusive or literal with W (W = k XOR W)


14-bit PIC instruction set
Opcode(二進制)助記元說明
00 0000 0000 0000NOPNo operation
00 0000 0000 1000RETURNReturn from subroutine, W unchanged
00 0000 0000 1001RETFIEReturn from interrupt
00 0000 0110 0010OPTIONWrite W to OPTION register
00 0000 0110 0011SLEEPGo into standby mode
00 0000 0110 0100CLRWDTReset watchdog timer
00 0000 0110 01ffTRIS fWrite W to tristate register f
00 0000 1 fffffffMOVWF fMove W to f
00 0001 0 xxxxxxxCLRWClear W to 0 (W = 0)
00 0001 1 fffffffCLRF fClear f to 0 (f = 0)
00 0010 d fffffffSUBWF f,dSubtract W from f (d = f − W)
00 0011 d fffffffDECF f,dDecrement f (d = f − 1)
00 0100 d fffffffIORWF f,dInclusive OR W with F (d = f OR W)
00 0101 d fffffffANDWF f,dAND W with F (d = f AND W)
00 0110 d fffffffXORWF f,dExclusive OR W with F (d = f XOR W)
00 0111 d fffffffADDWF f,dAdd W with F (d = f + W)
00 1000 d fffffffMOVF f,dMove F (d = f)
00 1001 d fffffffCOMF f,dComplement f (d = NOT f)
00 1010 d fffffffINCF f,dIncrement f (d = f + 1)
00 1011 d fffffffDECFSZ f,dDecrement f (d = f − 1) and skip if zero
00 1100 d fffffffRRF f,dRotate right F (rotate right through carry)
00 1101 d fffffffRLF f,dRotate left F (rotate left through carry)
00 1110 d fffffffSWAPF f,dSwap 4-bit halves of f (d = f<<4 | f>>4)
00 1111 d fffffffINCFSZ f,dIncrement f (d = f + 1) and skip if zero
01 00 bbb fffffffBCF f,bBit clear f (Clear bit b of f)
01 01 bbb fffffffBSF f,bBit set f (Set bit b of f)
01 10 bbb fffffffBTFSC f,bBit test f, skip if clear (Test bit b of f)
01 11 bbb fffffffBTFSS f,bBit test f, skip if set (Test bit b of f)
10 0 kkkkkkkkkkkCALL kSave return address, load PC with k
10 1 kkkkkkkkkkkGOTO kJump to address k (11 bits)
11 00xx kkkkkkkkMOVLW kMove literal to W (W = k)
11 01xx kkkkkkkkRETLW kSet W to k and return
11 1000 kkkkkkkkIORLW kInclusive or literal with W (W = k OR W)
11 1001 kkkkkkkkANDLW kAND literal with W (W = k AND W)
11 1010 kkkkkkkkXORLW kExclusive or literal with W (W = k XOR W)
11 110x kkkkkkkkSUBLW kSubtract W from literal (W = k − W)
11 111x kkkkkkkkADDLW kAdd literal to W (W = k + W)

PIC燒錄器

燒錄芯片的方式有兩種:普通燒錄和線上燒錄。

早期的 PIC16C 系列需使用平行燒錄。 程式記憶體為 Flash 的版本使用方便的序列燒錄方式,稱為 ICSP。

開發環境

Microchip 公司提供免費的開發環境 (MPLAB IDE) 與組譯器,也出售付費與提供有條件免費版本的 C 語言編譯器。另有第三方軟體商開發各式 C, BASIC 等編譯器與開發環境可以選用。

MPLAB 的下一代多平台開發環境 MPLAB-X (基於 Java 技術) 目前尚處於 beta 階段。

外部連結

维基共享资源上的相关多媒体资源:PIC微控制器
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.