[Solved] ECE 362 – Experiment 8 Rev 10/13 Bigger Bytes Lab Manual

30 $

File Name: ECE_362_–_Experiment_8_Rev_10/13_Bigger_Bytes_Lab_Manual.zip
File Size: 546.36 KB

SKU: [Solved] ECE 362 – Experiment 8 Rev 10/13 Bigger Bytes Lab Manual Category: Tag:

Or Upload Your Assignment Here:


ECE 362 – Experiment 8 Rev 10/13 Bigger Bytes Lab Manual -1- © 2013 by D. G. MeyerExperiment 8: Whatsamatta U Reaction TimerInstructional Objectives:· To illustrate how the TIM module can be used to implement a precision time base· To illustrate how the SPI module can be used in conjunction with an external shift register toexpand I/OParts Required:· 2 x 16 LCD and 16-pin single-row header (available from the Instrument Room, EE 168)· GAL22V10 configured as an 8-bit shift register· RED, YELLOW, and GREEN LEDs plus current limiting resistors (previous experiment)· Breadboard and wirePreparation:· Read this document in its entirety· Review the material on the TIM and SPI subsystems· Solder the 16-pin single-row header to your LCD· Complete the wiring outlined in the Hardware Overview· Complete and test the LCD device driver “C” codeIntroductionMidway through the football season, Coach Boris Badenov of Whatsamatta U had an idea. Determined to be as quick as possible to challenge the “bad calls” he’s sure will be made at the Battle for the Bit Bucket game with Boo-Hoo-U, he realized that a customized reaction timer could help him test and sharpen the swiftness of his protest skills. The interface, however, would have to be simple enough for a Healthcare.gov website contractor to use, which is why he has enlisted you (along with a bevy of benevolent boisterous Boilermakers) to construct a prototype for him. An illustration of the finish product is shown in Figure 1. Whatsamatta U Reaction TimerFigure 1. Reaction Timer Control Panel and Display.NOTE: “C” code for “main”and the ISRs must be writtenand debugged during yourscheduled lab period (LCDdevice driver should bewritten and tested as part ofyour pre-lab preparation.)ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -2- © 2013 by D. G. MeyerCoach BB’s reaction timer will use the docking module pushbuttons as follows: the left pushbutton starts the reaction test which will display the message “Ready, Set…” on the first line of the LCD and initiate a random delay. When this delay expires, “Go Team!” will be printed to the second line of the LCD, the yellow LED will be illuminated (simulating that a “yellow flag” has been thrown by the referee) and the reaction timer will start. The right pushbutton stops the test, at which point the reaction time will be displayed on the first line of the LCD in the format “RT = NNN ms” and an appropriate message will be displayed on the second line. Also, the YELLOW LED should be turned off and, if the resulting reaction time was less than 250 milliseconds, the GREEN LED should be turned on. If the reaction time was greater than 1 second, the RED LED should be turned on. The left LED on the docking modulewill be used to indicate the reaction time test is “stopped” (i.e., ready to start a new test), while the right LED will be used to indicate a reaction time test is “in progress”.In addition to the reaction time, appropriate messages (i.e., messages you wouldn’t mind if your Mom saw) should be displayed on the second line of the LCD (e.g., “Ready to start!” upon reset, “Go Whatsamatta U” if a really fast reaction time is recorded, etc.). It should be noted that LCD messages should be limited to 16 characters due to the size of the screen. If, for some reason, the reaction time exceeds 999 milliseconds, an appropriate suggestion should be displayed on the second line of the LCD (e.g., “Get HKN coffee!!”).Lucky for Coach BB, there are plenty of underpaid and overworked ECE 362 students armed with 9S12C32 microcontroller kits willing to work for the opportunity to buy full-price Bit Bucket game tickets. Time’s running out, though, so gather up your parts and get to work!Figure 2. Coach Boris Badenov of Whatsamatta U and the Coveted Boiler Bit Bucket.ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -3- © 2013 by D. G. MeyerHardware OverviewOn the docking module, the left pushbutton will be used to initiate a reaction time test, while the right pushbutton will be used to stop the test in progress (and display the reaction time results).The left LED will be used to indicate the reaction timer is stopped (ready to start a new test), while the right LED will be used to indicate a reaction time test is in progress.A GREEN LED on PTT[5] will be used to indicate a reaction time less than 250 milliseconds, aRED LED on PTT[6] will be used to indicate a reaction time greater than 999 milliseconds and aYELLOW LED on PTT[7] will indicate the start of the reaction time test.An external 8-bit shift register (GAL22V10, programmed using the ABEL code given inproblem 5 of the Module 2 homework) will be used to interface LCD to the microcontroller viathe SPI module (MOSI, port pin PM[4]; and SCK, port pin PM[5]). The LCD will be interfacedas described to the microcontroller module as described in the table below:LCDPin # LCD Pin Description Connected toMicrocontroller1 Vss (ground) Vss (ground)2 Vcc (+5V) Vcc (+5V)3 VEE (contrast adjust) Vss (ground)4 R/S (register select) PTT[2]5 R/W’ (LCD read/write) PTT[3]6 LCD Clock PTT[4]7 DB[0] (LS bit) Q[0]8 DB[1] Q[1]9 DB[2] Q[2]10 DB[3] Q[3]11 DB[4] Q[4]12 DB[5] Q[5]13 DB[6] Q[6]14 DB[7] (MS bit) Q[7]15 Not connected16 Not connectedSome of the LCD pins require a bit more explanation:Mnemonic Name DescriptionRS RegisterselectThis pin is logic 0 when sending an instructioncommand over the data bus and logic 1 whensending a character.R/W’ Read/write This pin is logic 0 when writing to the LCD,logic 1 when reading from it. For this lab, wewill only write to the LCD.LCDCLK LCD clock This pin latches in the data on the data[7:0]bus on the falling edge. Therefore, this lineshould idle as logic 1.NOTE: The LCD does notcome with pre-solderedheaders. You will need tosolder a 16-pin header tothe LCD so that you will beable to plug it in to yourbreadboard.NOTE: DB[#] are the LCD data inputs and Q[#] are thedata outputs of the GAL22V10 shift register.ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -4- © 2013 by D. G. MeyerSoftware OverviewTimer Channel 7 will be used to provide periodic interrupts at precise 1.000 millisecond intervalsfor the purpose of gauging the reaction time. The Timer Channel 7 interrupt service routineshould keep count of the elapsed time using the “react” variable provided in the skeleton file.This variable should be kept in BCD format.The RTI will be used to sample the pushbuttons on the docking board every 2.048 millisecondsas well as increment the “random” counter. Data for the LCD display will be shifted out to anexternal shift register (GAL22V10) and will be interfaced to the SPI module through Port M.A key element will be providing a “random” delay between the instant the “start test” (leftpushbutton) is pressed and the “Go Whatsamatta U” message is displayed on the LCD.Here, the “random” counter maintained by the RTI service routine will be used to trigger thestart of a reaction time test.In order to help with LCD interfacing, the “skeletons” of several functions outlining a simpledevice driver have been provided to you:Function Operation Performedshiftout Transmits the contents of A to a shift register using SPIlcdwait Delays for 2 millisecondssend_byte Writes contents of A to the LCDsend_i Sends instruction byte in A to LCDlinechg Move LCD cursor to the cursor position passed in Aprint_c Print character passed in register A on LCDpmsglcd Print to the LCD all characters passed by call until anASCII NULL character (decimal 0) is found.You will be required to write all of these functions (or equivalent) to interface with the LCD.Additionally, many of these routines depend on others (for instance, pmsglcd requires print_cbe written). You should build the driver from the ground up starting at shiftout anddesigning toward pmsglcd. The pmsglcd routine should take in a string passed by call andprint every character to the LCD until it reads an ASCII NULL character (“0”). You shouldmake multiple calls to print_c to print each individual character to the LCD screen.Before printing characters to the LCD, it must first be initialized by writing instruction bytes.The relevant LCD instructions are given in the skeleton file and are replicated below:Instruction Byte Operation PerformedLCDON $0F Turn on the LCD driver chipLCDCLR $01 Clear the LCDTWOLINE $38 Enable two line display modeCURMOV $FE Cursor move command (requires second cursorposition byte)ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -5- © 2013 by D. G. MeyerTo initialize the LCD, you must send the LCD commands in the following order. NOTE:LCDCLK and R/W¢ are names of signals, not instructions. Also, keep in mind send_i is afunction that takes arguments passed by value in register A.NOTE: The LCD initializations call functions that you must write. It isrecommended that you validate these functions before attempting initialization.The function chgline moves the cursor on the LCD to the cursor position passed by value inregister A. To accomplish this, you must first send the CURMOV instruction, followed by asecond instruction byte telling the LCD which position you want the cursor to move. Thesecursor position bytes are given in the table below.Cursor Position0 1 2 … 15 … 40Line 1 $00 $01 $02 $0F $26Line 2 $40 $41 $42 $4F $66Line 3 $80 $81 $82 $8F $A6Line 4 $C0 $C1 $C2 $CF $E6This is the cursor position byte map for our LCD driver (Hitachi HD44780). The area shaded ingreen corresponds to the valid cursor positions for our 2 x 16 character LCD. For example, thefirst character of the first line corresponds to cursor position $80 and first character of the secondline corresponds to cursor position $C0. It should be noted that both of these cursor positions aregiven as variables in your skeleton file (LINE1/LINE2).Keep in mind that the LCD driver chip is designed to accommodate up to a 4×40 characterdisplay (ours is only 2 x 16). This means that you will be able to write to cursor positions thatare not within the viewable area of your LCD.LCDCLK = ‘1’R/W’ = ‘0’send_i(LCDON)send_i(TWOLINE)send_i(LCDCLR)ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -6- © 2013 by D. G. MeyerStep 1. InterfacingInterface the LCD and LEDs to your microcontroller kit as described in the Hardware Overviewsection. This will require programming your GAL22V10 to function as an 8-bit shift register, asdescribed in problem 5 of the Module 2 homework. Complete all the interface wiring on yourbreadboard as part of your pre-lab preparation.Step 2. SoftwarePrior to your scheduled lab period, write the LCD device driver routines and test them with theinterface circuitry completed for Step 1. Complete the remainder of the “C” skeleton fileprovided on the course website during your scheduled lab period. Note that the “finishedproduct” should work in a “turn key” fashion, i.e., your application code should be stored in flashmemory and begin running upon power-on or reset. Demonstrate the completed reaction timersystem to your lab T.A.Step 3. SubmissionSubmit your “.C” solution file on-line after demonstrating it to your lab T.A. (but before leavinglab). Be sure identifying information (i.e., name, class number, and lab division) is included inthe files you submit – credit will not be awarded if identifying information is omitted.Bonus CreditThe “stock” reaction timer described above has a “fixed” 250 ms threshold which it uses todistinguish between “fast” and “slow” reaction times. A simple extension would be to “dial in”the desired threshold using a potentiometer, and to display how much faster/slower the user wasrelative to that threshold.Use a potentiometer (referenced to 5 VDC) connected to PAD0 as the means for entering thevariable “slow/fast” threshold – a suitable range might be 0 to 500 ms. This value should be readas part of the program initialization (after reset) and displayed on the the LCD before the firstreaction test is initiated: “Thresh = NNN ms”. Then, when a reaction test is run tocompletion, the first line of the LCD should display the reaction time the same way as the“stock” version, but the second line should display the difference between the measured reactiontime and the threshold: “100 ms slower” or “50 ms faster”.ECE 362 – Experiment 8 Rev 10/13Bigger Bytes Lab Manual -7- © 2013 by D. G. MeyerDebugging TipsWhen debugging the LCD circuit, you should use the oscilloscope logic analyzer if you’re tryingto watch more than two signals at a time (e.g. looking at all eight shift register outputs at onetime. The only difference in using this rather than using the A1/A2 analog oscilloscope probes isthat instead, you’ll be using the D0-D7 probes. If these probes aren’t immediately visible, pleasecheck the bag on top of the oscilloscope.D0 and D1 LA probesFirst, you should attach a probe to each pin you want to measure. Next, you should press theD0-D15 button in the lower right corner of the oscilloscope controls. This display allows you toenable D0-D7 and D8-D15. Enable D0-D7 by pressing the “On” control for these probes (thethird button from the left below the display). You can also choose to disable the A1/A2 probes ifyou want more display room for D0-D7.To trigger on any of these ports, you can press the Edge button and select the D bit as yourtrigger source (third button from the left below the display). You can select among the D bitsafter you have pressed this button by turning the knob marked “Select” under the D0-D15button. You may also choose whether to trigger on a rising or falling edge in the same menu.The last thing to check is under the Mode/Coupling button menu. You’ll want to select“Normal” trigger mode if you want a one-shot trigger. If you have a periodic waveform, select“Auto” as your trigger mode. Leave the coupling as “DC” for non-periodic waveforms. Therejection functions are situation-dependent and can be changed at will.You may now run your code and the LA will trigger based on the settings you’ve entered.

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] ECE 362 – Experiment 8 Rev 10/13 Bigger Bytes Lab Manual
30 $