打印
[其他ST产品]

str710串口中断的问题

[复制链接]
3405|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
godzy|  楼主 | 2007-5-28 16:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在调试串口中断时发现串口中断进不去,配合单步调试,发现EIC_IRQConfig(ENABLE);后程序就飞跑了。程序如下:
GPIO_Config(GPIO0, UARTX_T1_Pin, GPIO_AF_PP);
GPIO_Config(GPIO0, UARTX_R1_Pin, GPIO_IN_TRI_CMOS);
    // Configure the UART X
UART_OnOffConfig(UART1, ENABLE);        // Turn UARTX on
UART_FifoConfig(UART1, DISABLE);        // Disable FIFOs
UART_FifoReset(UART1, UART_RxFIFO);        // Reset the UART_RxFIFO
UART_FifoReset(UART1, UART_TxFIFO);        // Reset the UART_TxFIFO
UART_LoopBackConfig(UART1, DISABLE);    // Disable Loop Back
/* Configure the UART1 as following:
            - Baudrate = 9600 Bps
            - No parity
            - 8 data bits
            - 1 stop bit */
UART_Config(UART1, 9600, UART_NO_PARITY, UART_1_StopBits, UARTM_8D);
UART_RxConfig(UART1, ENABLE);          // Enable Rx
UART_StringSend(UART1, (u8 *)"Hello, UART0! ");//sends a string to UARTX

          /* Configure the EIC channel interrupt */
      EIC_IRQChannelPriorityConfig(UART1_IRQChannel, 3);
      EIC_IRQChannelConfig(UART1_IRQChannel, ENABLE);
      EIC_IRQConfig(ENABLE);
      UART_ItConfig(UARTX,UART_RxBufFull, ENABLE);
初学,请指教。
沙发
godzy|  楼主 | 2007-5-28 17:45 | 只看该作者

补充一下,是在ram中调试

使用特权

评论回复
板凳
godzy|  楼主 | 2007-5-29 09:23 | 只看该作者

EIC_IRQConfig(ENABLE);之后就异常了

单步调试发现执行EIC_IRQConfig(ENABLE)后,cpsr的i标志位是置为了,但是cpu模式也跟着由sys模式变成irq模式了,也就是说一开irq中断就进入中断模式了,问题是除了串口中断我就没有开其他中断了,而且也没有发任何数据给串口,怎么会进irq模式的呢?

使用特权

评论回复
地板
ST_ARM| | 2007-5-29 10:10 | 只看该作者

初始化代码没有问题

你把这段代码先去掉,试一下;
UART_StringSend(UART1, (u8 *)"Hello, UART0! ");//sends a string to UARTX。
另外,你在RAM中查看一下0x20000000到0x20000040里的内容,尤其是0x20000018、0x20000038,同时检查一下
;*******************************************************************
;* Function Name  : IRQHandler
;* Description    : This function called when IRQ exception is entered.
;* Input          : none
;* Output         : none
;*******************************************************************
IRQHandler   ------ 它的地址。

使用特权

评论回复
5
godzy|  楼主 | 2007-5-29 16:58 | 只看该作者

发现问题所在

