This is a atmega128 source to make a clock using the timer interrupt. I want to...

60.1K

Verified Solution

Question

Electrical Engineering

This is a atmega128 source to make a clock using thetimer interrupt. I want to add source if i press switch(PIND==0x0FE&&PIND==0x0FD) then below program would berunning .

#include
intposition=0,BJT[4]={0xFE,0xFD,0xFB,0xF7};
intnumber=0,segment[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
int msec=0, sec=0, min=0;
void main()
{
DDRA=0xFF;
PORTA=0XFF;
DDRB=0xFF;
PORTB=0xFF;
TCCR0=0x04;
TIMSK=0x01;
SREG=0x80;
while(1){}
}
interrupt[TIM0_OVF]void timer0_ovf_isr()
{
TCNT0=0x06;
PORTA=BJT[position];
if(position==0)number=sec%10;
if(position==1)number=sec/10;
if(position==2)number=min%10;
if(postion==3)number=min/10;
PORTB=segment[number];
position++;
if(position>3)position=0;
msec++;
if(msec==1000)
{
msec=0;
sec++;
}
if(sec==60)
{
sec=0;
min++;
}
if(min==60)min=0;
}


Answer & Explanation Solved by verified expert
4.2 Ratings (704 Votes)
Generating 10 ms delay pulse on PORTB using ATmega128 Timer interrupt include include timer0 overflow interrupt ISRTIMER0OVFvect PORTBPORTB    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students