Controller received data whilst busy

795 views Asked by At

I am trying to use interrupts in code vision for proteus. INT0 for increasing the counter value and INT1 for decreasing it. for that purpose I declared two funcions interrupt [EXT_INT0] void ext_int0_isr(void) and interrupt [EXT_INT1] void ext_int1_isr(void) but when I run the code it doesn't work and I get the infinite warning "Controller received data whilst busy" in proteus. I'd really appreciate if you could help me.

#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();
      }
}
1

There are 1 answers

0
Benyamin On BEST ANSWER

The problem was that the string's length that I was trying to put in the LCD was more than LCD's capacity and after I shortened the string the problem was solved.