可程式計數陣列 (PCA) 功能使用方法. 可程式計數陣列功能使用方法 Application Note 1 適用產品 :SM59D04G2,SM59D03G2

Similar documents
國立交通大學 電子研究所 碩士論文 多電荷幫浦系統及可切換級數負電壓產生器之設計及生醫晶片應用

MULTILAYER HIGH CURRENT/HIGH FREQUENCY FERRITE CHIP BEAD

Rev. No. History Issue Date Remark 0.1 Initial issue Mar 24, 2008 Preliminary

Multimeter 3 1/2經濟款數位電錶 MT User s Manual 2nd Edition, Copyright by Prokit s Industries Co., Ltd.

Unit 6: Movies. Film Genre ( 可加 film 或 movie) Adjectives. Vocabulary. animation. action. drama. comedy. crime. romance. horror

ORDER FORM 3A - Booth Packages Rental 訂購表格 3A - 攤位裝修設計租用

SECTION 機械標示 MECHANICAL IDENTIFICATION

#5802 使用者研究 Design and Research on User Experience

凱思隆科技股份有限公司 公司與產品簡介. KeithLink Technology Co., Ltd. TEL: FAX:

課程名稱 : 電子學 (2) 授課教師 : 楊武智 期 :96 學年度第 2 學期

NT-8540 / NT-8560 / NT-8580 Laser Distance Measurer

OEM Installation Guidance Document For BRCM WLAN + Bluetooth Module, BCM94313HMGB FCC ID: QDS-BRCM1051; IC: 4324A-BRCM1051

第壹部分 : 選擇題 (60 分 ) 一 綜合測驗 ( 第 1-15 題, 每題 2 分, 共 30 分 )

書報討論報告 應用雙感測觸覺感測器於手術系統 之接觸力感測

Low Cost PC Power/Clone PC market Replace Passive PFC with Active PFC Single Range (230Vac only) Power (70% market)

Using the Keyboard (VGP-WKB11)

工程圖學 (1) Engineering Drawing (I)

电池柜 B32 Battery Cabinet B32. 安装说明 Installation Instruction

24GHz BSD Radar. 24 GHz Radar Blind Spot Detection. Installation Guide

Signal Integrity for PCB Design

震波醫療機之設計與開發 Design and Development of Shock Wave Therapy

30 個創意思考技巧. Checklists Brainstorming Forced Relationships/Analogy Attribute Listing Morphological Analysis Imitation Mindmapping

SPECIFICATION FOR APPROVAL

行政院國家科學委員會專題研究計畫成果報告

User s Manual. Wi-Fi Smart Plug HS100 Wi-Fi Smart Plug with Energy Monitoring HS REV 2.0.0

電機驅動方案產品介紹 廣閎科技 2016 May. 25 inergy 大比特研讨会资料区 :

to possess 2. Description of type or types of irradiating apparatus for which licence is required : dental X-ray machine

User Manual bgn WLAN MODULE MODEL DWM-W042

Virtual Reality 虛擬實境

計畫編號 : NSC E 執行時程 : 93 年 8 月 1 日至 94 年 7 月 31 日 計畫主持人 : 連豊力 國立台灣大學電機系助理教授 共同主持人 : 呂良鴻 國立台灣大學電子所助理教授 計畫參與人員 : 許瑋豪 方文杰 林雍倫 馮天俊 魏嘉樑 麥肇元

微奈米光電製程 管傑雄 國立台灣大學電機系

Wireless Communications

高速數位電路與無線通訊系統之電磁相容技術發展與應用

Publication Lists (2001~2005) 1. Journal Papers:

RTL8188CE b/g/n RTL8188CE minicard User s Manual. Rev Dec Realtek Semiconductor Corp.

MARQUE : REFERENCE : CODIC :

Bluetooth Module : MB8811C1 SPECIFICATION. Tx Power Rx Sensitivity < -70dBm (BER 0.1%)

Development Status and Future Trend of MIMO OTA Test

DBUB-P705 Bluetooth Adapter User s Manual

Musical Genre Classification

FPGA-based Stepping Motor Drive System Design

行政院國家科學委員會專題研究計畫成果報告

igs01 Specification BLE( Bluetooth Smart) to WiFi Gateway Features Applications Block Diagram Specification Ver.1b

英文考科 大學入學考試中心 100 學年度指定科目考試試題 - 作答注意事項 - 祝考試順利 考試時間 :80 分鐘 作答方式 : 選擇題用 2B 鉛筆在 答案卡 上作答, 修正時應以橡皮擦拭, 切勿使用修正液 ( 帶 )

