Lab6A: Generate Different Frequencies Using a Switch!

 

Objective: In this problem you are required to modify your signal generator program (previous assignment) such that:

  1. By default your code should generate a 4.8KHz signal (square wave). In this case the TWO indicating LEDs (on RD1 and RD0) should display binary 01 (RD1=0 & RD0=1).
  2. When a switch is pressed one time and released the frequency should be changed to 5.2 KHz and the TWO indicating LEDs should show binary value 10 (RD1=1 & RD0=0).
  3. When the switch is pressed one time and released again the frequency should be changed back to 4.8 KHz and the TWO indicating LEDs should show binary value 01 (RD1=0 & RD0=1).

Notes:

  1. Your Switch can be connected to any IO pin.
  2. You must use subroutines (CALL) or Macros to perform creating each signal (5.2 and 4.8 KHz) - otherwise you will not receive a grade. Thus, your MAIN program must only contain function calls - something like this:
    • Initialize_
    • Generate_42KHz
    • Check_Switch_
    • etc.

What to submit: READ THIS CAREFULLY!

  • Your flowchart of the overall program. If your flowcharts are the same you will receive zero with no exceptions! (25 points)
    • Read the homework comments on Canvas! Bad flowcharts will not receive any grade! Do your flowchart first! DO NOT code until you have reviewed your flowchart and it is completed!
  • Problem statement. You should write it in your own words (15 points)
  • Take a snapshot of the first two pages of your code - you must show your program header/version/authors etc. appropriate comments - codes without comments will not receive grade. Your code must include proper format as described in class (30 points). See example file.
  • Use a real scope in the lab and take snapshots for the 5.2 and 4.8 KHz. DO NOT use the auto-measure feature. You must use cursors and show them on your snapshot. Record the amplitude. Show the frequency using the cursors. (30 points).
  • Demonstrate your program exactly as described otherwise you will not receive any grade!
  • NOTE: figures with no clear and descriptive explanation will not receive grade!
 

 

Lab6B: Taking Average/Min/Max

Objective: In this problem you are required to write a code which performs the following tasks (see the flow chart).

Procedure: Read the following program constrains carefully

  1. All the input values must be saved in the program memory (PM). You can start from any location. Assume the number of inputs is limited to 10. The last value will be 0xFF, indicating the end of the data (0xFF is not counted in the summation calculation).
  2. Assume all inputs are unsigned and larger than zero.
  3. Assume the average has no remainder.
  4. You must use TALPTR to copy the data from the program memory (PM) into data memory (DM).
  5. Your MAIN program must only contain function calls, as shown in the flowchart - otherwise you will not receive any grades!
  6. You must use subroutines (CALL) or Macros to perform each function.
  7. The DELAY functions can be anything as long as the displayed values are readable.
  8. Assume the SUM is always less than 99d
  9. Use LEDs connected to one of the IO ports to display the results.
  10. All displayed values must be in BCD form. As an example, if the AVG is 0xA then your AVG should be displayed as 0x10 on the IO port.

What to submit:

  • Submit your own flowchart of the overall program; similar to what we have here.
  • Submit a copy of one of your functions (subroutines). The subroutine must have Purpose, Input, Output, and proper comments, as well a a flowchart. Bad flowcharts will receive no grades! Use a professional software.

Please discuss any questions you have over PIAZZA. You MUST be able to display the program at the beginning of the class.