打印
[STM8]

关于STM8 中断问题

[复制链接]
2005|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lsj19851118|  楼主 | 2013-1-22 21:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
小弟这两天在调试串口通讯,采用定时中断接收,可是在设置中断后即开总中断“rim”后,下载程序重新上电后,单片机好长时间才能执行发送程序,如果把中断关了以后,就可一上电就发送字符。
程序大概是这样的:
   main()
{
int();
_asm("rim");
while(1){
   send(data);  
}
}
如果把 _asm("rim");
语句屏蔽后,程序一上电就可以正常发送,如果不屏蔽的话,单片机上电后大概得等个1分钟左右才能发出数据,哪位大侠遇见过这种情况后,帮忙解释一下。
沙发
uet_cache| | 2013-1-23 10:29 | 只看该作者
采用定时中断接收?什么意思,什么叫定时中断,,,

你的SEND函数里面是什么,,,怎么不加点延时,不怕硬件响应不过来吗?

使用特权

评论回复
板凳
lsj19851118|  楼主 | 2013-1-23 21:42 | 只看该作者
嘿嘿 写错了  是定时发送  中断接收,原本程序上是有延时的   在开全局中断的情况下就是一上电吧  单片机就进入到下面的中断函数中
@far @interrupt void NonHandledInterrupt (void)
{
       /* in order to detect unexpected events during development,
          it is recommended to set a breakpoint on the following instruction
       */
       return;
}
extern void _stext();     /* startup routine */

struct interrupt_vector const _vectab[] = {
       {0x82, (interrupt_handler_t)_stext}, /* reset */
       {0x82, NonHandledInterrupt}, /* trap  */
       {0x82, NonHandledInterrupt}, /* irq0  */
       {0x82, NonHandledInterrupt}, /* irq1  */
       {0x82, NonHandledInterrupt}, /* irq2  */
       {0x82, NonHandledInterrupt}, /* irq3  */
       {0x82, NonHandledInterrupt}, /* irq4  */
       {0x82, NonHandledInterrupt}, /* irq5  */
       {0x82, NonHandledInterrupt}, /* irq6  */
       {0x82, NonHandledInterrupt}, /* irq7  */
       {0x82, NonHandledInterrupt}, /* irq8  */
       {0x82, NonHandledInterrupt}, /* irq9  */
       {0x82, NonHandledInterrupt}, /* irq10 */
       {0x82, NonHandledInterrupt}, /* irq11 */
       {0x82, NonHandledInterrupt}, /* irq12 */
       {0x82, NonHandledInterrupt}, /* irq13 */
       {0x82, NonHandledInterrupt}, /* irq14 */
       {0x82, NonHandledInterrupt}, /* irq15 */
       {0x82, NonHandledInterrupt}, /* irq16 */
       {0x82, NonHandledInterrupt}, /* irq17 */
       {0x82, NonHandledInterrupt}, /* irq18 */
       {0x82, NonHandledInterrupt}, /* irq19 */
       {0x82, NonHandledInterrupt}, /* irq20 */
       {0x82, NonHandledInterrupt}, /* irq21 */
       {0x82, NonHandledInterrupt}, /* irq22 */
       {0x82, NonHandledInterrupt}, /* irq23 */
       {0x82, NonHandledInterrupt}, /* irq24 */
       {0x82, NonHandledInterrupt}, /* irq25 */
       {0x82, NonHandledInterrupt}, /* irq26 */
       {0x82, NonHandledInterrupt}, /* irq27 */
       {0x82, NonHandledInterrupt}, /* irq28 */
       {0x82, NonHandledInterrupt}, /* irq29 */
};

使用特权

评论回复
地板
jgphu| | 2013-1-25 16:40 | 只看该作者
楼上的, 这叫中断向量函数的入口地址 。 你如果是中断接收,你要把你的中断服务函数名添加进来

使用特权

评论回复
5
lsj19851118|  楼主 | 2013-1-27 11:44 | 只看该作者
问题找到了  是我将其中的一个I/O口作为外设中断,而且是悬浮输入了,所以每次上电初始化都会进入那个中断

使用特权

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

本版积分规则

5

主题

15

帖子

1

粉丝