Model RM Wireless Link Module External Interface Specification

BA 商品多樣化 商品多樣性的介紹 可以和感應器和指示燈等各種元件連接的端子台模組 有 點型 ( 輸入 ) 點型 ( 輸入 輸出 ) 0 點型 ( 輸入 輸出 ) 等種類 可以不經由繼電器轉接而可以和空氣閥和電磁閥等直接連接的 00mA 開關型式 配備可簡單進行動作確認的 LED 指示燈 DIN 軌

Created by Po fortunecookiemom.com

Statistical Tools for Digital Forensics. Information Technologies for IPR Protection

Journal of Commercial Modernization, 6(2), 作者 /Author: 張瑞當 (Ruey-Dang Chang); 曾玉琦 (Yee-Chy Tseng); 廖浩雲 (Hao-Yun Liao)

Paint Your Home in Wi-Fi. User Guide. AC1300 Whole-Home Wi-Fi System Deco M REV1.1.0

Paint Your Home in Wi-Fi. User Guide. AC1300 Whole-Home Wi-Fi System Deco M REV1.1.0

大學入學考試中心 106 學年度指定科目考試試題 英文考科 - 作答注意事項 - 非選擇題用筆尖較粗之黑色墨水的筆在 答案卷 上作答 ; 更正時, 可以使用修正液 ( 帶 )

國立交通大學 電信工程學系 碩士論文 連續時間轉導電容式三角積分調變器之實現. Implementation of the continuous-time transconductor-capacitor Delta-Sigma modulator 研究生 : 吳國璽 指導教授 : 洪崇智博士

國立交通大學 資訊科學與工程研究所碩士論文 多天線傳送系統干擾抑制及路徑衰減補償之可適性封包檢測. Adaptive Packet Acquisition with Interference and Time-Variant Path Loss in MIMO-OFDM Systems

PART III: BOOTH CONSTRUCTION FORMS 第三部分..攤位裝修表格

FIG.D FIG.C FIG.E 2 FIG.F 13 FIG.G

行政院國家科學委員會補助專題研究計畫 成果報告 期中進度報告 六子棋與 K 子棋之研究

VISUAL ARTS ADVANCED LEVEL. 1.1 To examine candidates general creative ability.

GENERAL RULES & REGULATIONS FOR THE 23 rd DA DUN FINE ARTS EXHIBITION OF TAICHUNG CITY

NX70 Installation Instructions High Performance Pulse Output Counter Module

HSPICE. Speaker Jh-He Lin

一個可以創造奇蹟的行業 儒鴻企業股份有限公司 成衣事業部陳總經理坤鎕

VISUAL ARTS ADVANCED LEVEL. 1.1 To examine candidates general creative ability.

Paint Your Home in Wi-Fi. User Guide. AC1300 Whole-Home Wi-Fi System Deco M REV1.1.0

聽力內容與圖片不符, 因此選 (B) 例題 Amy: Who s that man? Mike: 答案是 (C) (A) He s a cook. (B) Yes, he s my classmate. (C) He s our coach.

Design of A Fast Lock-in All-Digital Phase-Locked Loop in 40-nm CMOS Technology

CHAPTER 5 HELICAL ANTENNAS 螺旋天線. C. A. Balanis, Antenna Theory, Ch. 10 W. Stutzman, Antenna Theory, Ch. 6, P 231 J. D. Kraus, Antennas, Ch.

Raspberry Pi projects. Make a switch Control volume Measuring temperature Measuring light Output PWM Blink LEDs Remote- control car Installing VNC

WML- 43 User Manual. Content. 1. General. Page 1 of 6 WML-C43_User_Manual Jun

Chapter 11 Satellite Systems

RTL8723DE. PCI-Express NGFF1630-S2-E User s Manual. RTL8723DE User s Manual. Realtek Semiconductor Corp.

射頻微波通訊電路設計 RF/Microwave Communication Circuits Design

User guide Air USB. For other languages visit:

國立交通大學 工業工程與管理學系 博士論文 利用電腦輔助設計資料防止錯打線的視覺偵測系統之設計與開發

國立交通大學 電信工程研究所 博士論文 新穎交錯耦合濾波器之開發設計與寬頻高階馬迅平衡非平衡轉換器合成設計

User Guide. AC1300 Whole Home Wi-Fi System Deco M5 Router

ACT353 5V 450mA~650mA

Design of an Op-Amp Gain Compensator for Switched-Capacitor Integrators

Installation Manual WIND TRANSDUCER

Brazil. Canada. European Union (EU) Japan. PRSE User Manual - Certifications

Radio Frequency Data For Class B

