html5-img
1 / 6

嵌入式系統進階

嵌入式系統進階. 嵌入式系統的設計方式. 輪詢的設計方式 CPU 不斷測試資料是否已經進入,忙碌等待 (Busy Waiting), 無窮迴圈 . 大無窮迴圈的設計方式 CPU 不斷測試資料是否已經進入,但盡量不因單一裝置而卡住,使用很多 if 測試狀態旗標 中斷向量的設計方式 週邊設備會自動回報給 CPU 後,直接跳到中斷常式中執行. 輪詢的設計方式. int main(void) { int i; irq_init(); Initial_Creator(); enable_irq(); while (1)

evania
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. 嵌入式系統進階

  2. 嵌入式系統的設計方式 • 輪詢的設計方式 • CPU 不斷測試資料是否已經進入,忙碌等待 (Busy Waiting), 無窮迴圈. • 大無窮迴圈的設計方式 • CPU 不斷測試資料是否已經進入,但盡量不因單一裝置而卡住,使用很多 if 測試狀態旗標 • 中斷向量的設計方式 • 週邊設備會自動回報給 CPU後,直接跳到中斷常式中執行. 2

  3. 輪詢的設計方式 int main(void) { int i; irq_init(); Initial_Creator(); enable_irq(); while (1) { UC ch; while (KEYPAD_chk_key(&ch) == OK) KEYPAD_get_key(&ch); LCD_printf("key=%d\n", ch); } disable_irq(); return(0); } 3

  4. 大無窮迴圈的設計方式 int main(void) { int i; irq_init(); Initial_Creator(); enable_irq(); while (1) { UC ch; if (KEYPAD_chk_key(&ch) == OK) { KEYPAD_get_key(&ch); LCD_printf("key=%d\n", ch); } // if (....) } disable_irq(); return(0); } 4

  5. 中斷向量的設計方式 void Initial_TIMER0(void) { rTCFG0 = (rTCFG0 & ~(0xff)) | SYS_TIMER01_PRESCALER; rTCFG1 = (rTCFG1 &~(0xf)) | (SYS_TIMER0_MUX); rTCNTB0 = (TIMER0_RESCHED_PERIOD*PCLK)/ ((SYS_TIMER01_PRESCALER +1)*(SYS_TIMER1_DIVIDER)*1000); rTCMPB0 = 0; rTCON = rTCON & ~(0xffffff) | 0x6aaa0a; rTCON = rTCON & ~(0xffffff) | 0x599909; tick_on = UM; tick_ms = 0; tick_sec = 0; tick_min = 0; tick_hour = 0; register_irq(IRQ_TIMER0, TIMER0_ISR, "Timer ISR"); ClearPending(BIT_TIMER0); EnableInterrupt(BIT_TIMER0); } 5

  6. 參考文獻 • Computer Organization, 5/e • Carl Hamacher, Zvonko Vranesic, Safwat Zaky • Section 2.7 : 輸出入作業 • Chapter 9 : 嵌入式系統 6

More Related