Pages created and updated by Terry Sturtevant Date Posted: June 13, 2019

CP316: Microprocessor Systems and Interfacing

Testing Hardware Timing

Objectives

The speed with which a microprocessor or microcontroller communicates with hardware is dependent on many factors. One obvious factor is the clock speed, however this is often not the most important factor.

Equipment

Procedure

Raspberry Pi Manual Pin Toggling

  1. Connect the Raspberry Pi with the serial monitor.
  2. Download gpio_test_basic.py.
  3. Connect the oscilloscope to the output pin.
  4. Run the program to see that the square wave appears on the scope.
  5. Comment out the delay instructions in the program and rerun it so you can see the maximum frequency that can be produced.
    Sketch the output, and note the oscilloscope settings.

    pi toggle output suspended
    Is the output sharp or fuzzy? What does this tell you about the stability of the timing?

  6. Press the Run/Stop button on the oscilloscope to freeze the image, and note how consistent the pulses are. Repeat this 5 or 6 times to find the maximum variation between pulses that you observe.
    Sketch the output, and note the oscilloscope settings.
    pi toggle output suspended

    Demonstration - demonstrate the screen showing the variation.
    Because the operating system is scheduling several tasks, your program will be suspended periodically, which will result in occasional long pulses.

Raspberry Pi PWM Operation

  1. Download pwm_test_2018.py.
  2. Change the frequency to the maximum frequency observed previously, run the program and observe the output.
  3. As before, press the Run/Stop button on the oscilloscope to freeze the image, and note how consistent the pulses are. Repeat this 5 or 6 times to find the maximum variation between pulses that you observe.
    Sketch the output, and note the oscilloscope settings.
    Demonstration - demonstrate the screen showing the variation.
    Does the PWM capability avoid the problem of manual toggling of pins? What does that tell you about whether PWM is a feature of the hardware or the software?
  4. Increase the frequency, and see what maximum frequency you can achieve using the PWM feature.

Arduino blink program

  1. Connect the Arduino board.
  2. From the Examples, load the Blink sketch.
  3. Connect the oscilloscope to output pin 13.
  4. Run the program to see that the square wave appears on the scope.
  5. Comment out the delay instructions in the program and rerun it so you can see the maximum frequency that can be produced.
    Sketch the output, and note the oscilloscope settings.
    arduino blink output

  6. Press the Run/Stop button on the oscilloscope to freeze the image, and note how consistent the pulses are. Repeat this 5 or 6 times to find the maximum variation between pulses that you observe.
    Sketch the output, and note the oscilloscope settings.
    Demonstration - demonstrate the screen showing the variation.
    Because there is no operating system, your program is the only task running.

Arduino blinkfast program - using low level features

  1. Create a new sketch, and download the Blinkfast sketch.
  2. Run the program to see that the square wave appears on the scope.
  3. Comment out the delay instructions in the program and rerun it so you can see the maximum frequency that can be produced.
    Sketch the output, and note the oscilloscope settings.
    arduino blink output
    Is the duty cycle 50%? If not, what does that mean about the assembly language code?

  4. Press the Run/Stop button on the oscilloscope to freeze the image, and note how consistent the pulses are. Repeat this 5 or 6 times to find the maximum variation between pulses that you observe.
    Sketch the output, and note the oscilloscope settings.
    Demonstration - demonstrate the screen showing the variation.
    Because there is no operating system, your program is the only task running.

Arduino diasassembly

The Arduino IDE contains all of the tools necessary to see the actual assembly language code of a compiled program.
  1. Open the File menu and choose Preferences.
    file menu

  2. Choose the verbose output option.
    choosing verbose 
output

  3. File the location of the elf file when you compile the program.
    finding elf file

  4. Change to the directory containing the elf file. (Note how your username may not show up as expected when it shows the path.)
    change to elf 
file directory

  5. Run the command to dissasemble the elf file.
    dissasemble elf 
file command

  6. Note the dissasembled (txt) file is much bigger than the elf file.
    dissasembled file created

  7. Open the dissasembled (txt) file in any text editor.
    opening dissasembled file

  8. It should look like this:
    Blink.ino.txt
    Search for void loop() to see where your code starts.
Creative Commons License

Information on this site which is produced by Terry Sturtevant is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University