數位示波器原理準確量測與除錯技巧. 浩網科技股份有限公司應用工程暨高速數位測試中心 - 處長賴德謙 (Ted Lai ) 2014 INFINET TECHNOLOGY

Power Challenges for IoT devices

RHT03-SPI Temperature & Humidity Sensor

An Integrated Voltage-Mode Boost DC-DC Converter for Portable Electronic Systems

Large Signal Behavior of Micro-speakers. by Wolfgang Klippel, KLIPPEL GmbH ISEAT 2013

Class-AB Rail-to-Rail CMOS Buffer Amplifier for TFT-LCD Source Drivers 應用於薄膜電晶體液晶顯示器資料驅動電路的 AB 類軌對軌互補式金屬氧化物半導體場效電晶體緩衝放大器

國立交通大學 電子工程學系電子研究所 碩士論文. An Effective Heart Rate Variability Processor Design for. Portable 3-Lead ECG Monitoring System-on-Chip 研究生 : 曾少彥

3-Channel Constant Current LED Driver UCS1903

SPECIFICATION FOR APPROVAL

第壹部分 : 選擇題 (60 分 ) 一 綜合測驗 ( 第 1-15 題, 每題 2 分, 共 30 分 )

R-GAGE Q240RA-IL (-UL) Sensor

ApeosPort-V C7780/C6680/C5580

SPECIFICATION FOR APPROVAL

D. Appropriate labels must be affixed to the CUSTOMER Product that comply with applicable regulations in all respects.

teachers guide

3GPP 標準推廣說明會 Spectrum Sharing Aspects in 3GPP

Leading Provider of Industrial Networking Solutions

國立交通大學 碩士論文 90 奈米互補式金氧半製程下 之多功能輸入 / 輸出元件庫設計. Design of Configurable I/O Cell Library in 90-nm CMOS Process

Transcription:

可程式計數陣列 (PCA) 功能使用方法 1 適用產品 :SM59D04G2,SM59D03G2 2 應用說明 : PCA 共有五組, 每組皆可工作於以下七種模式 : 捕獲模式 - 正緣捕獲模式 (Positive edge capture mode) 捕獲模式 - 負緣捕獲模式 (Negative edge capture mode) 捕獲模式 - 正緣及負緣捕獲模式 (Both positive and negative edge capture mode) 計時模式 (Timer mode) 高速時脈輸出模式 (High Speed Output mode) 8 位元脈寬調變模式 (8-bit PWM mode) 16 位元脈寬調變模式 (16-bit PWM mode) 3 PCA Compare/Capture mode 應用說明 3.1 捕獲模式 - 正緣捕獲模式 (Positive edge capture mode): Capture mode 致能時,PCA 16-bit counter 計數暫存器 (CCCH, CCCL) 會不斷的上數, 當 CC0~CC4 pin 輸入外部訊號, 低電位轉換成高電位的訊號將做為捕獲條件, 捕獲時產生中斷, 並且由硬體將 PCA counter 存至捕獲資料暫存器 CCnD[15:0](CCnDH, CCnDL) 圖 : PCA capture mode with positive edge IRFWX-A123 1 Ver. A 2009/03

3.2 捕獲模式 - 負緣捕獲模式 (Negative edge capture mode): 可程式計數陣列功能使用方法 Capture mode 致能時,PCA 16-bit counter 計數暫存器 (CCCH, CCCL) 會不斷的上數, 當 CC0~CC4 pin 輸入外部訊號, 高電位轉換成低電位的訊號將做為捕獲條件, 捕獲時產生中斷, 並且由硬體將 PCA counter 存至捕獲資料暫存器 CCnD[15:0](CCnDH, CCnDL) 圖 : PCA capture mode with negative edge 3.3 捕獲模式 - 正緣及負緣捕獲模式 (Both positive and negative edge capture mode) Capture mode 致能時,PCA 16-bit counter 計數暫存器 (CCCH, CCCL) 會不斷的上數, 當 CC0~CC4 pin 輸入外部訊號, 高電位轉換成低電位, 或由低電位轉換成高電位的訊號將做為捕獲條件, 捕獲時產生中斷, 並且由硬體將 PCA counter 存至捕獲資料暫存器 CCnD[15:0](CCnDH, CCnDL) 圖 : PCA capture mode with both negative and positive edge IRFWX-A123 2 Ver. A 2009/03

