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

  Innovation and communication presentation

Innovation and Communication Presentation

  What does one measure with a conductivity analyzer

Does one need to calibrate a conductivity analyzer and what does one measure with a conductivity analyzer?

  Present value plot for projects

Given the following Present Value Plot for Projects A and B, which are mutually exclusive projects, answer the following questions:

  Represents the second highest overhead

For most organizations, the cost of built space represents the second highest overhead (OpEx) after staff costs. From critical consideration of the relevant research literature, your experience, and best practice in space management, consider the ..

  Find exponential fourier series for the following signals

Problem1: Using the uniqueness property of the Fourier series, find exponential Fourier series for the following signals: Problem 2. Sketch  the following periodic wave-forms

  Draw a module that can accept a new value every cycle

Draw a module that can accept a new value every cycle, enabling full throughput.  You are not allowed to have any combinational paths from the downstream interface to the upstream interface (or vice versa).  You will need two registers to store th..

  Dc analysis of transistor and dc load line

For the common emitter circuit shown below (see figure 1) the parameters are: VBB = 4 V, RB = 220 kΩ, RC = 2 kΩ, VCC = 10 V, VBE(on) = 0.7 V, and β = 200. Calculate the base current (IB), collector current (IC), emitter currents (IE), the VCEvoltage ..

  Parameters to work out the speed

Select any passenger or F1 race car, collect data from the web information, Identify all the parameters to work out the speed of 0-100 KM/Hr in 7 seconds and 4 seconds for Passenger and F1 race car respectively.

  How the dp flow measurement transducer operates

How the DP flow measurement transducer operates and how the DP flow transmitter vertical works?

  Create an edge-triggered d flip-flop

To simulate the operation of a circuit used to create an edge-triggered D flip-flop. To test the operation of a 74LS74 D flip-flop. To test the operation of a 74LS112 J-K flip-flop

  Explain the operation of a multiplexer

Briefly explain the operation of a multiplexer.

  Find some examples of thermal expansion

A personal observation, or an experience with, or an example of a real world application of the topic. Try looking the topic(s) up on the internet if nothing occurs to you offhand, or find some examples.

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