回复帖子:(x10(222.210.*.*))不会,很多系统函数都会打...

用户名:   *您没有注册?
密码:   *忘记论坛密码?    标题采用“回复:XXX....”
验证码 点击获取验证码
主题标题:  *不得超过 200 个汉字
当前心情
上一页 发帖表情 下一页
内容
  

主题最新回顾(发布时间:2008-1-7 9:26:00)
--  作者:x10(222.210.*.*)
--  
不会,很多系统函数都会打开中断。

主题最新回顾(发布时间:2008-1-7 7:50:00)
--  作者:shtupc(202.194.*.*)
--  
谢谢了!
顺便再问一句,如果在ReadTimer0()最后没有加sti的话,系统会不会一直关中断啊?

主题最新回顾(发布时间:2008-1-6 9:53:00)
--  作者:x10(222.210.*.*)
--  
不会,ICU会保持中断请求,一旦系统enable()或sti,就会响应中断。可以在ReadTimer0()最后加一条sti:

unsigned int ReadTimer0( )
{
asm pushf /* Save interrupt flag */
asm cli /* Disable interrupts */
asm mov al,0h /* Latch timer 0 */
asm out 43h,al
dummy(); /* Waste some time */
asm in al,40h /* Counter --> bx */
asm mov bl,al /* LSB in BL */
dummy(); /* Waste some time */
asm in al,40h
asm mov bh,al /* MSB in BH */
asm mov ax, 0f533h /* */
asm sub ax, bx
asm mov bx, ax /* Need ascending counter */
asm popf /* Restore interrupt flag */
asm sti  /* enable sti */
return( _BX );
}

主题最新回顾(发布时间:2008-1-6 7:57:00)
--  作者:shtupc(202.194.*.*)
--  关于串口中断的问题
在 ETR100.cpp文件中,有一个NB_Delay函数,里面调用了ReadTimer0( )函数,而ReadTimer0( )函数中有一句cli关中断的指令,我想问一下,在关中断这段短暂的时间里,如果外部设备通过串口发送过来数据,会不会因为中断系统是关闭的而丢掉,如何解决,谢谢!
下面是这两个函数的程序:
void NB_Delay( unsigned int milliseconds )
{
   unsigned long stop;
   unsigned cur, prev;

   prev = ReadTimer0( );
   stop = prev + (milliseconds * MULTIPLIER);

   cur = ReadTimer0( );
   while( cur < stop )
      {
      if(cur < prev)     /* Check for timer wraparound */
 {
 if (stop < TMR0SIZE) break;
 stop -= TMR0SIZE;
 }
      prev = cur;
      cur = ReadTimer0( );
      }
}

unsigned int ReadTimer0( )
{
  asm pushf                    /* Save interrupt flag         */
  asm cli                      /* Disable interrupts          */
  asm mov  al,0h               /* Latch timer 0               */
  asm out  43h,al
      dummy();                 /* Waste some time             */
  asm in   al,40h              /* Counter --> bx              */
  asm mov  bl,al               /* LSB in BL                   */
      dummy();                 /* Waste some time */
  asm in   al,40h
  asm mov  bh,al               /* MSB in BH                   */
  asm mov  ax, 0f533h          /* */
  asm sub  ax, bx
  asm mov  bx, ax         /* Need ascending counter      */
  asm popf                     /* Restore interrupt flag      */
  return( _BX );
}