0% found this document useful (0 votes)
14 views3 pages

2024 FALL ELEC335 LAB3 - STD

hw

Uploaded by

emrehayre3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

2024 FALL ELEC335 LAB3 - STD

hw

Uploaded by

emrehayre3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Department of Electronics Engineering

ELEC 335, Fall 2024

Lab #3: Timers, Interrupts, Watchdogs


&
Seven Segment Display

1 Overview

The objective of this lab is to provide a comprehensive understanding of timers and


their applications in embedded systems programming using C. Through a series of
problems, you will:

● Learn to implement accurate delay functions using the SysTick timer.


● Work with general-purpose timers to control LED blinking intervals,
adjusting them through external button presses.
● Interface with a seven-segment display to create a count-up timer using
interrupts, demonstrating timer overflow and external event handling.
● Gain experience in configuring and observing the behavior of watchdog
timers to manage system resets.
● Integrate watchdog timers with previous timer functionality, ensuring robust
system performance in real-time applications.

This lab emphasizes the importance of using interrupts and timers in various
microcontroller tasks and ensures students can effectively implement and manage
time-based events in embedded systems.

2 STM32F103C8T6 SETUP
The STM32F103C8T6 board is a blue chip, supports arduino ide and there are lots of
resource and tutorial videos about. It's also cheap compared to other boards!

For this lab you need following components:


● STM32F103C8T6
● ST Link V2
● 5mm Red LEDs (x10)
● 1k Resistor (x10)
● Breadboard
● Some jumpers
● Tactile button
● Seven Segment Display(NEW COMPONENT!)

0
Problems
Problem 1. In this problem, you will work on creating an accurate delay function
using “SysTick” exception. Create a “SysTick” exception with 1 millisecond
interrupt intervals. Then create a “delay_ms(..)” function that will accurately
wait for (blocking) given number of milliseconds.

• How would you measure the accuracy of your delay using software
methods?
• How would you measure the accuracy of your delay using hardware
methods?
Explain each case, and (if possible) implement your solution.

Problem 2. In this problem, you will work with general purpose timers. Set up
a timer with lowest priority that will be used to toggle on-board LED at 1 second
intervals. Change the blinking speed using an external button. Each button press
should increase the blinking speed by 1 second up to a maximum of 10 seconds.
Next button press after 10 should revert it back to 1 second. All the functionality
should be inside your interrupts.

Problem 3. In this problem, connect your seven-segment display and implement


a count up timer. It should sit at zero, once the external button is pressed, it
should count up to the max value (i.e. 9999) then once it overflows to 0, it should
stop, and light up an LED (on-board or external). Pressing the button again
should clear the LED and count again. For this problem, your main loop should
not have anything. All the functionality should be inside your interrupts.

Note: Arrange it so that the LSD of the number increments in 1 second intervals.
(i.e it should take 10 seconds to go from 0000 to 9999)

Problem 4. In this problem, you will work with watchdog timers. Setup either
window or independent watchdog timer and observe its behavior in the simple
blinky example from the repo. Calculate the appropriate reset time and
implement it. Add the necessary handler routine for resetting the device.

Problem 5. In this problem, you will implement your watchdog timer in Problem
3. Figure out a way to properly incorporate it to your code when it all works with
timers. Explain your solution and implementation and make sure you covered
all possible scenarios.

1
Submission

● Send the source code and .elf file to the Teams group. Zipped with name
F2024EC335_studentNumber_lab1.rar

_studentNumber_lab1/

problem1/

problem1.s problem1.elf

problem2/

problem2.s problem2.elf ..

● Bring your breadboard setup of the last problem to class and show us all how it works!
● Write a report in the following format:
○ Explain key parts of your code.
○ What you learned.
○ Proper cover page, intro, problems, flow charts, block diagrams, schematic diagrams,
comments, and theoretical, mathematical work, simulation vs. The lab report must be
submitted in hard copy.
● You will answer some key questions during the lab session. So be prepared and don’t cheat.
There is a possibility that these subjects will become your profession.

You might also like