#include

#include

#include


static unsigned char SegNum =

{0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07,

0x7F, 0x6F};

unsigned int i=0;

unsigned int j=0;


ISR (INT4_vect)

{

i++;

if(i>=10)

{

i=0;

j++;

}

PORTC = SegNum[i];

PORTG = 0x01;

_delay_ms(20);

if (j>0)

{

_delay_ms(10);

PORTC = SegNum[j];

PORTG = 0x02;

_delay_ms(10);

}


_delay_ms(20);

while(~PINE & 0x10)

{}

_delay_ms(20);

EIFR = 0x10;

}


ISR (INT5_vect)

{

i--;

if(i

{

i=9;

j--;

}

PORTC = SegNum[i];

PORTG = 0x01;

if (j>0)

{

_delay_ms(10);

PORTC = SegNum[j];

PORTG = 0x02;

_delay_ms(10);

}

_delay_ms(20);

while(~PINE & 0x20)

{}

_delay_ms(20);

EIFR = 0x10;

}


int main(void)

{

DDRC = 0xFF;

DDRG = 0x0F;

DDRE= 0x00;

PORTC = SegNum[i];

PORTG = 0x01;

EIMSK = 0x30;

EICRB = 0x0D;

sei();

while(1)

{

PORTC = SegNum[i];

PORTG = 0x01;

_delay_ms(20);

if (j>0)

{

_delay_ms(10);

PORTC = SegNum[j];

PORTG = 0x02;

_delay_ms(10);

}

}

}



버튼으로 7segment 더하고 빼는 동작인데요

i가 0보다 작을때 10의자리 빼고, 1의자리 9로 만들려고하는데 거기서 작동에 문제가 생기고 있습니다.

i가 1보다 작을때로 설정하면 원하는 동작이 구현되는데 혹시 뭐가 문제인지 알수있을까요?