SWEN-340

Non-Blocking and Interrupt Homework Assignment

Overview

This homework assignment is to demonstrate your understading of USART, Blocking vs Non-Blocking and Interrupt Handling

Setup

    Reference: Nucleo Reference Manual (Pages 1339-1344)

    Steps for creating a new project in CubeIDE (no defaults)

    Step 1: Download Src  Inc

    Step 2: Just like the in-class activity, create a project without defaults.

    Step 3: Unzip and copy src and inc into the core. (Some files will overwrite)

    Steps for Non-Blocking:

    Step 1: Complete init_systick() and delay_systick() as instructed with one exception. Make systick a 2 millisecond timer. Make sure you change the comments.

    Step 2: Comment out delay_loop() as in the in-class activity and call delay_systick() to create a 1 second delay. Add comments as necessary.

    Step 3: Modify UART.c by making a copy of the USART_Read function to USART_Read_Nonblocking.
    Hint: In the nonblocking version change the while to an if statement. If no character is available immediately return 0, not a boolean like the in-class activity.

    Step 4: Modify UART.h to add the new nonblocking function prototype.

    Step 5: Modify run_demo() so it calls the new USART_Read_Nonblocking and put code around USART_Write so it only prints when it gets a character and prints 'Enter' when the enter key is pressed.

    Steps for Interrupt Handling:

    Step 1: Replace the interrupt handler, SysTick_Handler().
    (a) Add a void SysTick_Handler() function to demo.c code from the previous assignment.
    (b) Open stm32l4xx_it.c and find and comment out SysTick_Handler().

    Step 2: Add a static volatile global uint8_t variable called one_second_elapsed

    Step 3: Inside the handler function:
    (a) have a static uint32_t counter that counts up for a 1 second delay (remember, SysTick is set to 2 ms)
    (b) then sets the one_second_elapsed variable to true when time gets to 1 second
    (c) then reset this counter to 0 (or use equivalent code)

    Step 4: Change your systick initialization code to enable the interrupt bit. Remember, the reload value is set for 2ms timer!

    Step 5: Change your main while loop inside the demo function by first removing the call to the delay_systick function. Replace that by checking for one_second_elapsed is true. If true toggle the LED and set one_second elapsed to false.

Submission

Submit your updated UART.c, UART.h, and demo.c to the Non-blocking and Interrupt assignment folder. Do not put in a zip file.

Grading

To receive full credit, Code must compile and run as expected without any warnings!

User must be able to type any key in Putty window while LED is blinking at 1 sec intervalWarnings - 0.5 point will be deducted for each warning

Compile Error - You may not get any points in case your code doesn't compile and run

Late Submission - 5% penalty per day will be applied