реклама на сайте
подробности

 
 
> Хочу прерывание на Паскале от СОМ-порта, (Турбо Паскаль, не Дельфи)
Diusha
сообщение May 26 2009, 17:11
Сообщение #1


Вечный студент
****

Группа: Участник
Сообщений: 500
Регистрация: 11-09-06
Из: Питер
Пользователь №: 20 262



Программка (запускается под DOS, Win98):


CODE
Uses crt, dos;

Label Finish, ll00;

Const
baud = 38400;
COM=$3F8 { $2F8 };
intr=$0C { $0B };

Var
stv, srv : pointer;
cnt : word;
b : byte;
key : char;
speed_fr : word;

{----------------------------------------------------------------------------------}
{$F+}
Procedure int_1c; interrupt;
Begin
inc(cnt);
if cnt=18 then begin cnt:=0; write ('g') end;
End;
{$F-}
{-----------------------------------------------------------------------------------}
{$F+}
Procedure int_rs; interrupt;
Begin
b:=port[COM];
write (b,' ');
End;
{$F-}
{----------------------------------------------------------------------------------}

BEGIN
speed_fr:=trunc(115200/baud+0.5);
port[COM+3]:=$80; { ўЄ«. гбв ­®ўЄ бЄ®p®бвЁ }
port[COM+1]:=hi(speed_fr); port[COM+0]:=lo(speed_fr);
port[COM+3]:=$00; { 5 bit, 1 stop, parity=none }
port[COM+4]:=0;
port[COM+2]:=$03; { FIFO on }
port[COM+1]:=$01; { interrupt when rec'd data is available }

getintvec($1C,stv);
getintvec(intr,srv);

cnt:=0;
setintvec($1C,addr(int_1c));
setintvec(intr,addr(int_rs));

ll00 : if keypressed then begin
key:=readkey;
goto Finish;
end;

{ b:=port[COM+5]; }
{ if (b and $01)<>0 then begin }
{ b:=port[COM]; }
{ write (b,' '); }
{ end; }

goto ll00;

Finish :
setintvec($1C,stv);
setintvec(intr,srv);
halt;
END.



Процедурка int_1c - для тренировки - раз в сек пишет "g"; работает. По ее образу и подобию - int_rs - должна непечатать принятые с СОМ данные. Не работает. Что не так?
Порт настраивается нормально, в этом легко убедиться раскомментировав 5 строчек выше "goto ll00;"
Причина редактирования: Оформление цитаты исходника.
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
SysRq
сообщение May 30 2009, 15:36
Сообщение #2


Чайник, 1 литр
****

Группа: Свой
Сообщений: 655
Регистрация: 17-05-06
Из: Moscow
Пользователь №: 17 168



Цитата
The Interrupt Enable bit is a PC-specific item. This is normally a general purpose output (OUT 2) on the 8250 SCC. However IBM's designers connected this output to an external gate to enable or disable all interrupts from the SCC. This bit must be programmed with a one to enable interrupts. Likewise you must ensure that this bit contains a zero if you are not using interrupts.

Цитата
Set OUT2 in the MODEM CONTROL Register so that the interrupt signal from the 8250 ACE is passed to the IRQ4 Interrupt Request Line


..just Gooooooooooooogle it :)
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- Diusha   Хочу прерывание на Паскале от СОМ-порта   May 26 2009, 17:11
- - SysRq   Цитата(Diusha @ May 26 2009, 21:11) port[...   May 26 2009, 17:34
- - zltigo   Цитата(Diusha @ May 26 2009, 20:11) Прогр...   May 26 2009, 18:08
- - defunct   Цитата(Diusha @ May 26 2009, 20:11) Не ра...   May 26 2009, 23:06
|- - Diusha   Цитата(defunct @ May 27 2009, 02:06) Writ...   May 27 2009, 04:20
||- - _Pasha   Цитата(Diusha @ May 27 2009, 07:20) До на...   May 27 2009, 07:48
|- - Diusha   Уррра-ааааа!!! Заработало!!...   May 30 2009, 14:25
|- - defunct   Цитата(Diusha @ May 30 2009, 17:25) Тепер...   May 30 2009, 14:42
|- - Diusha   Да, действительно, только бит 3 влияет   May 30 2009, 15:02
- - XVR   Прерывание от COM порта еще надо разрешить в контр...   May 27 2009, 08:52
|- - vvs157   Цитата(XVR @ May 27 2009, 12:52) Прерыван...   May 27 2009, 12:46
||- - defunct   Цитата(vvs157 @ May 27 2009, 15:46) И еще...   May 27 2009, 14:05
||- - _Pasha   Цитата(defunct @ May 27 2009, 17:05) Вот ...   May 27 2009, 14:13
||- - defunct   Цитата(_Pasha @ May 27 2009, 17:13) А Вы ...   May 27 2009, 18:42
|- - Diusha   Цитата(XVR @ May 27 2009, 11:52) Прерыван...   May 27 2009, 17:15
|- - _Pasha   Цитата(Diusha @ May 27 2009, 20:15) И смы...   May 27 2009, 17:25
|- - XVR   Цитата(Diusha @ May 27 2009, 21:15) И смы...   May 28 2009, 08:25
|- - Diusha   В теории я немного просветился. Но практике это не...   May 29 2009, 16:40


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 25th July 2025 - 12:14
Рейтинг@Mail.ru


Страница сгенерированна за 0.01394 секунд с 7
ELECTRONIX ©2004-2016