打印

用移植到stm32的ucos写串口中断为什么一直死机

[复制链接]
10256|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
高密度|  楼主 | 2008-6-26 11:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用移植到stm32的ucos写串口中断为什么一直死机啊,研究快两天了,请大侠指点一二。谢谢


中断处理函数

void USART1_IRQHandler(void)
{
    OS_CPU_SR  cpu_sr;
UCOS_II_REENTRANT_ISR_PROLOG UCOS_II_REENTRANT_ISR_EPILOG
    OS_ENTER_CRITICAL();;                                       
    OSIntNesting++;
   OS_EXIT_CRITICAL();
         
  if(USART_GetITStatus(USART1, USART_IT_RXNE) == SET)
  {

     data = (USART_ReceiveData(USART1) & 0x7F); 
     USART_ClearITPendingBit(USART1, USART_IT_RXNE);    
       
  }
    OSIntExit();
  
}

向量表

;******************************************************************************
;
;                             INTERRUPT VECTORS
;                                    ARM
;                             KEIL's uVision3 
;                   (RealView Microprocessor Developer Kit)
;
; Filename      : vectors.s
;******************************************************************************

                PRESERVE8
                AREA   VECT, CODE, READONLY                     ; Name this block of code                                   ;
                THUMB

                ENTRY

;******************************************************************************
;                                  IMPORTS
;******************************************************************************

                IMPORT    Tmr_TickISR_Handler
;                IMPORT  ProbeRS232_RxTxISRHandler
                IMPORT    USART1_IRQHandler
            
                IMPORT    OSPendSV
                IMPORT  ResetHndlr
                IMPORT  ||Image$$ARM_LIB_STACK$$ZI$$Limit||     ; Import stack limit from scatter-loading file              ;

;******************************************************************************
;                                  EXPORTS
;******************************************************************************
                ;EXPORT    USART1_IRQHandler
;******************************************************************************
;                                DEFINITIONS
;******************************************************************************


;******************************************************************************
;                      INITIALIZE EXCEPTION VECTORS
;******************************************************************************

Vectors
        DCD     ||Image$$ARM_LIB_STACK$$ZI$$Limit||         ;  0, SP start value.                                         
        DCD     ResetHndlr                                  ;  1, PC start value.                                         
        DCD     App_NMI_ISR                                 ;  2, NMI                                                     
        DCD     App_Fault_ISR                               ;  3, Hard Fault                                              
        DCD     App_Spurious_ISR                            ;  4, Memory Management                                      
        DCD     App_Spurious_ISR                            ;  5, Bus Fault                                               
        DCD     App_Spurious_ISR                            ;  6, Usage Fault                                             
        DCD     0                                           ;  7, Reserved                                                
        DCD     0                                           ;  8, Reserved                                                
        DCD     0                                           ;  9, Reserved                                                
        DCD     0                                           ; 10, Reserved                                                
        DCD     App_Spurious_ISR                            ; 11, SVCall                                                  
        DCD     App_Spurious_ISR                            ; 12, Debug Monitor                                           
        DCD     App_Spurious_ISR                            ; 13, Reserved                                                
        DCD     OSPendSV                                    ; 14, PendSV Handler                                          
        DCD     Tmr_TickISR_Handler                         ; 15, uC/OS-II Tick ISR Handler                               
        DCD     App_Spurious_ISR                            ; 16, INTISR[  0], Window Watchdog                            
        DCD     App_Spurious_ISR                            ; 17, INTISR[  1]  PVD through EXTI Line Detection            
        DCD     App_Spurious_ISR                            ; 18, INTISR[  2]  Tamper Interrupt                           
        DCD     App_Spurious_ISR                            ; 19, INTISR[  3]  RTC Global Interrupt                       
        DCD     App_Spurious_ISR                            ; 20, INTISR[  4]  FLASH Global Interrupt                     
        DCD     App_Spurious_ISR                            ; 21, INTISR[  5]  RCC Global Interrupt                       
        DCD     App_Spurious_ISR                            ; 22, INTISR[  6]  EXTI Line0 Interrupt                       
        DCD     App_Spurious_ISR                            ; 23, INTISR[  7]  EXTI Line1 Interrupt                       
        DCD     App_Spurious_ISR                            ; 24, INTISR[  8]  EXTI Line2 Interrupt                       
        DCD     App_Spurious_ISR                            ; 25, INTISR[  9]  EXTI Line3 Interrupt                       
        DCD     App_Spurious_ISR                            ; 26, INTISR[ 10]  EXTI Line4 Interrupt                       
        DCD     App_Spurious_ISR                            ; 27, INTISR[ 11]  DMA Channel1 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 28, INTISR[ 12]  DMA Channel2 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 29, INTISR[ 13]  DMA Channel3 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 30, INTISR[ 14]  DMA Channel4 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 31, INTISR[ 15]  DMA Channel5 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 32, INTISR[ 16]  DMA Channel6 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 33, INTISR[ 17]  DMA Channel7 Global Interrupt              
        DCD     App_Spurious_ISR                            ; 34, INTISR[ 18]  ADC Global Interrupt                       
        DCD     App_Spurious_ISR                            ; 35, INTISR[ 19]  USB High Priority / CAN TX  Interrupts     
        DCD     App_Spurious_ISR                            ; 36, INTISR[ 20]  USB Low  Priority / CAN RX0 Interrupts     
        DCD     App_Spurious_ISR                            ; 37, INTISR[ 21]  CAN RX1 Interrupt                          
        DCD     App_Spurious_ISR                            ; 38, INTISR[ 22]  CAN SCE Interrupt                          
        DCD     App_Spurious_ISR                            ; 39, INTISR[ 23]  EXTI Line[9:5] Interrupt                   
        DCD     App_Spurious_ISR                            ; 40, INTISR[ 24]  TIM1 Break  Interrupt                      
        DCD     App_Spurious_ISR                            ; 41, INTISR[ 25]  TIM1 Update Interrupt                      
        DCD     App_Spurious_ISR                            ; 42, INTISR[ 26]  TIM1 Trigger & Commutation Interrupts      
        DCD     App_Spurious_ISR                            ; 43, INTISR[ 27]  TIM2 Global Interrupt                      
        DCD     App_Spurious_ISR                            ; 44, INTISR[ 28]  TIM3 Global Interrupt                      
        DCD     App_Spurious_ISR                            ; 45, INTISR[ 29]  TIM4 Global Interrupt                      
        DCD     App_Spurious_ISR                            ; 46, INTISR[ 30]  I2C1 Event  Interrupt                      
        DCD     App_Spurious_ISR                            ; 47, INTISR[ 31]  I2C1 Error  Interrupt                      
        DCD     App_Spurious_ISR                            ; 48, INTISR[ 32]  I2C2 Event  Interrupt                      
        DCD     App_Spurious_ISR                            ; 49, INTISR[ 33]  I2C2 Error  Interrupt                      
        DCD     App_Spurious_ISR                            ; 50, INTISR[ 34]  SPI1 Global Interrupt                      
        DCD     USART1_IRQHandler                             ; 51, INTISR[ 35]  SPI2 Global Interrupt                      
        DCD     App_Spurious_ISR                     ; 52, INTISR[ 36]  USART1 Global Interrupt                    
        DCD     App_Spurious_ISR                   ; 53, INTISR[ 37]  USART2 Global Interrupt                    
        DCD     App_Spurious_ISR                            ; 54, INTISR[ 38]  USART3 Global Interrupt                    
        DCD     App_Spurious_ISR                            ; 55, INTISR[ 39]  EXTI Line [15:10] Interrupts               
        DCD     App_Spurious_ISR                            ; 56, INTISR[ 40]  RTC Alarm through EXT Line Interrupt       
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        DCD     App_Spurious_ISR                            ; 57, INTISR[ 41]  USB Wakeup from Suspend through EXTI Int.  
        
        
;******************************************************************************
;                          DEFAULT HANDLERS
;******************************************************************************

