Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Other Engineering Expert

Design with Microcontrollers

Lab: Interrupt Processing

Lab a: Interrupt-Driven General Purpose IO (GPIO)

Let us start with an example of how to handle an interrupt generated by a device connected to a GPIO pin-in our case, a switch which is onboard the PSoC board. We will develop a simple interrupt service routine (ISR) to service the interrupt as follows: when the switch is pressed, toggle the red onboard LED. Note the following important points:

• The LED is connected to P1[6] with a copper trace on the board, that is to the 6th pin belonging to I/O port 1. The switch is similarly connected to P0[7]. External connections are unnecessary.

• The LED is active low; that is, driving the pin low will turn it on.

• The switch is grounded when pressed.

As a first step, your must configure an input pin-let's call it SW-under the "My Design" tab in the .cysch file, as part of your top-level design within PSoC Creator. Note the following points:

• The input-pin parameters must be chosen as follows: digital input, a resistive pull up drive mode, and the initial drive state set to high.

Also, set the pin input to generate an interrupt- called SW Int-on the falling edge of the pulse and to trigger an ISR.

• Map the pin component to P0[7] in the .cydwr file under the "Pins" tab.

• Map the LED output pin component to P1[6] in the .cydwr file.

Once you build the code, the system will generate low-level code including the following stub for the ISR called SW Int Interrupt within the file SW Int.c. (The file may be called differently in your case depending on how you name your interrupt.)

Lab b: Handling UART Interrupts

In lab assignment 1, we saw how to accept keyboard input from the terminal by contin- uously polling the UART component, say named UART 1, for input data within the main program. The polling-based method can be written as follows.

This assignment asks you to operate the UART in an interrupt-driven fashion, accept input from the keyboard, and dynamically control the blinking rate of the LED.

Configure the UART component in your top-level design as follows:

• Set the baud rate on the UART to 9,600 bps. Match this baud rate on the terminal running on the host PC.

• Under the "UART Advanced" tab, have the UART generate an external interrupt when the receive FIFO buffer is not empty and associate an interrupt component with this event. In- terrupt components are listed in the component catalog under "System." Say, we name this interrupt as Uart Int.

• Designate pin P0[4] as the receive (rx) pin and P0[5] as the transmit (tx) pin in the .cydwr file under the "Pins" tab.

• External jumper wires are required: connect P0[4] to P12[7] and P0[5] to P12[6] on the board. This effectively transfers the bit stream between the UART component and the USB connector.

Lab c: Implementation of a Wall Clock

In this assignment you will use the timer and UART components in interrupt-driven fashion to implement a running wall clock and display it on the terminal in hh:mm:ss format, where hh stands for hours, mm for minutes, and ss for seconds. The wall-clock program must also have the following additional functionality:

• It must allow the user to set the hh, mm, and ss fields prior to starting the clock.

• It must allow the user to reset the various fields during operation. When the user presses the character ‘c' on the keyboard, the clock must be stopped, new values for hh, mm, and ss, accepted as inputs from the user, and the clock restarted with these new values.

The timer is available under the Digital/Functions menu in the component catalog. Use the Timer component, not the Timer Counter component. You can configure the timer, call it TIMER 1, in your high-level design as follows:

• The internal counter within the timer counts down; starting with an initial value n-which can be chosen to be an 8-bit or 16-bit value, as appropriate-and a clock signal of frequency f , the counter counts down at each rising edge of the incoming clock-pulse train until the counter value reaches 0; upon which the value is reset to n, and the process repeats itself. So, the period, p, of the timer can be calculated as p = n × 1/f seconds.

• At the end of each period, the timer asserts the line associated with terminal count, shown as the ‘tc' line in the timer block. Associate an interrupt with this line such that the cor- responding ISR, called timerISR in the code snippet below, is triggered at periodic time intervals.

Lab d: Measuring Elapsed Time

This assignment asks you to develop functions that use the timer component to measure elapsed time between events-in this case, to measure the execution time of a given function. Consider the following function that multiplies two N × N matrices:

You are asked to write two functions, tic and toc, that work in concert to measure the execution time incurred by matrixMult in milliseconds. The skeleton of the main program is as follows where the UART and timer components are named UART 1 and TIMER 1, respectively

Attachment:- Interrupt_Processing.pdf

Other Engineering, Engineering

  • Category:- Other Engineering
  • Reference No.:- M91904199

Have any Question?


Related Questions in Other Engineering

Projection of planes1 a regular pentagon of 25 mm side has

Projection of Planes 1. A regular pentagon of 25 mm side has one side on the ground. Its plane is inclined at 45° to H.P. and perpendicular to the V.P. Draw its projections. 2. Draw the projection of a circle of 50 mm di ...

Mine safety amp environmental engineering assignment -part

Mine Safety & Environmental Engineering Assignment - Part 1 - Questions 1. Occupational health and safety is the primary factor that needs to be considered in the mining industry. Discuss this statement. 2. Define the fo ...

Assignment -problem 1 - given is the lcc difference

Assignment - Problem 1 - Given is the LCC difference equation that represents some LTI system: y(n) - ¾y(n-1) - ¼y(n-2) = x(n) + x(n-1)   a) Find the impulse response of the system (solve the LCCDE). b) Draw a block diag ...

Question - show that the zero-point energy of a simple

Question - Show that the zero-point energy of a simple harmonic oscillator does not contribute to its entropy or heat capacity, but does contribute to its energy and Helmholtz function.

Mine safety amp environmental engineeringpart 1 questions1

Mine Safety & Environmental Engineering Part 1. Questions 1. Occupational health and safety is the primary factor that needs to be considered in the mining industry. Discuss this statement. 2. Define the following terms ...

Projectflow processing of liquor in a mineral refining

Project Flow Processing of Liquor in a Mineral Refining Plant The aim of this project is to design a flow processing system of liquor (slurry) in a mineral (aluminum) refining plant. Aluminum is manufactured in two phase ...

Operations engineering assignment -please select only one

Operations Engineering Assignment - Please select only one of the following case studies for your assignment: CASE A. Tesla Motors Tesla is an innovative manufacturer that designs, assemble and sells fully electric vehic ...

Mine safety amp environmental engineeringpart 1 questions1

Mine Safety & Environmental Engineering Part 1. Questions 1. Occupational health and safety is the primary factor that needs to be considered in the mining industry. Discuss this statement. 2. Define the following terms ...

Load fault level analysis amp protection design of a remote

LOAD, FAULT LEVEL ANALYSIS & PROTECTION DESIGN OF A REMOTE AREA MICROGRID Assignment Please undertake the following analyses: 1. Calculate the 3-phase fault levels on Bus 2, Bus 3 and Bus 4 with the main supply connected ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As