1 / 46

微控制器 應用產品開發與實務

微控制器 應用產品開發與實務. 2007 年 8 月 7 日. 目錄. 為何需要 MCU ? 可供開發使用的元件? 如何撰寫 MCU 程式? 範例說明。 結論。. 為何需要 MCU. 7:00 起床 / 刷牙 / 刮鬍子 [Alarm Clock, Elec. Brusher & Shaver] 7:15 煮咖啡 / 烤吐司 [Coffee Maker & Toaster] 7:30 看電視 Morning News [TV Remote ]

brad
Télécharger la présentation

微控制器 應用產品開發與實務

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. 微控制器應用產品開發與實務 2007年8月7日

  2. 目錄 • 為何需要MCU? • 可供開發使用的元件? • 如何撰寫MCU程式? • 範例說明。 • 結論。

  3. 為何需要MCU 7:00 起床/刷牙/刮鬍子 [Alarm Clock, Elec. Brusher & Shaver] 7:15 煮咖啡/烤吐司 [Coffee Maker & Toaster] 7:30 看電視 Morning News [TV Remote ] 8:00 Drive to Office [Keyless Car Entry & Remote] 8:30 Turn on Computer [Mouse & Keyboard] 9:30 Make Phone Calls/ Print Papers [Phone System & MFP] 12:00 Heat Lunch [Microwave Oven] 13:00 Exercise [ Jogging Machine & Pedometer] 14:00 Soft Drink [Slot Machine] 18:00 Turn on Air-conditioner [Remote Control] 19:00 Make Dinner [ Rice Cooker & Induction Cooker & Refrigerator ] 20:00 Listen to the music [ Remote Control ] Play with your Child [ Interaction Toys/ Learning Aids ] 21:30 Take a bath [ Instant Water Heater & Hair Dryer & Weight Scale] 22:00 Laundering [Washing Machine/ Dryer/ Steam Iron] 22:30 Go to bed & have a good sleeping Of course : Don’t forget to charge you battery and get your home security system alarmed

  4. C/R-F Type MCU HT45R36 HT45R38

  5. 何謂C/R-F Frequency Changed User can add R User can add C

  6. 家族成員

  7. 系統方塊圖 HT45R38 only OPA LED Driver (High Current Drive Port) Current Sensing LEDs 1 channel 8x8 Control I/O Key Inputs 2 channel PWMSignals 8-Bit PWM Holtek8-Bit MCUCore 5 channel AnalogSignals 12-Bit ADC C Sensor OSC Circuit Timer R Sensor External RC Oscillator VDD

  8. HT45R36接腳圖 HT45R36 52 QFP-A HT45R36 44 QFP-A

  9. HT45R38接腳圖 HT45R38 52 QFP-A

  10. DC特性 Ta=25ºC

  11. HT45R38 OPA DC特性 Ta=25ºC

  12. HT45R38 OPA AC特性 Ta=25ºC

  13. HT45R38比較器特性 Ta=25ºC Note: the OPA can be used as a comparator.

  14. C/R-F轉換圖 ASON is Channel Selection 00000b=TG1 On, Others Off. 00001b=TG2 On, Others Off. … … … 01111b=TG16 On, Others Off. 10000b=all TGs Off, Power Saving Mode ASCR Register Oscillation Circuit Timer B

  15. 計時轉換電路 1. RCO=0, Timer Mode and Timer B are Preloaded 2. RCO=1, RC Mode 1. OVB=0, Timer A Overflow. 2. OVB=1, Timer B Overflow. RCOCR Register

  16. HT45R38 Low offset調整 Low Offset Use AOF0 ~ AOF3 to Configure the Offset Voltage. Note: the OPA can be used as a comparator

  17. Offset對輸出訊號的影響 Schmitt Trigger The OPA/Comparator Diagram Adjust Hysteresis Adjust Offset Voltage to VCC/2

  18. 如何增加OPA的增益 Raise Gain VCC/2 OPA Configuration and Method of Increasing Gain

  19. HT45R36應用電路 Max. 8x8=64 Pixel LED Direct DrivingNo External Transistors

  20. HT45R38應用電路 Max. 8x8=64 Pixel LED Direct DrivingNo External Transistors

  21. A/D with OPA Type MCU HT46R32 / HT46R34 HT46R322 / HT46R342

  22. 家族成員

  23. 家族特色 • Program Memory • 2K14 for HT46R32 and HT46R322 • 4Kx15 for HT46R34 and HT46R342 • Data Memory • 888 for HT46R32 and HT46R322 • 192x8 for HT46R34 and HT46R342 • 20 Bidirectional I/O Pins • 8x8 High Current Drive Output (LED Driver) • HT46R322 and HT46R342 only • Six-level Subroutine Nesting • Watchdog Timer (WDT) • HALT and Wake-up Feature Reduce Power Consumption • Low Voltage Reset (LVR)

  24. Holtek8-Bit MCUCore 系統方塊圖 HT46R322/342 only Analog Signals OPA 1 channel LED Driver (High Current Drive Port) LEDs 8x8 2 channel PWMSignals 8-Bit PWM Control I/O Key Inputs 4 channel AnalogSignals 12-Bit ADC Timer /PFD External RC Oscillator Buzzer VDD

  25. HT46R32/34接腳圖 OPA Pin

  26. HT46R322/342接腳圖 LED Driver orOther Applications OPA Pin

  27. 應用電路 Max. 8x8=64 Pixel LED Direct DrivingNo External Transistors

  28. A/D with USB Type MCU HT46RB50 HT46RB70

  29. 為何需要USB • Support Plug and Play, Auto Detection • Easy to Expand, Support Up to 127 Devices • Hot Plug • Bus Power (max. 500mA from Host) / Self Power • Different Speed Selection • Low Speed (1.5 Mbps) • Full Speed (12 Mbps) • High Speed (480 Mbps) RS232 、Printer Port、 PS2 Port RS232、Printer Port、 PS2 Port

  30. Holtek USB MCU成員 High Speed USB 2.0 HT46RB50, HT46RB70 HT82A821R, HT82A822R HT82A832R Standard ADC USB Full Speed ASSP Speaker USB ASSP Phone USB HT82K94E, HT82K95E, HT82K96E HT82J97E, HT82M99E HT49RB50, HT49RB70 Standard I/O USB Low Speed Standard LCD USB

  31. 家族成員 Note: • HT46RB50, HT46RB70 all with SIO interface • HT46RB50/B70 with 1 and 2 bulk endpoint respectively

  32. 家族特色 • Program Memory: 4Kx15 and 8Kx16ROM • Data Memory: 192 bytes and 384 bytesRAM • Watchdog Timer (WDT) • Single Channel Serial Interface (SIO) • Up to 10-bit ADC 8 Channels • Up to 8-bit PWM4 Channel Outputs • Up to 6/12MHz XTAL System Clock(register need to be set to 6MHz or 12MHz) • Low Voltage Reset Function (LVR)

  33. 家族特色 • Internal 48MHz PLL frequency for Transceiver • Internal Regulator output 3.3V for D+ Pull-High • Full Speed USB (12 Mbps) • Support Remote Wake-up Function • HT46RB50 with 4 Endpoints (Endpoint 0~ Endpoint 3) • HT46RB70 with 6 Endpoints (Endpoint 0~ Endpoint 5) • Endpoint 0: Control Pipe (Setup / Input / Output) • Endpoint 1, 2, 4: Interrupt Pipe (Input / Output) • Endpoint 3, 5: Bulk Pipe (Input / Output)

  34. 系統方塊圖 Filter SIO Analog Output PWM Regulator V330 Holtek8-bit MCUCore PLL AnalogSignal 1.5k A/D F I F O S I E D+ H O S T Byte TX Control I/O Key Input D- VDD VSS Xtal 6/12MHz

  35. 應用電路 • Automatic Control • Data Collection • RS232 to USB Bridge • Handwriting System • Key Pad, Keyboard, Joystick…

  36. 為何MCU需要程式 • 什麼時間做什麼事。 • 遇到什麼狀況做什麼事。

  37. 如何撰寫MCU程式 • 程式語言依歷史演進可分為: • 1. 機器語言。 • 0101010100011101 • 2. 低階語言,又稱組合語言。 • 每種CPU都有自己的組合語言。 • 利用英文替代01010011。 • MOV A,01、AND A,FFH、ADD A,12H。 • 80X86、8051、PIC16F877、ARM等等。 • 3. 高階語言。 • 接近人類語言、更容易撰寫及閱讀 。 • C語言、Basic、FORTRAN、COBOL、PASCAL等等。 • 4. 物件導向語言。 • 把程式設計的概念物件化、具體化 。 • Visual Basic、Visual C++、Delphi等等。 • 5. 自然語言。 • 人類口語化的語言 。

  38. 人類談話內容歸類 • 談話內容可分為3類 • 1. 敘述 • 今天我去小明家作客。 • 我看到一件漂亮的衣服。 • 2. 疑問 • 這是真的嗎? • 我不相信! • 3. 判斷 • 我覺得你在騙我。 • 肚子餓了。

  39. 程式撰寫內容歸類 • 程式撰寫內容可以分為2類: • 1.敘述 • Sun=1+x • X2+2x+1=0 • 2.判斷 • If x==1 • While (x!=2)

  40. 變數與副程式命名原則 • 盡量少用無意義的數字與接腳,可將其命名。 • #define True 1 • #define False 0 • #define SW0 _pa0 • 使用匈牙利命名法則 • 變數以英文縮寫表示且第一個字大寫,可與指令或是暫存器名稱作區分,如遇一個英文字無法表示完成,可以用底線來完成。 • mov Command_H,True • sz SW0 • 副程式命名也是以此原則。 • Init_IO_Port • Init_Register

  41. 結構化程式設計 • 何謂結構化程式設計? • 由上而下的設計方式。 • 先定義設計最終目標,再細分構成最終目標所需的各部分,接著一直劃分到最基本元件。 • 模組化的設計方式。 • 對於副程式的變數傳遞只能一進一出。 • 只能用順序、選擇、重複等三種結構化特性來撰寫程式。 • if-else, switch case • for, while, do-while • 禁用goto。 • 善用註解與說明。

  42. 程式撰寫方式 • 先撰寫main主程式。 • 撰寫Scan_Key副程式。 • 撰寫BZ副程式。 • 撰寫Delay副程式。 • 撰寫Disp_7Seg副程式。 • 撰寫Hex_to_BCD副程式。 按鍵顯示之程式架構圖

  43. 程式測試方法 • 先針對硬體電路做測試。 • 先針對最基本的副程式作測試至完成為止。 • BZ、Delay、Hex_to_BCD • 測試過程中可以利用測試點的方式來做測試,例如利用I/O Port或是HT-IDE3000中的Watch視窗觀看執行過程是否有錯誤。 • 接著測試Scan_Key之副程式是否正常。 • 再者測試Disp_7Seg之副程式。 按鍵顯示之程式架構圖

  44. 程式撰寫與除錯 Register Windows Watch Windows

  45. 按鍵顯示實驗Demo與說明

  46. 結論 • 生活中離不開MCU的產品。 • 越來越多的硬體電路被加入到MCU中。 • 學習到變數如何命名。 • 學習結構化程式寫法。 • 如何利用HT-IDE3000之Watch功能來進行程式除錯。

More Related