打印
[AVR单片机]

求救AVR不可以在中断函数里改变变量的值么

[复制链接]
1138|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hzs5281|  楼主 | 2013-7-31 00:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#define F_CPU 8000000UL
#include<avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
//#include "LCD12864.c"

char i=1,j=1;
int main()
{


  DDRA=0XFF;
  DDRD=0x00;
  PORTD=0Xff;
  MCUCR=0x08;
  GICR=0xc0;
  sei();

//  Lcd_Initi();//
//  _delay_ms(300);
//  Lcd_Clear(); _delay_ms(100);
while(1)
{

// Lcd_Str(1,1,"胜-Johnson");
//  Lcd_Num(2,1,i);
//  Lcd_Num(2,5,j);
//   k=~((i<<4)+j);
   PORTA=i*16+j;
   _delay_ms(300);
//   i++;j++;
}
}

ISR(INT0_vect)
{
  i++;
}

ISR(INT1_vect)
{
j++;

}
以上是代码,可是i,j并没有变啊,求解!!

相关帖子

沙发
netcattle| | 2013-7-31 11:40 | 只看该作者
用volatile修饰i,j试试

使用特权

评论回复
板凳
hzs5281|  楼主 | 2013-8-2 16:32 | 只看该作者
netcattle 发表于 2013-7-31 11:40
用volatile修饰i,j试试

可以了,谢谢:)

使用特权

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

本版积分规则

1

主题

3

帖子

0

粉丝