打印
[应用相关]

再问 ucos的中断写入规则

[复制链接]
3189|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dkill|  楼主 | 2008-6-10 18:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
ucos, TI, ni, pi, gp
1.首先我建立一个主任务
   static  void  AppTaskStart (void *p_arg)
{
    CPU_INT32U  i;
    CPU_INT32U  j;


   .............

    BSP_Init();                                                 /* 

   ..........
}
2.在BSP_Init(); 函数里我初始化了一个外部中断线
void  BSP_Init (void)
{
   
      ...........

   
      temper_Init();

     ...........
}
函数的操作:
static  void temper_Init(void)

  GPIO_InitTypeDef GPIO_InitStructure;
  EXTI_InitTypeDef EXTI_InitStructure;
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  /* Configure PB.09 as input floating (EXTI Line 9) */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  
  
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);

  /* Configure EXTI Line9 to generate an interrupt on falling edge */  
  EXTI_InitStructure.EXTI_Line = EXTI_Line9;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  EXTI_GenerateSWInterrupt(EXTI_Line9);
  
}
这样当我按键时会产生中断。
  我想问的是中断跳到哪个函数去呢,我不知道的就是怎样写这个中断要跳转到的函数(函数名称和定义步骤都不清楚)
    请高手指点
  
沙发
dkill|  楼主 | 2008-6-11 11:39 | 只看该作者

帮帮我呀

使用特权

评论回复
板凳
dkill|  楼主 | 2008-6-11 12:00 | 只看该作者

继续发

  const  INTVECT_ELEM  AppVectTbl[] = {
    { .__ptr = __sfe("CSTACK")},        /*  0, SP start value.                                         */
    __program_start,                    /*  1, PC start value.                                         */
    App_NMI_ISR,                        /*  2, NMI                                                     */
    App_Fault_ISR,                      /*  3, Hard Fault                                              */
    App_Spurious_ISR,                   /*  4, Memory Management                                       */
    App_Spurious_ISR,                   /*  5, Bus Fault                                               */
    App_Spurious_ISR,                   /*  6, Usage Fault                                             */
    0,                                  /*  7, Reserved                                                */
    0,                                  /*  8, Reserved                                                */
    0,                                  /*  9, Reserved                                                */
    0,                                  /* 10, Reserved                                                */
    App_Spurious_ISR,                   /* 11, SVCall                                                  */
    App_Spurious_ISR,                   /* 12, Debug Monitor                                           */
    App_Spurious_ISR,                   /* 13, Reserved                                                */
    OSPendSV,                           /* 14, PendSV Handler                                          */
    Tmr_TickISR_Handler,                /* 15, uC/OS-II Tick ISR Handler                               */
    App_Spurious_ISR,                   /* 16, INTISR[  0], Window Watchdog                            */
    App_Spurious_ISR,                   /* 17, INTISR[  1]  PVD through EXTI Line Detection            */
    App_Spurious_ISR,                   /* 18, INTISR[  2]  Tamper Interrupt                           */
    App_Spurious_ISR,                   /* 19, INTISR[  3]  RTC Global Interrupt                       */
    App_Spurious_ISR,                   /* 20, INTISR[  4]  FLASH Global Interrupt                     */
    App_Spurious_ISR,                   /* 21, INTISR[  5]  RCC Global Interrupt                       */
    App_Spurious_ISR,                   /* 22, INTISR[  6]  EXTI Line0 Interrupt                       */
    App_Spurious_ISR,                   /* 23, INTISR[  7]  EXTI Line1 Interrupt                       */
    App_Spurious_ISR,                   /* 24, INTISR[  8]  EXTI Line2 Interrupt                       */
    App_Spurious_ISR,                   /* 25, INTISR[  9]  EXTI Line3 Interrupt                       */
    App_Spurious_ISR,                   /* 26, INTISR[ 10]  EXTI Line4 Interrupt                       */
    App_Spurious_ISR,                   /* 27, INTISR[ 11]  DMA Channel1 Global Interrupt              */
    App_Spurious_ISR,                   /* 28, INTISR[ 12]  DMA Channel2 Global Interrupt              */
    App_Spurious_ISR,                   /* 29, INTISR[ 13]  DMA Channel3 Global Interrupt              */
    App_Spurious_ISR,                   /* 30, INTISR[ 14]  DMA Channel4 Global Interrupt              */
    App_Spurious_ISR,                   /* 31, INTISR[ 15]  DMA Channel5 Global Interrupt              */
    App_Spurious_ISR,                   /* 32, INTISR[ 16]  DMA Channel6 Global Interrupt              */
    App_Spurious_ISR,                   /* 33, INTISR[ 17]  DMA Channel7 Global Interrupt              */
    App_Spurious_ISR,                   /* 34, INTISR[ 18]  ADC Global Interrupt                       */
    App_Spurious_ISR,                   /* 35, INTISR[ 19]  USB High Priority / CAN TX  Interrupts     */
    App_Spurious_ISR,                   /* 36, INTISR[ 20]  USB Low  Priority / CAN RX0 Interrupts     */
    App_Spurious_ISR,                   /* 37, INTISR[ 21]  CAN RX1 Interrupt                          */
    App_Spurious_ISR,                   /* 38, INTISR[ 22]  CAN SCE Interrupt                          */
    App_Spurious_ISR,                   /* 39, INTISR[ 23]  EXTI Line[9:5] Interrupt                   */
    App_Spurious_ISR,                   /* 40, INTISR[ 24]  TIM1 Break  Interrupt                      */
    App_Spurious_ISR,                   /* 41, INTISR[ 25]  TIM1 Update Interrupt                      */
    App_Spurious_ISR,                   /* 42, INTISR[ 26]  TIM1 Trigger & Commutation Interrupts      */
    App_Spurious_ISR,                   /* 43, INTISR[ 27]  TIM2 Global Interrupt                      */
    App_Spurious_ISR,                   /* 44, INTISR[ 28]  TIM3 Global Interrupt                      */
    App_Spurious_ISR,                   /* 45, INTISR[ 29]  TIM4 Global Interrupt                      */
    App_Spurious_ISR,                   /* 46, INTISR[ 30]  I2C1 Event  Interrupt                      */
    App_Spurious_ISR,                   /* 47, INTISR[ 31]  I2C1 Error  Interrupt                      */
    App_Spurious_ISR,                   /* 48, INTISR[ 32]  I2C2 Event  Interrupt                      */
    App_Spurious_ISR,                   /* 49, INTISR[ 33]  I2C2 Error  Interrupt                      */
    App_Spurious_ISR,                   /* 50, INTISR[ 34]  SPI1 Global Interrupt                      */
    App_Spurious_ISR,                   /* 51, INTISR[ 35]  SPI2 Global Interrupt                      */
    ProbeRS232_RxTxISRHandler,          /* 52, INTISR[ 36]  USART1 Global Interrupt                    */
    ProbeRS232_RxTxISRHandler,          /* 53, INTISR[ 37]  USART2 Global Interrupt                    */
    App_Spurious_ISR,                   /* 54, INTISR[ 38]  USART3 Global Interrupt                    */
    App_Spurious_ISR,                   /* 55, INTISR[ 39]  EXTI Line [15:10] Interrupts               */
    App_Spurious_ISR,                   /* 56, INTISR[ 40]  RTC Alarm through EXT Line Interrupt       */
    App_Spurious_ISR,                   /* 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  */
};
中断跳转到
static  void  App_Spurious_ISR (void) @ "ICODE"
{
    while (1) {
       LED_On(1)  ;
    }
}
我用的EXTI_Line0中断
中断能产生   但是我怎么判断是EXTI_Line0中断呢  有很多中断都跳到这个里面

使用特权

评论回复
地板
静默| | 2008-6-11 12:33 | 只看该作者

你再试试

定义一个中断服务程序过程, 定义方法您参考 OSPendSV, Tmr_TickISR_Handler
例:YourExtiLine0_ISR

App_Spurious_ISR,                   /* 22, INTISR[  6]  EXTI Line0 Interrupt                       */
把上面这行改成 
YourExtiLine0_ISR,                   /* 22, INTISR[  6]  EXTI Line0 Interrupt                       */
 
你再试试。

使用特权

评论回复
5
dkill|  楼主 | 2008-6-11 13:21 | 只看该作者

谢谢楼上

但是还有一事不明  
我改了程序
   void  App_Spurious_ISR1 (void) //@ "ICODE"
{   OS_CPU_SR  cpu_sr;


    OS_ENTER_CRITICAL();                                             OSIntNesting++;
    OS_EXIT_CRITICAL();
   
      LED_On(0) ;
      OSIntExit(); 
 
}
可以正常进入 点亮led
  但是为什么一直在里面 退不出去
还有第一次运行 会自己直接进入中断  复位一次就好了
  

使用特权

评论回复
6
dkill|  楼主 | 2008-6-11 15:17 | 只看该作者

中断退不出来问题找到了

但是为什么一运行 就进入中断呢  复位一次  就没事了了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

62

主题

201

帖子

0

粉丝