12.07.2015 Views

16-bit MCU 新增的PPS 功能

16-bit MCU 新增的PPS 功能

16-bit MCU 新增的PPS 功能

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>16</strong>-<strong>bit</strong> <strong>MCU</strong> 新 增 的 PPS功 能© 2005 Microchip Technology Incorporated. All Rights Reserved. Slide 1


Microchip <strong>16</strong>-<strong>bit</strong> <strong>MCU</strong> 的 PPS●●PPS - Peripheral Pin Select− 什 麼 是 PPS ?− PPS 帶 來 的 好 處 與 便 利 性 ?− PPS 如 何 工 作 ?●●實 例 演 練如 何 為 內 建 周 邊 指 定 輸 入 接 腳如 何 為 內 建 周 邊 指 定 輸 出 接 腳© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 2


PIC24F 與 其 他 <strong>16</strong>-<strong>bit</strong> <strong>MCU</strong> 的 比 較INTE EGRA ATIONPIC10, PIC12,PIC<strong>16</strong>: 5 MIPS6 – 64 pins< <strong>16</strong>KB FlashdsPIC ® DSCFamiliesPIC24F<strong>16</strong> MIPS28 –100 pinsPIC18 Up to 128 KB Flash10 MIPS18 – 100 pinsUp to 128KB FlashdsPIC30F30 MIPS18 – 80 pinsUp to 144KB FlashPERFORMANCEdsPIC3340 MIPS18 – 100 pinsUp to 256KB FlashPIC24H40 MIPS18 – 100 pinsUp to 256KB FlashPIC ® <strong>MCU</strong>Families© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 3


PPS - Peripheral Pin Select● What it is…− 讓 使 用 者 可 以 自 行 為 內 建 的 純 數 位 周 邊 指 定輸 出 及 輸 入 接 腳− 達 到 內 建 周 邊 功 能 的 最 佳 化 使 用 方 式− 允 許 接 腳 的 使 用 能 經 由 軟 體 來 重 新 定 義● What it is not …− 並 非 用 來 達 成 接 腳 相 容 性 之 用− Analog 的 周 邊 以 及 特 殊 的 功 能 腳 位 (e.g.,PMP & I 2 C) 仍 然 位 於 固 定 腳 位© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 4


為 何 我 們 需 要 PPS ?假 設 在 實 際 的 應 用 案 例 我 們 須 要 以 下 資 源● Memory− 64K Flash− 8K RAM● Analog− 2chADC− Vref +&-− Comparator x 2● Digital it I/O− 4 I/O●Serial Channels− I 2 C x2− SPI x 2− UART x 2© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 5


為 何 我 們 需 要 PPS 的 實 例我 們 可 以 選 擇 High-Pin Count 的 <strong>MCU</strong> !●●●Application− 64 KB Flash, 8 KB RAM− 2chA/D A/D, Ext. VREF− 2 Comparators− UART x 2, I 2 C, SPI x 2− 4 Digital I/OPin multiplexing blocksfunctions−−UART1 and SPI1Comparator2 and SPI125 spare pins−−Must use even larger pincount deviceOr write SPI in software© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 6


為 何 我 們 需 要 PPS 的 實 例●●●會 選 用 Pin-Count 較 高 的 <strong>MCU</strong> , 通 常 是 因 為接 腳 衝 突 的 關 係 而 不 得 不 選 用 腳 數 較 多 的 來避 免選 擇 High Pin-Count 的 <strong>MCU</strong> 之 缺 點− 占 用 較 大 的 PCB 資 源− Power Consumption− Pi Price $$如 果 …. 選 用 的 <strong>MCU</strong> 有 豐 富 的 內 建 周 邊 而 且接 腳 數 很 小© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 7


周 邊 接 腳 可 自 行 對 應 的 優 點● 解 決 產 品 設 計 上 的 一 般 考 量− 設 計 彈 性− 規 劃 時 的 簡 易 性− 周 邊 安 排 有 衝 突 時 的 優 先 順 序 考 量− 特 定 周 邊 的 限 制 (Analog 腳 位 )− 安 全 與 保 密 性© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 8


