Description
OBJECTIVES
• Interact with the LEDs directly using memory
• Implement and demonstrate the use of the watchdog
• Structure your code
MAJOR TASKS
DEMONSTRATION – BUILDINGON LABS
This assignment builds on thelabs and assignmentsso 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 YOU DEMONSTRATE MODIFIED CODE, YOU WILL RECEIVE A LATE PENALTY ACCORDING TO HOW LONG IT HAS BEEN SINCE THE DROPBOX DEADLINE.
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).
DOCUMENT REQUIREMENTS
This assignment requires a single flowchart of the flow of your code. This flowchart should use standard flowchart shapes for steps and decisions, and should correspond with your logic.
Please print the table below, with your name clearly displayed, for marking purposes.
Item Grade
Demonstration
/ 5
Code
Functionality / 5
Direct Memory Access / 5
Watchdog / 5
Proper use of registers, etc. / 5
Readability / 5
Comments / 5
Code Subtotal
/ 35
Total
/ 35
Applicable Cap:
CAPS
If you do not complete all functionality, the following caps will be applied:
Function Maximum Grade
Hard coded delays 60%
Direct LED access missing 80%
Watchdog demo missing 80%
All functions implemented 100%
SUBMISSION GUIDELINES
PLEASE READ AND UNDERSTAND THE SUBMISSION GUIDELINES BELOW. FAILURE TO CORRECTLY SUBMIT ANY REQUIRED COMPONENT WILL RESULT IN 10% PENALTY PER MISSING OR INCORRECT COMPONENT.
PAPER SUBMISSION
Please print your flowchart and include the grade table. Ensure your name is on all pages.
ELECTRONIC SUBMISSION
Exactly THREE items will be submitted electronically.
• A PDF of your flowchart
• Upload the complete C hook file xx_hook.c.
• Upload your complete assembly file (the xx_asm.s file).
FOR THIS ASSIGNMENT, PLEASE DO NOT COMPRESS EITHER FILE, AND PLEASE BE CERTAIN YOU HAVE NAMED IT AND YOUR FUNCTIONS CORRECTLY.
Complete file naming and upload guidelines are provided below.
ELECTRONIC SUBMISSION AND FILE NAMING
Often, multiple groups will name their assignment files assignment1.zip (or some other common combination) which results in confusion and complications when downloading and unzipping submitted electronic files.
Please follow the following guidelines for all submissions this term. Failure to follow the electronic submission guidelines may result in a 10% penalty per infraction.
As long as other file naming conventions are followed, you may choose to append an assignment identifier (i.e. “_a1” or something else as appropriate) as the LAST element before the file extension.
DOCUMENT NAMING AND SUBMISSION
Unless otherwise requested, you should only ever submit a single document containing the complete document as specified. This document must be:
• A professionally formatted document adhering to the SET report standard
• A single PDF file, NOT included in a zip
UNLESS INDICATED OTHERWISE, DO NOT SUBMIT THE ASSIGNMENT SPECIFICATION AS A PART OF YOUR DOCUMENT.
Documents should be named with the usernames of all team members as follows:
• Individual assignments: username.pdf (i.e. jsmith.pdf)
• When working alone: username_alone.pdf (i.e. jsmith_alone.pdf)
• When working with a partner: username1_username2.pdf (i.e. jsmith_bjones.pdf)
• When working as a team: username_team.pdf (i.e. jsmith_team.pdf – but be certain to include all team members on report title page)