控制器在忙时收到数据
Controller received data whilst busy
我正在尝试在 proteus 的代码视觉中使用中断。 INT0 用于增加计数器值,INT1 用于减少它。为此,我声明了两个函数 interrupt [EXT_INT0] void ext_int0_isr(void)
和 interrupt [EXT_INT1] void ext_int1_isr(void)
,但是当我 运行 代码不起作用时,我在 proteus 中收到无限警告“控制器在忙碌时收到数据”。如果你能帮助我,我将不胜感激。
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
#include <delay.h>
int i = 0 ;
int j = 0 ;
char number[16];
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
#asm("cli")// Global disable interrupts
i++;
//go to products counting
if(i < 10) goto ENTERED;
//go to products packaging process
if(i >= 11)
{
lcd_clear();
lcd_gotoxy(2,0);
lcd_putsf("Products Are");
for (j=0; j < 10; j++)
{
lcd_gotoxy(1,1);
lcd_putsf("Being Packaged.");
delay_ms(500);
lcd_gotoxy(1,1);
lcd_putsf("Being ");
delay_ms(500);
}
}
i=1;
ENTERED:
if(i < 11)
{
sprintf(number,"Number Of People=%d \n (one Entered)",i);
}
}
// External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isr(void)
{
#asm("cli")// Global disable interrupts
i--;
//go to products counting
if(i < 11) goto WENTOUT;
//go to products packaging process
if(i >= 11)
{
lcd_clear();
lcd_gotoxy(2,0);
lcd_putsf("Products Are");
for (j=0; j < 10; j++)
{
lcd_gotoxy(1,1);
lcd_putsf("Being Packaged.");
delay_ms(500);
lcd_gotoxy(1,1);
lcd_putsf("Being ");
delay_ms(500);
}
}
i=1;
WENTOUT:
if(i < 11)
{
sprintf(number,"Number Of People=%d \n (one went out)",i);
}
}
void main(void)
{
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
GICR|=(1<<INT1) | (1<<INT0) | (0<<INT2);
MCUCR=(1<<ISC11) | (0<<ISC10) | (1<<ISC01) | (0<<ISC00);
MCUCSR=(0<<ISC2);
GIFR=(1<<INTF1) | (1<<INTF0) | (0<<INTF2);
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTA Bit 0
// RD - PORTA Bit 1
// EN - PORTA Bit 2
// D4 - PORTA Bit 4
// D5 - PORTA Bit 5
// D6 - PORTA Bit 6
// D7 - PORTA Bit 7
// Characters/line: 16
lcd_init(16);
sprintf(number,"Number Of People=%d",i);
while (1)
{
lcd_gotoxy(4,0);
lcd_puts(number);
#asm("sei")// Global enable interrupts
delay_ms(50);
lcd_clear();
}
}
问题是我试图放入 LCD 的字符串长度超过了 LCD 的容量,在我缩短字符串后问题就解决了。
我正在尝试在 proteus 的代码视觉中使用中断。 INT0 用于增加计数器值,INT1 用于减少它。为此,我声明了两个函数 interrupt [EXT_INT0] void ext_int0_isr(void)
和 interrupt [EXT_INT1] void ext_int1_isr(void)
,但是当我 运行 代码不起作用时,我在 proteus 中收到无限警告“控制器在忙碌时收到数据”。如果你能帮助我,我将不胜感激。
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
#include <delay.h>
int i = 0 ;
int j = 0 ;
char number[16];
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
#asm("cli")// Global disable interrupts
i++;
//go to products counting
if(i < 10) goto ENTERED;
//go to products packaging process
if(i >= 11)
{
lcd_clear();
lcd_gotoxy(2,0);
lcd_putsf("Products Are");
for (j=0; j < 10; j++)
{
lcd_gotoxy(1,1);
lcd_putsf("Being Packaged.");
delay_ms(500);
lcd_gotoxy(1,1);
lcd_putsf("Being ");
delay_ms(500);
}
}
i=1;
ENTERED:
if(i < 11)
{
sprintf(number,"Number Of People=%d \n (one Entered)",i);
}
}
// External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isr(void)
{
#asm("cli")// Global disable interrupts
i--;
//go to products counting
if(i < 11) goto WENTOUT;
//go to products packaging process
if(i >= 11)
{
lcd_clear();
lcd_gotoxy(2,0);
lcd_putsf("Products Are");
for (j=0; j < 10; j++)
{
lcd_gotoxy(1,1);
lcd_putsf("Being Packaged.");
delay_ms(500);
lcd_gotoxy(1,1);
lcd_putsf("Being ");
delay_ms(500);
}
}
i=1;
WENTOUT:
if(i < 11)
{
sprintf(number,"Number Of People=%d \n (one went out)",i);
}
}
void main(void)
{
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
GICR|=(1<<INT1) | (1<<INT0) | (0<<INT2);
MCUCR=(1<<ISC11) | (0<<ISC10) | (1<<ISC01) | (0<<ISC00);
MCUCSR=(0<<ISC2);
GIFR=(1<<INTF1) | (1<<INTF0) | (0<<INTF2);
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTA Bit 0
// RD - PORTA Bit 1
// EN - PORTA Bit 2
// D4 - PORTA Bit 4
// D5 - PORTA Bit 5
// D6 - PORTA Bit 6
// D7 - PORTA Bit 7
// Characters/line: 16
lcd_init(16);
sprintf(number,"Number Of People=%d",i);
while (1)
{
lcd_gotoxy(4,0);
lcd_puts(number);
#asm("sei")// Global enable interrupts
delay_ms(50);
lcd_clear();
}
}
问题是我试图放入 LCD 的字符串长度超过了 LCD 的容量,在我缩短字符串后问题就解决了。