3.4 計時模式 (Timer mode) 當該模式致能,PCA 16-bit counter 計數暫存器 (CCCH, CCCL) 會上數, 直到 PCA counter 溢位時, 則會產生中斷. 圖 : PCA Timer mode 3.5 高速時脈輸出模式 (High Speed Output mode) 當高速時脈輸出模式 ( 比較模式 ) 致能, 每當 PCA 16-bit counter 計數暫存器 (CCCH, CCCL) 和資料暫存器 CCnD[15:0] 相同時,CCn pin 則會做反相訊號輸出 圖 : PCA high speed output IRFWX-A123 3 Ver. A 2009/03

3.6 8-bit 脈寬調變模式 (8-bit PWM mode) 3.6.1 8 位元 PWM 僅使用資料暫存器 CCnDL[7:0], 未使用 CCnDH[15:8] 3.6.2 8 位元 PWM 訊號輸出頻率由 bit PCAC2^CCCLK 設定 : CCCLK 6T 12T 00 Fosc/256 (Fosc/2)/256 01 (Fosc/4)/256 (Fosc/8)/256 10 (Fosc/12)/256 (Fosc/24)/256 11 (CCCI pin frequency )/256 (CCCI pin frequency )/256 3.6.3 當使用 8 位元 PCA 之 PWM 功能時需注意如下 : 當 CCnDL=0x00 或 0xFF 時 CCn pin 輸出皆為 low; 當 CCnDL=0x01 時 CCn pin 輸出 low pulse 為 2 個 PWM Input clock; 當 CCnDL=0x02 時 CCn pin 輸出 low pulse 為 3 個 PWM Input clock; 當 CCnDL=0xFE 時 CCn pin 輸出 high pulse 為 1 個 PWM Input clock IRFWX-A123 4 Ver. A 2009/03

3.7 16-bit 脈寬調變模式 (16-bit PWM mode) 3.7.1 16 位元 PWM 使用資料暫存器 CCnDL[7:0] 和 CCnDH[15:8] 3.7.2 16 位元 PWM 訊號輸出頻率由 bit PCAC2^CCCLK 設定 : CCCLK 6T 12T 00 Fosc/65536 (Fosc/2)/65536 01 (Fosc/4)/65536 (Fosc/8)/65536 10 (Fosc/12)/65536 (Fosc/24)/65536 11 (CCCI pin frequency )/65536 (CCCI pin frequency )/65536 3.7.3 當使用 PCA 之 PWM 功能時需注意如下 : 當 CCnD = 0x0000 或 0xFFFF 時 CCn pin 輸出皆為 low; 當 CCnD = 0x0001 時 CCn pin 輸出 low pulse 為 2 個 PWM Input clock; 當 CCnD = 0x0002 時 CCn pin 輸出 low pulse 為 3 個 PWM Input clock; 當 CCnD =0xFFFE 時 CCn pin 輸出 high pulse 為 1 個 PWM Input clock 4 Pin Description 40L PDI P Pin # 44L QFP Pin # 44L PLC C Pin # Symbol I/O Names 3 42 4 P12/CCCI/EEI2 Bit 2 of port 1 & PCA External clock input & EEI i/o /ICP_DATA interrupt 2 & ICP data/command IO 4 43 5 P13/CC0/EEI3 i/o Bit 3 of port 1 & PCA Channel 0 & EEI interrupt 3 5 44 6 P14/CC1/EEI4 i/o Bit 4 of port 1 & PCA Channel 1 & EEI interrupt 4 6 1 7 P15/CC2/EEI5 i/o Bit 5 of port 1 & PCA Channel 2 & EEI interrupt 5 7 2 8 P16/CC3/EEI6 i/o Bit 6 of port 1 & PCA Channel 3 & EEI interrupt 6 8 3 9 P17/CC4/EEI7 i/o Bit 7 of port 1 & PCA Channel 4 & EEI interrupt 7 IRFWX-A123 5 Ver. A 2009/03

5 特殊功能暫存器說明 : Mnemonic Description Direct Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 RESET PCA PCAC1 PCA control register 1 A1h CCR CIDL - CC4IE CC3IE CC2IE CC1IE CC0IE PCAC2 PCA control register 2 A2h CCCLK[1:0] - CC4IF CC3IF CC2IF CC1IF CC0IF PCAH PCA counter high 9Ah PCA[15:8] PCAL PCA counter low 9Bh PCA[7:0] CC0CON CC0 control register A3h - - - TOG0 - CC0MOD[2:0] CC0DH CC0 data high 9Ch CC0D[15:8] CC0DL CC0 data low 9Dh CC0D[7:0] CC1CON CC1 control register A4h - - - TOG1 - CC1MOD[2:0] CC1DH CC1 data high 9Eh CC1D[15:8] CC1DL CC1 data low 9Fh CC1D[7:0] CC2CON CC2 control register A5h - - - TOG2 - CC2MOD[2:0] CC2DH CC2 data high 91h CC2D[15:8] CC2DL CC2 data low 92h CC2D[7:0] CC3CON CC3 control register A6h - - - TOG3 - CC3MOD[2:0] CC3DH CC3 data high 93h CC3D[15:8] CC3DL CC3 data low 94h CC3D[7:0] CC4CON CC4 control register A7h - - - TOG4 - CC4MOD[2:0] CC4DH CC4 data high 95h CC4D[15:8] CC4DL CC4 data low 96h CC4D[7:0] IRFWX-A123 6 Ver. A 2009/03

