请教LPC2200串口中断发送问题,谢谢!

[复制链接]
2567|2
 楼主| ericli_80 发表于 2007-12-13 13:17 | 显示全部楼层 |阅读模式
我串口初始化程序如下:可是就是无法进入中断发送<br />我已经打开了中断,能进入中断接收数据<br />void&nbsp;Uart0_Init(void)<br />{<br />&nbsp;uint16&nbsp;Fdiv;<br />&nbsp;PINSEL0&nbsp;=&nbsp;(PINSEL0&0xfffffff0)|0x05;&nbsp;//选择串口<br />&nbsp;U0LCR&nbsp;=&nbsp;0x83;<br />&nbsp;Fdiv&nbsp;=&nbsp;(Fpclk/16)/UART_BPS;<br />&nbsp;U0DLM&nbsp;=&nbsp;Fdiv/256;<br />&nbsp;U0DLL&nbsp;=&nbsp;Fdiv%256;<br />&nbsp;U0LCR&nbsp;=&nbsp;0x03;<br /><br />&nbsp;U0FCR&nbsp;&nbsp;=&nbsp;&nbsp;0x01;&nbsp;//接收一个字符<br />&nbsp;U0IER&nbsp;&nbsp;=&nbsp;&nbsp;0x03;&nbsp;//开接收、发送中断&nbsp;&nbsp;&nbsp;<br />&nbsp;VICIntSelect&nbsp;=&nbsp;0x00000000;//设置UART0为IRQ中断,其他中断为IRQ中断<br />&nbsp;VICVectCntl0=0x26;<br />&nbsp;VICVectAddr0&nbsp;=(uint32)Uart0_Receive;<br />&nbsp;VICIntEnable&nbsp;=&nbsp;0x00000040;//UART0使能中断<br />}<br /><br />中断程序<br /><br />void&nbsp;__irq&nbsp;Uart0_Receive(void)<br />{<br />&nbsp;&nbsp;&nbsp;uint8&nbsp;Re;<br /><br />&nbsp;if(U0LSR&0x01)&nbsp;//读取数据<br />&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InBuffer[0]=U0RBR;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;U0IER=0x03;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InFlag=1;<br />&nbsp;}<br />&nbsp;else&nbsp;if(U0LSR&0x20)//发送数据<br />&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;U0THR=0x54;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;U0IER=0x01;<br />&nbsp;}<br />&nbsp;VICVectAddr=0;<br />&nbsp;Re=U0IIR;<br />}<br />
阿南 发表于 2007-12-13 19:36 | 显示全部楼层

没用过LPC2200,不过请问楼主,

串口发送和接收是共用一个中断向量吗?如果是,接收都可以,发送不行,应该只是发送使能的问题吧
armecos 发表于 2007-12-13 21:15 | 显示全部楼层

你这样写程序十分不利于阅读

你这样写程序十分不利于阅读<br /><br />以下仅供参考:(所有程序均在2210调试通过,串口支持中断收发,128字节缓冲)<br /><br />在2200上中断程序应该这样写:<br /><b>第三讲&nbsp;ecos中断操作</b><br /><br />在2200上串口程序应该这样写:<br /><b>第六讲&nbsp;串口操作</b><br /><br />其他请参考:<br /><b>EasyARM2200和SmartARM2200增值软件合集第二版</b><br /><br />另:<br /><b>www.armecos.com</b>上有免费测试程序
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部