Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C language, write an initialization subroutine to set up INT1 as falling-

ID: 3573088 • Letter: U

Question

Using C language, write an initialization subroutine to set up INT1 as falling- edge triggered and INT2 as rising-edge triggered interrupt inputs having high priorities. Explain how you can find the source of the interrupt when an interrupt occurs. Write the high priority interrupt subroutine (handler) that turns on the right LED (pin 1 on PORTA) when the interrupt initialized in (a) is coming from INTI and turns on the left LED (pin 3 on PORTA) when it comes from IN 12. An analog -to-digital converter has a positive input reference voltage of 5.0V and is set up for 10-bit conversion. Calculate the resolution of the ADC in millivolts per bit. What is the output code if the input voltage is 2.0V. An LM35DZ type analog temperature sensor is connected to analog port AN0 of

Explanation / Answer

Q 4. Program for initalizing INT1 as falling edge and INT2 as rising edge

#include <stdio.h>
#include <lcd.h>
#asm
.equ __lcd_port=0x1B ;PORTA       //LCD module function
#endasm

volatile bit state1=1;

interrupt [EXT_INT0] void ext_isr_INT0(void) {
   state1=0;
}

interrupt [EXT_INT1] void ext_isr_INT1(void) {
   if (state1) {
       lcd_putsf("^");
   } else {
       state1=1;
   }
}


void main(void) {
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;

PORTD=0x0C;
TCNT0=0x00;
OCR0=0x00;

DDRD=0x80;
TCCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;


//the following code sets INT0 to on andFalling Edge
//it sets INT1 to on and Rising edge
GICR|=0xC0;
MCUCR=0x0E;
MCUCSR=0x00;
GIFR=0xC0;

// Timer initialization for interrupt
TIMSK=0x00;
ACSR=0x80;
SFIOR=0x00;

// LCD module is initialized here
lcd_init(16);

// it enables Global interrupts
#asm("sei")
while (1) {
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote