How to accept keyboard input from the terminal by polling

Assignment Help Other Engineering
Reference no: EM131148732

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

Reference no: EM131148732

Questions Cloud

Describe the situation and ethical issues : Summarize an ethical dilemma from an experience you have observed in the work environment. Use the 5D process. Describe the situation. Describe the ethical issues. Discuss the options.
Commit to budget item for future training : As the human resources manager, you must convince Chris Crittenden, vice president, that your company needs a training program for all workers who are currently telecommuting or who plan to do so. Their managers should also receive training. You deci..
Features of medieval europe : What were the features of Medieval Europe that developed between 500 and 1200 C.E.? Please discuss with reference to the Church, Feudalism, and Manorialism
Describe the situation with the drugs crossing the border : Describe the situation with the drugs crossing the border into the United States. Is it possible to adequately address this issue and not affect the US / Mexican economic status?
How to accept keyboard input from the terminal by polling : 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.
Did someone agree to sell you something but at last minute : Thinking back on the last few months, consider a time when you encountered a friend or business associate who promised or agreed to do something but did not follow through. For example, did someone agree to sell you something but at the last minut..
Think utilitarianism versus the categorical imperative : Do you believe that the ethics of an act are better explained by the results of the act or the intrinsic nature of the act itself (Think Utilitarianism versus the Categorical Imperative)?
What problems did newly independent nations of africa face : What problems did the newly independent nations of Africa face in the years after independence? What challenges do contemporary. African societies face today? Be sure to provide specific examples
What are the reasons for characterizing social problems : What are the reasons for characterizing social problems such as alcoholism and drug abuse as diseases rather than behavioral disorders? What are the implications of treating other social problems as diseases? What are the implications for the medical..

Reviews

Write a Review

Other Engineering Questions & Answers

  How many gates are required to implement the given equations

How many gates are required to implement the following Boolean equations? Which Boolean law is used to transform each of the following equations?

  Determining the volume of the anchor

An iron anchor of density 7870 kg/m3 appears 200 N lighter in water than in air.

  Functionalities of imaging infrared

Functionalities of Imaging Infrared (IIR) seeker, IR, Operation during day and night

  Delay in time between the contraction of the atria

1) There is a delay in time between the contraction of the atria and the contraction of the ventricles. This is called the AV-delay. What structural characteristics (identify more than one!) of the conducting fibers between the AV node and AV bundle ..

  Laplace transform and analysis in s-domain

This week's lab is based on the application of circuit analysis techniques to a capacitive circuit with Multisim. You will learn to utilize Multisim to perform the mesh analysis.

  How does a cast iron cooling curve look

How does a cast iron cooling curve look,effect of heating temp, duration also cooling rate

  Design a lighting system

Design a lighting system along with electrical power distribution - fully referenced schematic diagrams of the proposed system

  Plot the relation between the input x(t) and the output y(t)

Plot the relation between the input x(t) and the output y(t). Is this a linear system? For what range of input values is the system linear, if any?

  Differences in ph and condtivitives between water samples

Explain in detail Why there is some differences in pH and condtivitives between water samples?

  Assume that you are managing a design project which will

imagine you are managing a design project that will create an interface for automobile mechanics. the interface would

  Provide a logic diagram that shows how a memr sometimes

provide a logic diagram that shows how a memr sometimes called oe signal and a memw signal can be generated from the

  Standard deviation of portfolio return issues

What is the (population) standard deviation of portfolio returns?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd