Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives:Learn how to poll a GPIO pinLearn the structure of GPIO pins Learn how to debounce a switchLearn how microcontrollers interface with peripherals though memory

Objectives:Learn how to poll a GPIO pinLearn the structure of GPIO pins Learn how to debounce a switchLearn how microcontrollers interface with peripherals though memory mappingLearn how GPIO outputs workIntroduction:In Labo, you learned a bit about how to set up projects in PSoC Creator, as well as the very basics of Output on the PSoC4. In this lab, you will learn how to read a digital input through the process of polling.Polling is continually looping to check a pin's (or pins') value(s) to detect a change. In Part 1, you will have to implement a true LED toggle using a polling loop. To learn how microcontrollers interface with their built-in peripherals, you will do this WITHOUT using the auto-generated API, and instead use memory-mapped registers to read the pin and output to an LED. In Part 2, you will use three push buttons supplied in your parts kits to make a game. The game will cycle through the R, G, and B LEDs. Your three push buttons will correspond to the colors, so that if you push the correct button with that LED is on, you win that round, and the cycling gets faster! You will go back to using the Pin HAL for Part 2(and, really, for the rest of the labs in the course).Part 1- Polling a Switch using Memory Mapped Peripherals In microcontrollers, one of the most commonly used peripherals is General Purpose Input and Output (or GPIO for short). GPIO allows you to wait for all sorts of user input events (like button presses here) OR control various external hardware (like LEDs here). GPIO typically works using some kind of push/pull chain on the output (like a CMOS output chain using PMOS for sourcing current and NMOS for sinking current) or using some kind of high-impedance buffer on the input. The "drive mode" of the pins (whether they are inputs or outputs), their current state, what to output, how to do interrupts, etc. are all controlled through memory-mapped configuration registers). Memory-mapped registers are very commonly used in microcontrollers to control all kinds of peripherals. Peripherals are basically any custom hardware, specific to the microcontroller, that would be different from just a CPU or Memory (ROM or RAM).These could include GPIO (like this lab), Timers, UARTs, I2C, SPI, etc. No matter the peripheral, it is highly likely that controlling them requires the utilization of one or more registers that are mapped to specific locations in memory. Bits in these registers will control the functionality of the peripheral and give you the chance to modify them in your program to change the behavior as necessary.For GPIO on the PSoC4, the key memory mapped registers are the PRTx_PC (Pin Control) register to control the drive mode, the PRTx_DR (Output Data Register) register to change the output pins, and the PRTX_PS (Pin State) register to read the current state of the pins. There are a few other registers which control some esoteric things like Interrupts, Output Enable on these pins, Bus Bypasses, and the like, but for pure input/output aren't required. Now, for example, let's say we wanted to blink the LED like we did in LabO. We would need to programmatically make the pin "Strong Drive" like we did in the Schematic Configuration Window of PSoC Creator and we would also need have to have a way to write Is and Os to the pin, with each "1" corresponding to a voltage output of

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

6. Show that E(FUG) = EF U EG.

Answered: 1 week ago

Question

Round up to single decimal point. (XX.X)

Answered: 1 week ago