Remappable Functions<strong>16</strong>-<strong>bit</strong> <strong>MCU</strong> and dsPIC ® DSC●●●●●●●●All SPI & UART FunctionsTimer & External Interrupt InputsInput Capture & Output ComparesAnalog Comparator outputsPWM Fault Input pinsQuadrature Encoder Interface InputsData Converter InterfaceCAN© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 9


PPS Implementation Details●●●可 被 remap 的 內 建 周 邊 都 可 以 被 指 定 於 任 何 RPpin− 多 個 functions 對 應 至 同 一 pin 是 被 支 援 的Inputs vs. Outputs− 輸 入 的 設 定 方 式 為 指 定 某 一 Pin 腳 給 指 定 的 周 邊− 輸 出 設 定 方 式 為 指 定 某 一 周 邊 功 能 給 指 定 的 Pin 腳Pin 腳 的 安 排 由 軟 體 設 定− 可 選 擇 on-the-fly 的 設 定 或 單 次 的 設 定 方 式●使 用 Configuration Bits 裡 的 IOLOCK 選 項© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 10


周 邊 輸 入 在 做 Remap 時 要 參 考 的暫 存 器 列 表© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 11


Remappable InputsRP0PadLogicPeripheral InputPin Select BitsRP1PadLogicInput to PeripheralRP2PadLogicRPnPadLogic// C Example – Map U1RX// 每 周 邊 有 對 應 的 RPINRx 暫 存 器 , 例 如 UART1 RX 對 應 到 RPINR18 的 <strong>bit</strong> 0 ~ 5// RPINR18 中 的 6 個 位 元 , 用 來 設 定 UART1 RX 要 接 收 哪 一 個 RP 接 腳 的 輸 入 信 號 RP8RPINR18<strong>bit</strong>s.U1RXR = 8;© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 12


Remappable InputsDefine the location of each function used by modifying xxxxR <strong>bit</strong>s in RPINRn registers© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 13


Remappable Outputs© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 14


Remappable OutputsPeripheral OutputSelect BitsPeripheral 1 OutputPeripheral 2 OutputPeripheral 3 OutputPadLogicRP0Peripheral N Output// C Example – Map U1TX to RP1// 每 個 RP Pin 有 對 應 的 RPORx 暫 存 器 , 例 如 RP1 有 RPOR0// RPOR0 中 有 5 個 <strong>bit</strong> ( Bit-8 ~ Bit-12 ) 用 來 指 定 要 由 RP1 輸 出 的 周 邊// UART1 TX 的 編 號 為 3 號RPOR0<strong>bit</strong>s.RP1R = 3© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 15


Remappable OutputsDefine the output functionality on each pin by modifying RPnR <strong>bit</strong>s in RPORn registers© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide <strong>16</strong>


使 用 MPLAB C30 內 建 的Peripherals Library 來 設 定© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 18


PPS 設 定 輸 出 的 函 數●●說 明 檔 的 位 置−C:\Program Files\Microchip\MPLAB C30\docsiPPSOutput(pin,fn)− 將 選 定 的 輸 出 腳 指 定 給 某 一 Function− Pin =●OUT_PIN_PPS_RP0 .. OUT_PIN_PPS_RP31− fn = PPS.h 定 義 的 眾 多 Function● e.g. OUT_ FN_ PPS_OC1OUT_FN_PPS_U1TX© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 19


PPS 設 定 輸 入 的 函 數●●說 明 檔 的 位 置−C:\Program Files\Microchip\MPLAB C30\docsiPPSInput(fn,pin)− 將 某 一 Function 的 輸 入 指 定 給 某 一 接 腳− fn = PPS.h 定 義 的 眾 多 Function● e.g. IN_FN_PPS_IC1IN_FN_PPS_U1RX− Pin =●●IN_PIN_PPS_RP0 .. IN_PIN_PPS_RP31IN_ PIN_ PPS_ RPI32 .. IN_ PIN_ PPS_RPI45© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 20


