Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Solved Assignment for Introduction Microcontrollers | ECET 209, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Class: Intro Microcontrollers; Subject: Electrical & Computr Engr Tech; University: Purdue University-Calumet Campus; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/05/2009

koofers-user-1o4
koofers-user-1o4 🇺🇸

5

(1)

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Prof. Omar Farook /ECET 209/HW 5/Ver.1 page
1
Interruption
/*
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 + A0
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).
*/
pf3
pf4

Partial preview of the text

Download Solved Assignment for Introduction Microcontrollers | ECET 209 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Interruption

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); }