


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Class: Intro Microcontrollers; Subject: Electrical & Computr Engr Tech; University: Purdue University-Calumet Campus; Term: Unknown 1989;
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Designed by: Omer Farook Project:"Demonstrating the use of External Interrupt" The system board is set to receive Interrupt via the RB0 pin (pin 6) which is normally High, Interrupt occurs when Low Port A's all the bits are set as outputs and are connected to the 5 LEDs Intially they are made High and thus all 5 LEDs are on. The System's normal task is to keep them in this state
When First time External Interrupt occurs A0 is turn Low. When Second time External Interrupt occurs A1 + A0 are turn Low. When Third time External Interrupt occurs A2 + A1 + A0 are turn Low. When Fourth time External Interrupt occurs A3 + A2 + A1 + A0 are turn Low. When Fifth time External Interrupt occurs A4 + A3 + A2 + A1 + A are all turn Low. */ //developing code for 16F88 based sytem
#include <16f88.h>
//Delay Preprocessor--------------------------------------------
/* The #use symbol(s) are preprocessor directives that some of our C functions require. For example, in order to use the delay_ms(); and delay_us(); functions, we must include the #use delay preprocessor which indicates the frequency of the oscillator we are using. In the case of this program, we are using the 4_000_000 Hz oscillator which is defined in (clock = 4000000). */
#use delay(clock=4000000) //clock=4000000 Oscillator running @ 4 MHz
//Fuse (PIC Configuration) Settings-----------------------------
/* The settings in the fuses register are defined in our C program so that we do not have to set them in the WinPIC software. The Win PIC software is used on the PC to download our program to the PIC chip via the serial port. */
#fuses NOLVP, NOWDT, INTRC, PUT //NOLVP - Turn Off Low Voltage Programming //NOWDT - Turn Off Watchdog Timer //INTRC - Enable the Internal Oscillator //PUT - Turn On the Power Up Timer
//Pre-Processor directive for External interrupt #int_EXT //body of the External interrupt Service Routine
void ext_isr(void) { unsigned int A1 = 0; //Reading the status of port A and placing in the //variable A A1 = input_a(); //Using the if control structure to determine the //value which //is at Port A accordingly appropriately //altering the Port A bit status if (A1 == 0x1f) { output_a(0x1e); }
if (A1 == 0x1e) { output_a(0x1c); } if (A1 == 0x1c) { output_a(0x18); } if (A1 == 0x18)
//Enable the interrupt at the External Interrupt level
ext_int_edge(0,h_TO_l); //Determines when the External interrupt is acted upon //First argument is the interrupt 0 and the //second argument //is the edge triggered either h_to_l or L_to_H
output_a(0x00);
while(1) //Set while condition as 1 = True (Perpetual Loop) { static unsigned int x1 = 0; //static declaration will keep the value of the //variable x
//between the functions x1 = input_a(); //Reading the status of port A and placing in the //variable x
if (x1 == 0x00) //Using the if control structure to determine the //value which //is at Port A which if 0x00 is accordingly alterered //to 0x1f { output_a(0x1f); }