使 用 MPLAB C30 PeripheralLibrary 設 定 PPS 範 例#define USE_AND_OR /* To enable AND_OR mask setting */#includevoid PPS_init(void){ /* Configure Peripheral pin for UART1*/}iPPSInput(IN_FN_PPS_U1RX,IN_PIN_PPS_RP10);iPPSInput(IN_FN_PPS_U1CTS,IN_PIN_PPS_RPI32);iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U1TX);iPPSOutput(OUT_PIN_PPS_RP31,OUT_FN_PPS_U1RTS);// 設 定 UART1 的 TX 與 RTS 分 別 輸 出 至 RP17 & RP31// 設 定 UART1 的 RX 與 CTS 分 別 由 RP10 及 RPI 輸 入 信 號// RPIx : 只 能 remap INPUT 的 功 能 接 腳© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 21


PPS Register Protection●●●HW integrity it checking− Bit flip will cause device reset●任 何 位 元 的 非 預 期 改 變 都 會 造 成 RESETI/O lock feature− RPINRn/RPORn can only be written to whileOSCCON[IOLOCK] = 0; once the IOLOCK isset, the registers cannot be writtenIOLOCK Protection− The state of the IOLOCK <strong>bit</strong> can only bechanged with an unlocking sequence− Protection selectable by configuration <strong>bit</strong>© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 22


Pin Function Priority● 如 果 功 能 重 疊 時 的 優 先 順 序 :1. Analog FunctionsANx, Vref+/-2. PPS Outputs3. PPS Inputs4. Fixed DigitalPeripheral Outputs5. Fixed DigitalPeripheral InputsUART TX, SDO, OCUART RX, SDI, ICI2C, PMPI2C, PMP© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 23


Initializing a PPS Application1. Design Decision: Static or Dynamic RPnassignment?• Set IOL1WAY config <strong>bit</strong> accordingly gy2. Initialize the pin out by mapping theRPn pins to the desired peripheralinput/output functions• Map RPn pin(s)Peripheral Input Function(s)• Map Peripheral Output Function(s)RPnpin(s)• Lock the RPn SFRs using ‘lock’ sequence3. Configure Peripherals4. Enable Interrupts (if required)© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 24


Cool Byproducts●Increase drive strength by outputting sameperipheral on multiple pinsPeripheral Outpute.g. OC1PadLogicRP1PadLogicRP2PadLogicRP3© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 25


Cool Byproducts●Connect one signal to multiple peripheralinputsRP0PadInput to Peripheral #1Logice.g. U1CTSInput to Peripheral #2e.g. INT1© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 26


Cool Byproducts●Connect peripheral output to anotherinput (Loopback) for debugginggRP0PadLogicInput to Peripherale.g. SDIOutput to Peripherale.g. SDO© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 27


原 先 須 使 用 64-pin <strong>MCU</strong> 的 應 用 現 在因 為 利 用 PPS 所 以 只 需 44-pin <strong>MCU</strong>● 應 用 需 求−64 6 KB Flash, 8KB RAM−2 ch A/D, Ext. VREF−2 Comparators−UART x 2, I 2 C, SPI x 2−4 Digital I/O● 使 用 只 有 44-Pin 的PIC24FJXXGA004● 還 可 以 有 3 Spare PinsSmaller packages, simplified design and lower cost!© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 28


Application Example #2● Communicating with multipleUART Devices● Standard Options:UARTDevice #1UARTDevice #1U1TXU1RXU3TXU3RXUARTDevice #3U1TXU1RXUARTDevice #2Really BigMicroMicroUARTDevice #2U2TXU2RXU4TXU4RXUARTDevice #4UARTDevice #3使 用 有 PPS 功 能 並 內 建 多 個UART 的 PIC24FJ 系 列使 用 傳 統 <strong>MCU</strong> 並 搭 配 多 工 器 完成 多 UART 的 應 用UARTDevice #4© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 29


Application Example #2●●Communicating with multiple UARTDevicesDynamic Peripheral Remapping:U1TXU1TXUARTDevice #1 U1RXU1RXUARTDevice #3PIC24FJ64GA004UARTDevice #2U1TXU1RXU1TXU1RXUARTDevice #4© 2008 Microchip Technology Incorporated. All Rights Reserved. C30 入 門 及 應 用 Slide 30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!