5.1 PCA 控制暫存器 1(Control register 1) Bit 7 Bit 0 CCR CIDL - CC4IE CC3IE CC2IE CC1IE CC0IE Read/Write - Reset Value 0 0 0 0 0 0 0 0 CCR: PCA Counter Run control bit: CCR =1, 啓動 PCA 計數, 由軟體設定 CCR =0, 停止 PCA 計數, 由軟體設定 CIDL: Counter Idle control: CIDL =1, 進入閒置模式, 但必須要 PCON[0] 同時也被致能為 1 CIDL =0, 離開閒置模式 CCnIE: CC0 ~ CC4 interrupt enable. CCnIE = 1, 中斷致能 CCnIE = 0, 中斷禁能 5.2 PCA 控制暫存器 2(Control register 2) Mnemonic: PCAC2 Address: A2h CCCLK[1:0] - CC4IF CC3IF CC2IF CC1IF CC0IF - CCCLK[1:0] 比較捕獲時脈來源選擇 (Compare/Capture clock source select) CC0CLK[1:0] Clock source 00 Fosc 01 Fosc/4 10 Fosc/12 11 External clock input (CCCI pin) CCCLK 會和 6T 或 12T 有關, 詳細請參考表一 圖一及圖二說明. 相關名詞定義如下 : System clock frequency(f SYS ) = crystal(f CRY ) or oscillator(f OSC ) frequency in 6T, and System clock frequency(f SYS )= crystal(f CRY ) or oscillator(f OSC ) frequency divided by 2 in 12T CCnIF CC0 ~ CC4 中斷旗標 (CC0 ~ CC4 interrupt flag) 當發生中斷時由硬體設置為 1, 必須由軟體清除. IRFWX-A123 7 Ver. A 2009/03

表一 : 計算取樣週期, 以使用 Crystal 16MHz 為範例 Machine Fcry CCCLK[1:0] PCA counter increment Div Sample period(us) cycle (MHz) 6T 16 00 1 system clocks 1 0.0625 6T 16 01 2 system clocks 4 0.25 6T 16 10 12 system clocks 12 0.75 12T 16 00 1 system clocks 2 0.125 12T 16 01 2 system clocks 8 0.5 12T 16 10 12 system clocks 24 1.5 External clock input External clock input 6T/12T 16 11 / (CCCI pin) (CCCI pin) 註 :CCCLK[1:0]=11 時, 取樣週期會依照外部的訊號輸入而定 ; 其它模式取樣週期 (Sample period) = 1 / (Fcry / Div) 圖. PCA clock selection at 6T mode 圖二. PCA clock selection at 12T mode IRFWX-A123 8 Ver. A 2009/03

5.3 PCA 計數暫存器 1(Counter register 1) Mnemonic: PCAH Address: 9Ah PCA[15:8] Mnemonic: PCAL Address: 9Bh PCA[7:0] 5.4 CC0CON (Compare/Capture channel 0 control register) Mnemonic: CC0CON Address: A3h - - - TOG0 - CC0MOD[2:0] - - - - CC0MOD[2:0] 比較 / 捕獲通道 0 模式選擇 (Compare/Capture channel 0 modes select) CC0MOD[2:0] Function 000 Disable PCA channel 0 001 Positive edge capture mode 010 Negative edge capture mode 011 Both positive and negative edge capture mode 100 Timer mode 101 High Speed Output mode 110 8-bit PWM 111 16-bit PWM TOG0: CC0 toggle register. 5.5 CC0 Data register Mnemonic: CC0DH Address: 9Ch CC0D[15:8] Mnemonic: CC0DL Address: 9Dh CC0D[7:0] IRFWX-A123 9 Ver. A 2009/03

5.6 CC1CON (Compare/Capture channel 1 control register) Mnemonic: CC1CON Address: A4h - - - TOG1 - CC1MOD[2:0] - - - - CC1MOD[2:0] 比較 / 捕獲通道 1 模式選擇 (Compare/Capture channel 1 modes select) CC1MOD[2:0] Function 000 Disable PCA channel 1 001 Positive edge capture mode 010 Negative edge capture mode 011 Both positive and negative edge capture mode 100 Timer mode 101 High Speed Output mode 110 8-bit PWM 111 16-bit PWM TOG1: CC1 toggle register. 5.7 CC1 Data register Mnemonic: CC1DH Address: 9Eh CC1D[15:8] Mnemonic: CC1DL Address: 9Fh CC1D[7:0] 5.8 CC2CON (Compare/Capture channel 2 control register) Mnemonic: CC2CON Address: A5h - - - TOG2 - CC2MOD[2:0] - - - - CC2MOD[2:0] 比較 / 捕獲通道 2 模式選擇 (Compare/Capture channel 2 modes select) IRFWX-A123 10 Ver. A 2009/03

CC2MOD[2:0] Function 000 Disable PCA channel 2 001 Positive edge capture mode 010 Negative edge capture mode 011 Both positive and negative edge capture mode 100 Timer mode 101 High Speed Output mode 110 8-bit PWM 111 16-bit PWM TOG2: CC2 toggle register. 5.9 CC2 Data register Mnemonic: CC2DH Address: 91h CC2D[15:8] Mnemonic: CC2DL Address: 92h CC2D[7:0] 5.10 CC3CON (Compare/Capture channel 3 control register) Mnemonic: CC3CON Address: A6h 7 6 5 4 3 2 1 0 Res et - - - TOG3 - CC3MOD[2:0] - - - - CC3MOD[2:0] 比較 / 捕獲通道 3 模式選擇 (Compare/Capture channel 3 modes select) CC3MOD[2:0] Function 000 Disable PCA channel 3 001 Positive edge capture mode 010 Negative edge capture mode 011 Both positive and negative edge capture mode 100 Timer mode 101 High Speed Output mode 110 8-bit PWM IRFWX-A123 11 Ver. A 2009/03

111 16-bit PWM TOG3: CC3 toggle register. 5.11 CC3 Data register Mnemonic: CC3DH Address: 93h CC3D[15:8] Mnemonic: CC3DL Address: 94h CC3D[7:0] 5.12 CC4CON (Compare/Capture channel 4 control register) Mnemonic: CC4CON Address: A7h - - - TOG4 - CC4MOD[2:0] - - - - CC4MOD[2:0] 比較 / 捕獲通道 4 模式選擇 (Compare/Capture channel 4 modes select) CC4MOD[2:0] Function 000 Disable PCA channel 4 001 Positive edge capture mode 010 Negative edge capture mode 011 Both positive and negative edge capture mode 100 Timer mode 101 High Speed Output mode 110 8-bit PWM 111 16-bit PWM TOG4: CC4 toggle register. IRFWX-A123 12 Ver. A 2009/03

5.13 CC4 Data register Mnemonic: CC4DH Address: 95h CC4D[15:8] Mnemonic: CC4DL Address: 96h CC4D[7:0] IRFWX-A123 13 Ver. A 2009/03

6 中斷 (Interrupt) 6.1 中斷向量表 (Interrupt Vector Table): Interrupt Source Interrupt Vector Polling sequence External interrupt 0 0003h Timer 0 000Bh External interrupt 1 0013h Timer 1 001Bh Serial Port 0023h Timer 2 002Bh EEI 0033h PCA interrupt 003Bh 6.2 使用 Keil C 的中斷設定範例程序 : Polling sequence unsigned char CPH,CPL; void init(void) IE = 0x80; IE1= 0x02; // PCAC1[7]=>PCA counter run bit // PCAC1[4]~PCAC1[0] =enable all of CC4 ~ CC0 interrupt PCAC1 = 0x9f; // Clock source = Fosc (note:12t=fosc/2,6t=fosc) PCAC2 = 0x00; void PCA_Capture(void) interrupt 7 //vector 003Bh //user code=================== PCAL = 0x00; PCAH = 0x00; CPH=CC0DH; CPL=CC0DL; //============================ PCAC2 = PCAC2&0xC0; //clear all flag IRFWX-A123 14 Ver. A 2009/03

