scale/1000; // this is the first digit
(scale % 1000)/100; // this is the second digit
(scale % 100)/10; // this is the decimal
still confuse in using two different interrupts in same code with same ISR vactor?
void init_Ex2(void)
{
TIMSK|=(1<<TOIE1); // enabled global and timer overflow interrupt;
TCCR1A = 0x00; // normal operation page 148 (mode0);
TCNT1=0x0000; // 16bit counter register
TCCR1B = 0x03; // start timer/ set clock
sei();//Enable Global Interrupts
}
ISR(TIMER1_OVF_vect) {
if(!(PINC&(1<<PINC1))&&(PINC&(1<<PINC2))){PORTB=(1<<PB0);SEVEN_SEGMENT_PORT=values[10];}
}
void init_Ex1(void)
{
TCCR0=0x02; // Prescaler = FCPU/1024
TIMSK|=(1<<TOIE0); //Enable Overflow Interrupt Enable
TCNT0=0; //Initialize Counter
sei();//Enable Global Interrupts
}
ISR(TIMER0_OVF_vect) //ISR rutine for sevensegment
{
var1=scale;
if (show_digit==0)
{
// write code to show digit 1
num1=scale%10; // this is the first digit
PORTB=(0<<PB0)|(0<<PB1)|(0<<PB2)|(0<<PB3)|(1<<PB4); // Turning ON Units place of display
SEVEN_SEGMENT_PORT=values[num1]; // Writing corresponding number on Units place
// _delay_us(450);//rt delay
}
else if (show_digit==1)
{
// write code to show digit 2
num2=(scale % 100)/10 ;
PORTB=(0<<PB0)|(0<<PB1)|(0<<PB2)|(1<<PB3)|(0<<PB4); // Turning ON Tens place and Turning OFF Units place of seconds
SEVEN_SEGMENT_PORT=values[num2]+0x80; // Writing corresponding number on Tens place
// _delay_us(450);// Short delay
}
else if (show_digit==2)
{
// write code to show digit 3
num3=(scale % 1000)/100;
PORTB=(0<<PB0)|(0<<PB1)|(1<<PB2)|(0<<PB3)|(0<<PB4); // Turning ON Units place of minutes // Turning ON Units place of minutes
SEVEN_SEGMENT_PORT=values[num3]; // Writing corresponding number on Units place of minutes
// _delay_us(450);
}
else if (show_digit==3)//&&(!(PINC&(1<<PINC1))))
{
PORTB=(0<<PB0)|(1<<PB1)|(0<<PB2)|(0<<PB3)|(0<<PB4); // Turning ON Units place of minutes
// Turning ON Tens place and Turning OFF Units place of minutes
num4=scale/1000;
SEVEN_SEGMENT_PORT=values[num4]; // Writing corresponding number on Tens place of minutes
// _delay_us(450);//
}
else if (show_digit==4)
//show_digit=0; // after showing the third digit restart
{
PORTB=(1<<PB0)|(0<<PB1)|(0<<PB2)|(0<<PB3)|(0<<PB4);
SEVEN_SEGMENT_PORT=values[0];
}
if(++show_digit==5) show_digit=0;
}
if(!(PINC&(1<<PINC1))&&(PINC&(1<<PINC2)))//this condition for switch pressed at PinC1
else if(!(PINC&(1<<PINC2))&&(PINC&(1<<PINC1)))//this condition is for switch pressed at PINC2
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 #define CHECKBIT(ADDRESS,BIT) (ADDRESS & (1<<BIT)) ISR(TIMER1_OVF_vect) { if(!CHECKBIT(PINC,1)) { // PINC1 state is 0 this condition for switch pressed at PinC1 } else if(!CHECKBIT(PINC,2)) { // PINC2 state is 0 this condition is for switch pressed at PINC2 } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?