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

  Determine the elevation and stationing of the low point

The initial grade is -3.5% and the final grade is +6.5%. Determine the elevation and stationing of the low point, PVI, and PVT.

  Write program called nprimes which takes single integer

E15: Fundamentals of Digital Systems - Fall 2010 - HOMEWORK 10. Write a program called nprimes which takes a single integer input n on the command line. It should produce as output the first n prime numbers, one on each line

  Partial vacuum in a reservoir

Figure is a sketch of an aspirator, a simple device that can be used to achieve a partial vacuum in a reservoir connected to the vertical tube at B. An aspirator attached to the end of a garden hose may be used to deliver soap or fertilizer from t..

  Write an interrupt service routine

ELE3EMB Assignment- Write an interrupt service routine (C code) named ‘posi RXD'. The interrupt service rou- tine runs whenever a byte is received via the RS-232 connection to the PC.

  Evaluate the online crm system of your bank what are the

what are the motivations for an organization to have a good supply chain management scm system? define scm in your own

  Complete product design specification

What other information would be required to be able to write a more complete Product Design Specification and derive at least four concept designs to satisfy the given specification. Use short written descriptions and simple sketches to illustra..

  Determine the first order energy shift

Do the calculation again for the hypothesis that the nuclear charge is uniformly distributed over the surface of a spherical shell of radius R.

  Simulation with arena an office of a state license bureau

an office of a state license bureau has two types of arrivals. individuals interested in purchasing new plates are

  Application of mechatronics engineering

Write an essay on Application of Mechatronics Engineering

  Diesel engine that operates on ideal diesel cycle

A four-cylinder two-stroke 2.4-L diesel engine that operates on an ideal Diesel cycle has a compression ratio of 17 and a cutoff ratio of 2.2. Air is at 55°C and 97 kPa at the beginning of the compression process.

  Instrumentation measurement & lab thermal sensors lab

For the comparator below, complete the design so that the threshold voltage is 1.25V which means that if the input is below 1.25V, the output will be HIGH and if its greater, it will be low.

  Evaluate the stability using rouths hurwartz criterion

Evaluate the stability using Rouths Hurwartz criterion and obtain the range of K value for the stability under various controllers and evaluate the relative stability of the system with P and I controllers.

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