Starting from:

$25

PROG1360-Assignment 5 Watchdog and LED Solved

Objectives
·        Interact with the LEDs directly using memory

·        Implement and demonstrate the use of the watchdog

·        Structure your code

Major Tasks
Demonstration – Building on Labs
This assignment builds on the labs and assignments so far.

The Demonstration section of this document outlines the items you are required to show.

Tasks
You will revisit the blinking lights game of Assignment 3 and make modifications. Modifications to make:

1.      Replace the calls to BSP_LED_Toggle / LED_ON / LED_OFF with direct memory access as shown in Lab 9.

2.      Modify the winning code (blink all lights on and off twice) with direct memory access, changing the state of all lights with single calls (all on / all off) instead of individual calls.

Additions to make:

Create a new test item in the menu (the one we normally access with minicom) to demonstrate that the hardware watchdog works. Requirements:

1.      Initialize and start the watchdog from the C code as shown in the lab

2.      Experiment with the prescaler and reload values to determine the watchdog duration. Make this duration configurable in the call to your C code.

3.      This function will blink the LEDs in a continuous loop using direct memory access

4.      If the user button is not pressed, refresh the watchdog between LED blinks

5.      If the user button is pressed, don’t refresh the watchdog, but continue blinking the LEDs. A properly configured watchdog will result in the board rebooting after the watchdog timer has expired.

Given the command below (where xx is your initials)

xxWatch duration delay
your board will execute the blinking light loop with the watchdog enabled for the duration you specify. You will need to determine what the units of duration are.

Where necessary, you can still use the busy_delay. You may have to refresh the watchdog during the busy delay if the timeout is less than the delay.

Requirements
·        Only the watchdog initialization is to be implemented in your C hook code.

·        You may use library functions from the stm32 code to parse input.

·        You must use direct memory access to manipulate the LEDs

·        It is very important that you structure your code cleanly for this assignment.

·        You must name all functions and adapt any menu help instructions appropriately.

·        You will have to determine how the watchdog timeout duration is calculated. (This may be useful to research)

·        On starting the game, ensure that all lights are first turned off.

Demonstration
Please note that you must be prepared before offering to demonstrate your code. You must demonstrate the code that you have submitted to the eConestoga dropbox.

For this assignment, you will demonstrate the following items. You may use a lab PC or your own. If needed, you may use a classmate’s VM, but you MUST run your own code and only your own code. You must demonstrate in your regularly scheduled lab period. If.

1.      Your xx_hook.c and xx_asm.s code as taken directly from the drop box compiles.

2.      Your code deploys with sudo make program.

3.      Your code runs with no parameters provided (sensible defaults).

4.      Your code runs as specified.

5.      You can demonstrate both cases – that it is possible to both win and lose.

Code
Your code will be evaluated as follows. Each will be evaluated on a 0 to 5 basis, where 0 is unacceptable or not present, and 5 is excellent.

Functionality
Your program behaves as specified.

Direct Memory Access
You have implemented all LED interaction as specified

Watchdog
The watchdog works as specified.

Proper use of Registers, the stack, and link register
Only necessary items (no more, no less) are pushed onto the stack. Your function calls use the link register appropriately.

Code Readability and Structure
Your code is properly indented, does not wrap or have long lines, and can be logically understood.

You use subroutines and memory appropriately.

Code comments
As this is assembly language, you must extensively comment any code that is unclear (i.e. nearly every line).

More products