** In C Language **
PROGRAMMING ASSIGNMENTs: Use SysTick interrupt to flash LED0 of the board. The LED should repeatedly turn on for some time and off for the same time. Use EXTI interrupt of PA5 so that an interrupt is triggered when the push button SW4 is pressed. LED0 has four states and the push button is used to switch between these states. The four states of LED0 are as follows: 1- The LED's on/off time period is a half second. 2- The LED's on/off time period is a second. 3- The LED's on/off time period is two seconds. 4- The LED's flashing is off. For example, if the current state is State 1, the program moves to State 2 when the push button is pressed. If the current task is State 4, the program moves to State 1 when the button is pressed, etc. Hints:- - You can start with the program explained in the slides, named SysTick_Flashing_LED_EXTI_OnOff.c. Run this program first and then modify it. - Use a memory variable called State and initialize it to 1. - In EXTI routine, increment State by one, and if State =5, it should be 1. The do the following: - If the state is 1, enable SysTick interrupt and initialize the timer to trigger interrupts every half second. - If the state is 2 , initialize the timer to trigger interrupts every one second. Page 1 of 3 - If the state is 3 , initialize the timer to trigger interrupts every two second. - If the state is 4 , disable SysTick interrupts. - In the SysTick routine, flip LED0. As you see, the program is written mainly in the interrupt routines of EXTI and SysTick. You can add one task in the main program. In this task, add the program of Lab 9 (Keypad and LCD) in the main program. Observe how the tasks of LCD/keypad, LED flashing, and receiving user input by the pushbutton, are running at same time smoothly The main purpose of interrupts is running multiple tasks simultaneously. PROGRAMMING ASSIGNMENTs: Use SysTick interrupt to flash LED0 of the board. The LED should repeatedly turn on for some time and off for the same time. Use EXTI interrupt of PA5 so that an interrupt is triggered when the push button SW4 is pressed. LED0 has four states and the push button is used to switch between these states. The four states of LED0 are as follows: 1- The LED's on/off time period is a half second. 2- The LED's on/off time period is a second. 3- The LED's on/off time period is two seconds. 4- The LED's flashing is off. For example, if the current state is State 1, the program moves to State 2 when the push button is pressed. If the current task is State 4, the program moves to State 1 when the button is pressed, etc. Hints:- - You can start with the program explained in the slides, named SysTick_Flashing_LED_EXTI_OnOff.c. Run this program first and then modify it. - Use a memory variable called State and initialize it to 1. - In EXTI routine, increment State by one, and if State =5, it should be 1. The do the following: - If the state is 1, enable SysTick interrupt and initialize the timer to trigger interrupts every half second. - If the state is 2 , initialize the timer to trigger interrupts every one second. Page 1 of 3 - If the state is 3 , initialize the timer to trigger interrupts every two second. - If the state is 4 , disable SysTick interrupts. - In the SysTick routine, flip LED0. As you see, the program is written mainly in the interrupt routines of EXTI and SysTick. You can add one task in the main program. In this task, add the program of Lab 9 (Keypad and LCD) in the main program. Observe how the tasks of LCD/keypad, LED flashing, and receiving user input by the pushbutton, are running at same time smoothly The main purpose of interrupts is running multiple tasks simultaneously