Answered step by step
Verified Expert Solution
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 PSoC 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' values to detect a change. In Part you will have to implement a true LED toggle using a polling loop. To learn how microcontrollers interface with their builtin peripherals, you will do this WITHOUT using the autogenerated API, and instead use memorymapped registers to read the pin and output to an LED. In Part 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 and really, for the rest of the labs in the coursePart 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 pushpull chain on the output like a CMOS output chain using PMOS for sourcing current and NMOS for sinking current or using some kind of highimpedance 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 memorymapped configuration registers Memorymapped 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 RAMThese could include GPIO like this lab Timers, UARTs, IC 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 PSoC the key memory mapped registers are the PRTxPC Pin Control register to control the drive mode, the PRTxDR Output Data Register register to change the output pins, and the PRTXPS 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 inputoutput 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 corresponding to a voltage output of
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started