線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3151
推到 Plurk!
推到 Facebook!

請問一下如何利用c語言寫一個中斷副程式?

尚未結案
snyu1982
一般會員


發表:3
回覆:2
積分:1
註冊:2005-07-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-07-16 00:23:11 IP:61.231.xxx.xxx 未訂閱
請問一下如何利用c語言寫一個中斷副程式? 我是要用在控制類比數位信號轉換的, 只是要利用到C語言中的中斷指令, 但是不知要如何下手!!!!!請各位幫個忙!!!!! 方便的話可以給小弟完整的DEMO嗎? E-MAIL:tsai.snyu@msa.hinet.net
hobolin
初階會員


發表:0
回覆:25
積分:25
註冊:2005-07-03

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-07-16 15:24:01 IP:202.145.xxx.xxx 未訂閱
可否詳述是什麼作業系統? 用什麼樣的卡(isa or pci)? 中斷的目的是什麼?
snyu1982
一般會員


發表:3
回覆:2
積分:1
註冊:2005-07-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-07-16 15:43:52 IP:61.231.xxx.xxx 未訂閱
請問一下如何利用c語言寫一個完整的中斷程式架構? 我是要用在控制類比數位信號轉換的(卡片為ISA), 希望能利用固定週期的中斷 達到固定取樣頻率做一次A/D轉換的目的 只是要利用到C語言中的中斷指令, 但是不知要如何下手!!!!!請各位幫個忙!!!!! 方便的話可以給小弟完整的DEMO嗎?(包含所有宣告,inculde) 若能標明["固定時間"的設定處]和["A/D轉換的程式"該放在哪裡]更好 PS:我用TURBO C 3.0 (DOS下操作) E-MAIL:tsai.snyu@msa.hinet.net
hobolin
初階會員


發表:0
回覆:25
積分:25
註冊:2005-07-03

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-07-16 16:19:18 IP:202.145.xxx.xxx 未訂閱
用 google 查到了下面的網址 http://downloads.suntimes.com/category.php%5Baction%5Dbrowse&i=20&id=294&f=%7C%7C%7C%7C&s=product.date_released%7CDESC%5BSiteID%5Dsuntimes    裡面有 ticktock.c
/*
     Name: ticktock.c
     Author: Michael Tighe
     System: IBM PC/XT/AT/PS2, MS-DOS 3.30
   Language: Turbo C Version 2.00
Description: Demo of the IBM-PC's high resolution clock
 
    INFO FOR TICKTOCK:
 
    The TICKTOCK programs demonstrate how to obtain accurate timing
information from the IBM PC/XT/AT family of computers. The next few
paragraphs should give you a basic idea of how the time is stored in these
computer systems.
 
    In the PC family, an internal clock runs at 1.193180 Mhz. This clock
is divided by 65536 to give 18.206482 clock pulses per second (.0549255
seconds per clock pulse). Therefore, the clock 'ticks' every .0549255
seconds.
 
    Two addresses in low memory are used to keep track of the tick count.
They are both 1 word (two bytes) in length. The first is at address
0000:046C. It is incremented 18.2 times a second. When it overflows, it is
reset to 0 and another word at address 0000:046E is incremented.
 
    It should be noted that the word at address 0000:046E is also the
current hour, in 24 hour format. The address at 0000:046C when divided by
18.2, is the current time past the hour, in seconds.
 
*/
# include 
 
# define TIMER_LO 0X46C
# define TIMER_HI 0X46E
 
void geticktock();
 
float tick, tock;
 
main()
{
  printf("[TICKTOCK Version 87.365]\n\n");
  getticktock();
  printf("tick value is %6.0f, tock value is %6.0f\n",tick,tock);
  printf("Sleeping for 5 seconds (~91 ticks)...\n"); sleep(5);
  getticktock();
  printf("tick value is %6.0f, tock value is %6.0f\n",tick,tock);
  return;
}
 
getticktock()
{
  unsigned char t1,t2;
 
  t1 = 0; t2 = 0;
  t1 = peekb(0,TIMER_LO); t2 = peekb(0,TIMER_LO 1);
  tick = (float) t1   (float) t2 * 256;
  t1 = peekb(0,TIMER_HI); t2 = peekb(0,TIMER_HI 1);
  tock = (float) t1   (float) t2 * 256;
  return;
}
取得系統時間後,可以用此做一個簡單的 delay 程式,以達 到週期性取值的目的。 沒辦法給你完整的 demo,手頭上沒有 dos 可以測試, 不過這個 code 應該是沒有問題的
系統時間:2024-05-19 1:04:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!