7 PCA 範例程式及說明 : 7.1 PCA Capture mode 應用的範例程式 : Device:SM59D04G2C25 function generator: f=2khz,t=500us Description Example: P1.3 Negative edge capture mode Crystal: 24MHz/12T, Clock source = Fosc/2, t= 0.0833333us, CC0D= 1743h T*CC0D = 496.25us Crystal: 24MHz/12T, Clock source = Fosc/8, t= 0.3333333us, CC0D= 05DFh T*CC0D = 500.9us Crystal: 24MHz/12T, Clock source = Fosc/24, t= 1us, CC0D= 01EEh T*CC0D = 496us Main program //==================================================================== // // S Y N C M O S T E C H N O L O G Y // //==================================================================== #include "sfr.h" //#include <reg51.h> unsigned int j = 0; unsigned char CPH,CPL; void init(void) P0 = 0xff; P1 = 0xff; P2 = 0xff; P3 = 0xff; //EA = 1; IE = 0x80; IE1= 0x02; // PCAC1[7]=>PCA counter run bit // PCAC1[4]~PCAC1[0] =enable all of CC4 ~ CC0 interrupt PCAC1 = 0x9f; //Clock source = Fosc (note:12t=fosc/2,6t=fosc) //PCAC2 = 0x00; //Clock source = Fosc/4 (note:12t=fosc/8,6t=fosc/4) //PCAC2 = 0x40; //Clock source = Fosc/12 (note:12t=fosc/24,6t=fosc/12) PCAC2 = 0x80; //Clock source = External clockc (note:ccci pin) //PCAC2 = 0xc0; PCAL = 0x00; PCAH = 0x00; IRFWX-A123 15 Ver. A 2009/03

// Select_channel_mode Set // CCnCON.2 CCnCON.1 CCnC0N.0 Capture mode // 0 0 1 postive edge // 0 1 0 Negative edge // 0 1 1 postive&negative edge // 1 0 0 Timer mode void Select_channel_mode(void) CC0CON = 0x02; //P1.3 Negative edge capture mode CC1CON = 0x02; //P1.4 Negative edge capture mode CC2CON = 0x01; //P1.5 Postive edge capture mode CC3CON = 0x03; //P1.6 Postive & Negative capture mode CC4CON = 0x03; //P1.7 Postive & Negative capture mode void PCA_Capture(void) interrupt 7 //vector 003Bh // PCA Capture interrupt PCAL = 0x00; PCAH = 0x00; CPH=CC0DH; CPL=CC0DL; PCAC2 = PCAC2&0xC0; void main(void) unsigned int i=0, ii=0; init(); Select_channel_mode(); P3 = 0xFF; while(1) for(i=0;i<1000; i++) for(ii=0;ii<200; ii++) P0 =CPH; P2 =CPL; IRFWX-A123 16 Ver. A 2009/03

7.2 PCA Timer mode 應用的範例程式 : Description Device:SM59D04G2C25 Crystal:24MHz/12T Clock source= Fosc/4 6T:T =1 / Clock source = 4/24MHz =0.1666666us 12T:T =2(1 / Clock source) =2*4/24MHz = 0.33333us PCA = 65536-300(decimal) =10000-12C = 0xFED4 300T = 100us, will detect P3 toggles about 100us Main program //==================================================================== // // S Y N C M O S T E C H N O L O G Y // //==================================================================== #include "sfr.h" // enable interrupt and select clock source void Initial() IE=0x80; //enable all interrupt IE1=0x02; //enable PCA interrupt //PCAC1: CCR CIDL - CC4IE CC3IE CC2IE CC1IE CC0IE //PCAC1=0x9f; PCAC1=0x81; //PCAC2.7,PCAC2.6 Clock source // 0 0 Fosc // 0 1 Fosc/4 // 1 0 Fosc/12 // 1 1 External clock input(ccci pin,p1.2) PCAC2=0x40; //clock source from Fosc/4 PCAL =0xD4; //software reload value PCAH =0xFE; //software reload value // select_channel 0 ~ 4 void select_channel(void) CC0CON=0x04; //channel"0" timer mode CC1CON=0; //channel"1" timer mode disable CC2CON=0; //channel"2" timer mode disable CC3CON=0; //channel"3" timer mode disable CC4CON=0; //channel"4" timer mode disable void PCA_Timer(void) interrupt 7 using 0//vector 003Bh //if (PCAC2&0x01) // //65536-300(decimal) =10000-12C = 0xFED4 IRFWX-A123 17 Ver. A 2009/03

