1 / 14

第五章 MSP430 中斷式數位 I/O

第五章 MSP430 中斷式數位 I/O. 微電腦控制 I/O 介面. 中斷控制器 (interrupt controller) In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution.

vaughn
Download Presentation

第五章 MSP430 中斷式數位 I/O

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. 第五章MSP430中斷式數位I/O

  2. 微電腦控制I/O介面 • 中斷控制器(interrupt controller) • In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution. • 處理與時間相關的工作(time-dependent task)  事件(event) 中斷要求(interrupt request) 中斷服務常式(interrupt service routine, ISR) 回到上次執行點 • 中斷的辨認與分派方式 輪詢 (polling) 中斷向量(interrupt vector)

  3. I/O的服務-詢問 • 當轉移I/O埠的資料或狀態信息時,稱之為在服務I/O埠。服務的需求可由二種方式產生:詢問(polling)及中斷(interrupt)。 • 詢問程式是一段小程式,規律的檢查I/O埠是否需要服務。 • 詢問程式檢查I/O埠的狀態暫存器決定是否需要服務。其優先順序是依詢問程式的撰寫方式決定。 • 詢問的I/O系統必須等軟體測試方能得到服務,適用於不需要立即得到服務的系統或服務頻率很低的系統。

  4. I/O的服務-中斷 • 中斷輸入就像硬體的副程式呼叫,當中斷信號啟動時,一個特別的控制邏輯程序便開始。微處理器先儲存目前PC內容,以便在中斷結束後返回。其主要步驟: • 收到中斷信號(interrupt request, IRQ) • 完成目前執行的指令(因此沒有指令被中途停止) • 將目前PC值放入堆疊中 • 自特殊記憶體位址處取出中斷向量值放入PC • 程式由PC所指的新位址繼續執行 • 中斷程式執行到回返指令後結束。 • 中斷服務程式的起使位置被存在特殊的記憶體位址,稱之為中斷向量。

  5. 多重中斷需求處理 • 當有超過一個的中斷需求時,微處理器通常有兩種方式解決: • 有些微處理器有多個中斷埠。每個中斷服務程式有不同的中斷向量,不同的中斷裝置可呼叫不同的服務程式。 • 當微處理器只有單獨一個中斷輸入時,一些系統使用外部硬體提供不同的中斷向量。

  6. MSP430的中斷

  7. MSP430的中斷

  8. MSP430的中斷

  9. MSP430的中斷

  10. MSP430的I/O中斷

  11. MSP430的I/O中斷 INT01.C • 將P1.4接至GND後放開,觀察LED1變化。 • 承上若要改成接至VCC後產生LED1變化,該如何更改程式?? • 若要改成由P1.5觸發中斷,該如何改程式?? • 試試看不清除PXIFG旗標的狀況。 • P1.4改成以波型產生器輸入1Hz方波,觀察LED1變化。

  12. MSP430的I/O中斷 INT01.C

  13. MSP430的I/O中斷 Polling01.C

  14. MSP430的I/O中斷 INT02.C • 詳細比較本程式與上一個程式的差異性。 • 試著修改為以P1.4及P1.5為中斷來源。若P1.4被觸發(正源觸發),則LED1快速閃動;若P1.5被觸發(正源觸發),則LED2快速閃動。其餘時間,閃動方式如INT02.C原來的模式。

More Related