[Solved] CSE474 Lab 1-Input/Output Interfacing and Traffic Light Controller, FSMs

$25

File Name: CSE474_Lab_1-Input/Output_Interfacing_and_Traffic_Light_Controller,_FSMs.zip
File Size: 678.24 KB

SKU: [Solved] CSE474 Lab 1-Input/Output Interfacing and Traffic Light Controller, FSMs Category: Tag:
5/5 - (1 vote)

Lab 1: Input/Output Interfacing and Traffic Light Controller, FSMsGoals1. Familiarity with IAR workbench software development environment2. Programming the EK-TM4C123 board3. Learning basics of general-purpose input and output (GPIO)4. Performing simple digital I/O input (interfacing push button) and output (interfacing LED)5. Understanding the power of pointers in C and how to use them in addressing GPIO registers6. Using the datasheet to extract information necessary for addressing the LaunchPad parts.7. Understand debouncing8. Designing a finite state machine (FSM) controllerWhat you need for the lab1. The EK-TM4C123 Launchpad (http://www.ti.com/tool/EK-TM4C123GXL)2. TM4C123 data sheet (https://canvas.uw.edu/courses/1205180/files/folder/EkTM4C123GXL?preview=49165887)3. IAR workbench or other IDE4. IDE installation guide (https://canvas.uw.edu/courses/1205180/files/folder/EkTM4C123GXL?preview=49716060)5. Tutorial video (https://www.youtube.com/watch?v=cLbaSFKdAho)Since we use different versions of the IDE in this video, please consult the above IDE installationguide if you find any differences.6. Oscilloscope and some cables7. LEDs (https://learn.adafruit.com/all-about-leds/the-led-datasheet)8. Push buttons(https://www.alps.com/prod/info/E/HTML/Tact/SnapIn/SKHH/SKHHAKA010.html)9. Debouncing (https://canvas.uw.edu/courses/1205180/files/folder/labs?preview=49719211)10. Lab write up specifications(https://canvas.uw.edu/courses/1205180/files/folder/labs?preview=49165850)The IDE1. IAR workbench is installed on the lab machines in the lab and the installation instructions(https://canvas.uw.edu/courses/1205180/files/folder/Ek-TM4C123GXL?preview=49716060)are posted on Canvas. If you want to download the software on your laptop please note that IARworks only on Windows OS so if your computer runs Linux or Mac OS, you will need to install avirtual machine. You are free to use other IDEs such as Keil uVision or Code Composer but makesure that the TM4C123 is supported (the board is supported by Keil 4.7 but not Keil 5).2. The free version of IAR limits your data and code to 32 KB, which is not an issue for the labassignments in this course.TM4C123GXL boardFigure 1shows an overview of the different parts of the Launchpad, refer to the user manual (postedon canvas) for more information on the boards features

Figure 1 TM4C123G LaunchPadThe RGB user LED consists of three LEDs Red, Green, and Blue and are connected to the processorthrough Port F (as shown in Figure 2 and Figure 3)

Figure 2 Three LEDsFigure 3 PortF

To turn on an LED, the following operations must be performed:1. Configure the RCGCGPIO register to turn on the GPIO port F by enabling its clock. By default, theclock to all peripherals, including GPIO ports, are turned off in order to improve the energyefficiency.2. Configure the GPIODEN register to set Port F as digital (by default, the mode of all GPIO pin isanalog)3. Configure the GPIODIR register to set the PF1, PF2, and PF3 pins as outputs4. Configure the GPIODATA register to set the output value of the corresponding GPIO pin to 1. PortF is one byte (8 bits) wide so to turn on the red LED (as an example), PF1 must be set to 1 so thevalue of the port is 0x02 (hexadecimal).The same steps apply for reading user switches except that GPIODIR register should be configured to setpins PF0 and PF4 as inputs. Please note that PF0 has special considerations. It is configured as a GPIO bydefault but is locked and can be reprogrammed by unlocking the pin in the GPIOLOCK register and uncommitting it by setting the GPIOCR register. Therefore you need to configure GPIOLOCK, GPIOCR, andGPIOPUR as well.Section A. Input/Output InterfacingExample ProgramThe program shown in figure 4 is a program that turns on the red LED.Figure 4 sample program for onboard LEDNote that it includes the tm4c123gh6pm.h file which is included in a library specific to the TM4C123GXLboard. This can be downloaded from http://www.ti.com/tool/sw-ek-tm4c123gxl (available on canvas

too). The installing header files document on canvas refers to installing the header files for the TIVAseries and shows how to set the path in IAR. You can follow the same steps for setting the path of theTM4C123GXL library.Section A Required Tasks:1. Try the program of figure 4 to turn on the red LED on your board.2. Modify the program to exclude using macros definitions and eliminate the use of the TIVA andLaunchpad libraries. You need to directly address the registers based on their base and offsetaddresses as described in the datasheet.3. Expand the program to light up all LEDs. They should be flashing continuously.4. Modify the program to define and use your own macros for better readability. You do not need toinclude the LaunchPad libraries.5. Write another C program to incorporate the user input from the switches. You should turn on thered light when user switch 1 is pressed and turn on the green light when the user switch 2 ispressed.6. Use an oscilloscope to show the voltage output of the LED and the voltage signal of the pinconnected to the onboard pushbutton. Find out the latency between the onboard buttons pressedand LED lighting up.Section B. Traffic Light Controller, FSMsButton DebouncingCheck the correct pinout for the push buttons. Wire one pin of a button to the ground, and the other pin toPA5 in the TIVA. Note here, PA5 is a positive-logic button input, where 1 means pressed, and 0 means notpressed. You may use the breadboard and jumper wires from EE 215.Please try the program of figure 5 to interface a switch to TIVA.