// PCAL =0xD4; PCAH =0xFE; //software reload value //software reload value P3 = ~P3; //12T@24MHz P3 toggle per 100us PCAC2 &= 0x40; //software clear all flag 可程式計數陣列功能使用方法 void main(void) select_channel(); Initial(); while(1) 7.3 PCA High speed output mode 應用的範例程式 : Description High speed pulse width Device:SM59D04G2C25 Crystal:24MHz/12T Clock source = Fosc/12 6T: T =1 /source clock = 1/(Fosc/12) = 12/24MHz =0.5us 12T: T =2(1 /source clock) = 2/(Fosc/12) =2*12/24MHz =1us 100T =100us, detect pin CC0(P1.3) toggles about 100us. Main program //==================================================================== // // S Y N C M O S T E C H N O L O G Y // //==================================================================== //******************************************************************** // high speed pulse width // Device:SM59D04G2C25 Crystal:24MHz/12T // 6T: 1 source clock = 1/(Fosc/12) = 12/24MHz =0.5us // 12T: 1 source clock = 2/(Fosc/12) =2*12/24MHz =1us // detect P1.3 toggle per 100us //******************************************************************** #include"sfr.h" void Initial() IE=0x80; IE1=0x02; //enable all interrupt //enable PCA interrupt PCAC1=0x81; //PCAC1.7=>PCA counter run bit //PCAC1 enable CC0 interrupt //PCAC2.7,PCAC2.6 Clock source // 0 0 Fosc // 0 1 Fosc/4 // 1 0 Fosc/12 IRFWX-A123 18 Ver. A 2009/03

// 1 1 External clock input(ccci pin) PCAC2=0x80; //clock source from Fosc/12 可程式計數陣列功能使用方法 PCAH =0x00; PCAL =0x00; CC0DH=0x00; CC0DL=0x64;; // //software reload value //software reload value //detect P1.3 toggle per 100us // only for select channel at CCnCON. void Select_channel_mode() CC0CON=0x05; //high speed mode =>P1.3 enable CC1CON=0x00; //high speed mode =>P1.4 disable CC2CON=0x00; //high speed mode =>P1.5 disable CC3CON=0x00; //high speed mode =>P1.6 disable CC4CON=0x00; //high speed mode =>P1.7 disable // PCA High Speed interrupt void PCA_High_Speed(void) interrupt 7//vector 3B PCAL =0x00; //software reload value PCAH =0x00; //software reload value PCAC2=PCAC2&0xC0; // PCAC2.7:6 (CCCLK is "11" representative external clock input "p1.2") void main() Initial(); Select_channel_mode(); while(1) IRFWX-A123 19 Ver. A 2009/03

7.4 PCA PWM mode 應用的範例程式 : Description Device:SM59D04G2C25 Crystal:24MHz/12T Main program //==================================================================== // // S Y N C M O S T E C H N O L O G Y // //==================================================================== #include"sfr.h" void Select_channel(); void Initial(); void main() Initial(); Select_channel(); while(1) p3=~p3; //***************************************************************** // initial set and select clock source mode0 ~ mode3 //***************************************************************** void Initial() p0=0xff; p1=0xff; p2=0xff; p3=0xff; PCAC1=0x9f; //PCAC1.7=>PCA counter run bit enable //PCAC1.4 ~ PCAC1.0 enable CC4 ~ CC0 interrupt //source clock = Fosc/12 PCAC2=0x80; //***************************************************************** // select 8 bit or 16 bit PWM and select PWM output p1.3 ~ p1.7 //***************************************************************** void Select_channel(void) CC0CON=0x06; //8bit PWM CC0DL= 0x3F; //pulse width,low:high =64us:192us =1:3 /* CC1CON=0x07; //16bit PWM CC1DH= 0x3F; //pulse width,low:high =16.386ms:49.159ms =1:3 CC1DL= 0xFF; CC1CON=0x06; //8bit PWM CC1DL= 0x00; //pulse width,always low CC0CON=0x06; //8bit PWM CC0DL= 0x01; //pulse width,low:high =2:254 IRFWX-A123 20 Ver. A 2009/03

*/ /* CC2CON=0x06; //8bit PWM CC2DL= 0xfd; //pulse width,low:high =254:2 CC3CON=0x06; //8bit PWM CC3DL= 0xfe; //pulse width,low:high =255:1 CC4CON=0x06; //8bit PWM CC4DL= 0xff; //pulse width,always low CC0CON=0x07; //16bit PWM CC0DH= 0x00; //pulse width,low:high =3:65533 CC0DL= 0x02; CC1CON=0x07; //16bit PWM CC1DH= 0x00; //pulse width,low:high =2:65534 CC1DL= 0x01; CC2CON=0x07; //16bit PWM CC2DH= 0x00; //pulse width,always low CC2DL= 0x00; CC3CON=0x07; //16bit PWM CC3DH= 0xFF; //pulse width,low:high =65535:1 CC3DL= 0xFE; CC4CON=0x07; //16bit PWM CC4DH= 0xFF; //pulse width,always low CC4DL= 0xFF;*/ IRFWX-A123 21 Ver. A 2009/03