Download presentation
Presentation is loading. Please wait.
Published bySydney Cooper Modified over 8 years ago
1
GUIDED BY PROFFESOR NILESH DESAI GROUP NO:-8 CHANDRASHIKHA SINGH(13011011009) KURUP SHUBHAM VALSALAN(130110111027) SAURAV SHUBHAM(1301101110050 )
2
In system programming an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code the processor is executing. The processor responds by suspending its current activities, saving its state, and executing a function called an interrupt service routine, ISR to deal with the event. This interruption is temporary, and, after the interrupt handler finishes, the processor resumes normal activities. There are two types of interrupts: hardware interrupts and software interrupts
3
Hardware interrupts are used by devices to communicate that they require attention from the operating system Internally, hardware interrupts are implemented using electronic signal. For example, pressing a key on the keyboard or moving the mouse triggers hardware interrupts that cause the processor to read the keystroke or mouse position. Unlike the software type (described below), hardware interrupts are asynchronous and can occur in the middle of instruction execution, requiring additional care in programming. The act of initiating a hardware interrupt is referred to as an interrupt request (IRQ)
4
A software interrupt is caused either by an exceptional condition in the processor itself, or a special instruction in the instruction set which causes an interrupt when it is executed. For example, if the processor's arithmetic logic unit is commanded to divide a number by zero, this impossible demand will perhaps causing the computer to abandon the calculation or display an error message.
5
The task is to write a C program, utilizing the external interrupt of the ATMega8515, that when download to the ATMega8515 in the figure below perform one (1) of two (2) operations. On start-up OPERATION 1 is is executed and continue indefinitely. If the push-button switch is pressed OPERATION 1 is paused and OPERATION 2 is carried out after which OPERATION 1 is resumed. OPERATION 1 - A roll action is perform using the LEDs. The first LED is lit and roll down to the last LED then back to the first LED. This operation is done continuous.
7
#include #define F_CPU 4000000UL #include #define DataPort PORTC // Using PortC as our Dataport #define DataDDR DDRC //Interrupt Service Routine for INT0 ISR(INT0_vect) { unsigned char i, temp; _delay_ms(500); // Software debouncing control temp = DataPort; // Save current value on DataPort
8
for(i = 0; i<5; i++) { DataPort = 0x00; _delay_ms(500); // Wait 5 seconds DataPort = 0xFF; _delay_ms(500); // Wait 5 seconds } DataPort = temp; //Restore old value to DataPort } int main(void) { DDRD = 1<<PD2; // Set PD2 as input (Using for interupt INT0) PORTD = 1<<PD2; // Enable PD2 pull-up resistor DataDDR = 0xFF; // Configure Dataport as output DataPort = 0x01; // Initialise Dataport to 1 GICR = 1<<INT0; // Enable INT0 MCUCR = 1<<ISC01 | 1<<ISC00; // Trigger INT0 on rising edge sei(); //Enable Global Interrupt
9
while(1) { if(DataPort >= 0x80) DataPort = 1; else DataPort =DataPort << 1 ; // Shift to the left delay_ms(500); // Wait 5 seconds } }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.