App_NMI_ISR         B       App_NMI_ISR

App_Fault_ISR       B       App_Fault_ISR

App_Spurious_ISR    B       App_Spurious_ISR

                ALIGN
                END
沙发
高密度|  楼主 | 2008-6-26 11:56 | 只看该作者

中断处理函数是这个

void USART1_IRQHandler(void)
{
    OS_CPU_SR  cpu_sr;

    OS_ENTER_CRITICAL();;                                       
    OSIntNesting++;
   OS_EXIT_CRITICAL();
         
  if(USART_GetITStatus(USART1, USART_IT_RXNE) == SET)
  {

     data = (USART_ReceiveData(USART1) & 0x7F); 
     USART_ClearITPendingBit(USART1, USART_IT_RXNE);    
       
  }
    OSIntExit();
  
}

使用特权

评论回复
板凳
香水城| | 2008-6-26 11:58 | 只看该作者

移植错误或使用错误

我不会uCOS,帮不上忙

使用特权

评论回复
地板
高密度|  楼主 | 2008-6-26 12:52 | 只看该作者

那也谢谢香哥了。现在我感觉是中断处理函数没有问题

应该是向量表不对
个人感觉

使用特权

评论回复
5
cpufan| | 2008-6-26 13:48 | 只看该作者

换 st demo中的向量表试试看

使用特权

评论回复
6
高密度|  楼主 | 2008-6-26 14:00 | 只看该作者

那样编译就通不过了,你看我改的vectors.s文件有问题吗?

使用特权

评论回复
7
dy008| | 2008-6-26 15:01 | 只看该作者

cortexM3使用uCos中的中断问题!

ucos的cortexm3移植模板均没有设置NVIC的优先级分组,使用的是默认级别,
当用户添加自己中断服务时应该将Tmr_TickISR_Handler调为最高,OSPendSV调为最低,自己的中断服务处于中间即可!

使用特权

评论回复
8
jtingwang| | 2008-6-26 17:43 | 只看该作者

前面是UART?后面是SPI?

DCD     USART1_IRQHandler                             ; 51, INTISR[ 35]  SPI2 Global Interrupt

使用特权

评论回复
9
anzil| | 2010-3-26 10:30 | 只看该作者
你这个中断处理程序只是接收中断处理,不是写中断。如果是写中断的话,只要你设置写中断允许,因为此时串口发送寄存器这时候本身就是空的,所以系统就会马上进到你现在的中断处理函数中,而你又没有对写中断做处理,系统就会死机。

使用特权

评论回复
10
yemingxp| | 2010-9-29 10:51 | 只看该作者
你这个中断处理程序只是接收中断处理,不是写中断。如果是写中断的话,只要你设置写中断允许,因为此时串口发送寄存器这时候本身就是空的,所以系统就会马上进到你现在的中断处理函数中,而你又没有对写中断做处理, ...
anzil 发表于 2010-3-26 10:30


是不是答非所问了?别人没见开了写中断,哪有你说的情况?!

使用特权

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

本版积分规则

2

主题

10

帖子

0

粉丝