串口发送没有问题,因为不涉及中断。
原来RO:0x20000000,RW:空着,下载到ram调试的。
现在RO:0x0,RW:0x20000000,下载到flash调试就OK了。
也就是在ram启动模式下载,无法进入中断,估计是remap方面的问题,有待进一步研究。
没改动前:
225    ;*******************************************************************************
226    ;* Function Name  : IRQHandler
227    ;* Description    : This function called when IRQ exception is entered.
228    ;* Input          : none
229    ;* Output         : none
230    ;*******************************************************************************
231    
232    IRQHandler
233            SUB    lr,lr,#4       ; Update the link register
IRQHandler    [0xe24ee004]   sub      r14,r14,#4
234            SaveContext r0,r12    ; Save the workspace plus the current
200000fc    [0xe92d5fff]   stmfd    r13!,{r0-r12,r14}
20000100    [0xe14f1000]   mrs      r1,spsr
20000104    [0xe92d0002]   stmfd    r13!,{r1}
235                                  ; return address lr_ irq and spsr_irq.
236            LDR    lr, =ReturnAddress ; Read the return address.
20000108    [0xe59fe310]   ldr      r14,0x20000420 ; = #0x20000118
237            LDR    r0, =EIC_base_addr
2000010c    [0xe59f0310]   ldr      r0,0x20000424 ; = #0xfffff800
238            LDR    r1, =IVR_off_addr
20000110    [0xe3a01018]   mov      r1,#0x18
239            ADD    pc,r0,r1      ; Branch to the IRQ handler.
20000114    [0xe080f001]   add      pc,r0,r1
240    ReturnAddress
241                                 ; Clear pending bit in EIC (using the proper IPRx)
242            LDR    r0, =EIC_base_addr
ReturnAddress    [0xe59f0304]   ldr      r0,0x20000424 ; = #0xfffff800
243            LDR    r2, [r0, #CICR_off_addr] ; Get the IRQ channel number.
2000011c    [0xe5902004]   ldr      r2,[r0,#4]
244            MOV    r3,#1
20000120    [0xe3a03001]   mov      r3,#1
245            MOV    r3,r3,LSL r2
20000124    [0xe1a03213]   mov      r3,r3,lsl r2
246            STR    r3,[r0, #IPR_off_addr]   ; Clear the corresponding IPR bit.
20000128    [0xe5803040]   str      r3,[r0,#0x40]
247            RestoreContext r0,r12  ; Restore the context and return to the...
2000012c    [0xe8bd0002]   ldmfd    r13!,{r1}
20000130    [0xe16ff001]   msr      spsr_cxsf,r1
20000134    [0xe8fd9fff]   ldmfd    r13!,{r0-r12,pc}^
248                                   ; ...program execution.
249    

使用特权

评论回复
6
godzy|  楼主 | 2007-5-29 17:03 | 只看该作者

0x20000000到0x20000040里的内容

96    ;*******************************************************************************
97    ;                        Exception vectors
98    ;*******************************************************************************
99    
100            LDR     PC, Reset_Addr
vector_begin    [0xe59ff018]   ldr      pc,Reset_Addr ; = #Reset_Addr
101            LDR     PC, Undefined_Addr
20000004    [0xe59ff018]   ldr      pc,Undefined_Addr ; = #Undefined_Addr
102            LDR     PC, SWI_Addr
20000008    [0xe59ff018]   ldr      pc,SWI_Addr ; = #SWI_Addr
103            LDR     PC, Prefetch_Addr
2000000c    [0xe59ff018]   ldr      pc,Prefetch_Addr ; = #Prefetch_Addr
104            LDR     PC, Abort_Addr
20000010    [0xe59ff018]   ldr      pc,Abort_Addr ; = #Abort_Addr
105            NOP                             ; Reserved vector
20000014    [0xe1a00000]   nop      
106            LDR     PC, IRQ_Addr
20000018    [0xe59ff018]   ldr      pc,IRQ_Addr ; = #IRQ_Addr
107            LDR     PC, FIQ_Addr
2000001c    [0xe59ff018]   ldr      pc,FIQ_Addr ; = #FIQ_Addr
108    
109    ;*******************************************************************************
110    ;               Exception handlers address table
111    ;*******************************************************************************
112    
113    Reset_Addr      DCD     Reset_Handler
Reset_Addr    [0x2000133c]   dcd      0x2000133c  <.. 
114    Undefined_Addr  DCD     UndefinedHandler
Undefined_Addr    [0x200000c0]   dcd      0x200000c0  ... 
115    SWI_Addr        DCD     SWIHandler
SWI_Addr    [0x200000dc]   dcd      0x200000dc  ... 
116    Prefetch_Addr   DCD     PrefetchAbortHandler
Prefetch_Addr    [0x20000138]   dcd      0x20000138  8.. 
117    Abort_Addr      DCD     DataAbortHandler
Abort_Addr    [0x20000158]   dcd      0x20000158  X.. 
118                    DCD     0               ; Reserved vector
20000034    [0x00000000]   dcd      0x00000000  ....
119    IRQ_Addr        DCD     IRQHandler
IRQ_Addr    [0x200000f8]   dcd      0x200000f8  ... 
120    FIQ_Addr        DCD     FIQHandler
FIQ_Addr    [0x20000178]   dcd      0x20000178  x.. 
121    

使用特权

评论回复
7
godzy|  楼主 | 2007-5-29 17:10 | 只看该作者

从汇编中来看没有什么问题啊

******************************
106            LDR     PC, IRQ_Addr
20000018    [0xe59ff018]   ldr      pc,IRQ_Addr ; = #IRQ_Addr
*******************************
232    IRQHandler
233            SUB    lr,lr,#4       ; Update the link register
IRQHandler    [0xe24ee004]   sub      r14,r14,#4
234            SaveContext r0,r12    ; Save the workspace plus the current
200000fc    [0xe92d5fff]   stmfd    r13!,{r0-r12,r14}
*********************************************
从上面来看,irq中断向量地址以及irq中断子程序地址由没什么问题。
不知道是不是跟仿真器有关,我用的是傅立叶的usb2.0的仿真器,难道它不支持在ram启动模式下调试中断?我改成flash启动模式就可以了。

使用特权

评论回复
8
godzy|  楼主 | 2007-5-29 17:40 | 只看该作者

问题解决了。

原来fft开发板的说明文档关于boot配置的说明有误,boot1与boot0弄反了,害我启动模式老不正确。
不过至少对boot配置这块熟悉许多了。同时感谢ST_ARM,学会了一点分析方法。

使用特权

评论回复
9
creeping| | 2007-6-16 00:03 | 只看该作者

哈哈

是啊,我也用的FFT开发板,幸亏设计之前就发现了他的说明里的配置说明错了
后来对照资料发现的
哈哈哈,在这里看到有人和我一样发现了fft开发板的错误,有些欣慰
握个手!

使用特权

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

本版积分规则

2

主题

10

帖子

0

粉丝