Figure 5 sample code for push buttonCommonly, we would encounter a bouncing issue when a push button is used. When it happens, the GPIOpins would treat a single press as multiple presses. There are multiple ways to denounce the button,either by hardware approach or software approach. See the debouncing document in the Canvas formore details (https://canvas.uw.edu/courses/1205180/files/folder/labs?preview=49719211).

Figure 5 push button bounceA common approach is using a delay. Essentially, when you press or not press a button, the contact is notimmediately read. We just wait a few moments before reading the new value. Please try this code below:// SysCtlDelay(7000000); // uncomment me if you need debouncingLEDLEDs emit light when the current passes through them. LEDs have polarity, the current flows from theanode (shorter lead) to the cathode (longer lead) to activate them. The LEDs wont be damaged if youreversed the direction, but they wont be turned on.The brightness of a LED depends on the current flows through it. If the current is more than 8mA, it is notsafe to connect it directly to a GPIO pin on the board. We suggest you use a 220 current limiting resistor,which connects to the cathode of the LEDs. The hardware configuration of this LED is shown in Figure 6.Note +5 V is VBUS on TIVA. Please try the code above to interface an LED. You need to modify the pinfrom PA2 to PE0 to match the hardware configuration. Alternatively, you could connect the pin 1 ofU3a7406 (or any generic 7406 gates found in the kit) to PA2 on TIVA to match the sample code.Figure 6 LED hardware setup

Figure 7 sample code for LEDsTraffic Light ControllerWe provide three different LEDs and two push buttons in this lab. One red LED (for stop), one green LED(for go), and one yellow LED (for warn). The suggested pins are:LEDs/ switch Possibility 1 Possibility 2 Possibility 3Button for start/stop PA2 PB2 PE0Button for passenger PA3 PC4 PE1Red LED (Stop) PA7 PB5 PE5Yellow LED (Warn) PA6 PB4 PE4Green LED (Go) PA5 PB3 PE3Finite State Machine DesignDesign a finite state machine that implements a traffic light system. It should include two push buttons asan input, and three LEDs are an output. You may need to purchase one push button from EE store if youcan only find one button in your lab kie.Inputs:1) Button for start/stopThe user would press this button to start and stop the system. The system will always start fromthe go stage (where the green LED is on).2) Button for passengerOnce this button is pressed, it indicates there is a passenger that would like to cross the street. Ifthe current stage is stopped (where the red LED is on), nothing will happen. If the current stage is

going (where the green LED is on), the current stage will change to warn stage (where the yellowLED is on), then the current stage will change to stop stage (where the red LED is on) to allow thepassenger safely across the street.Outputs:1) Red LED (stop)When the current stage is stop, the red LED is on, and all other LEDs are off.2) Yellow LED (warn)When the current stage is warn, the yellow LED is on, and all other LEDs are off. It onlyhappens when the button for the passenger is pressed.3) Green LED (go)When the current stage is go, the green LED is on, and all other LEDs are off.Section B Required Tasks:1. Try the program to interface the button.2. Try the program for the button debouncing.3. Try the program for the LED.4. Design the FSM for the traffic light system.5. Draw the finite state machine system diagram.6. Draw the schematics for the traffic light control system.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE474 Lab 1-Input/Output Interfacing and Traffic Light Controller, FSMs
$25