ECE 4721 - 5721 Homework 2
ECE 4721 - 5721 Homework 2
Homework #2
Yaswanthrao Gandham
Due on 02/23/2022
Answer the following questions from the textbook. Each problem is worth 10
points.
1. Chapter #3 – Problems 1 – 4
1)
The LED can only flash after the Task_Read_Switches function is executed, and the
maximum delay is achieved when switch 1 is passed immediately after it finishes the
execution of the global flash LED variable which is set to 0.
a. Sequence of Events:
Task_Flash – in RGB mode
Task_RGB – in RGB mode
Task_Read_Switches – in RGB mode
Sequence:
Task_Read_Switches – in RGB mode
Task_RGB – in RGB mode
Task_Flash- in RGB mode
Task_Read_Switches – in Flash mode
Sequence:
Task_RGB – in Flash mode
Task_Flash-in Flash mode
2)
a. Assume Task_X and Task_Y are happening after Task_RGB
Sequence:
Task_Flash – in RGB mode
Task_RGB – in RGB mode
Task_X – in RGB mode
Task_Y – in RGB mode
Task_ReadSwitches – in RGB mode
b. Sequence:
Task_Flash – in Flash mode
Task_RGB – in Flash mode
Task_X – in Flash mode
Task_Y – in Flash mode
Task_ReadSwitches – In Flash mode
Task_Flash_RGB mode
3)
a. Sequence:
PORTD_IRQHandler- in RGB mode
Task_RGB in RGB mode – in RGB mode
Delay: 0.01ms + 1000ms = 1000.01ms
4)
a. The maximum delay occurs when the switch is pressed immediately after
Task_Read_Switches
11)
Each interrupt source can be enabled and disabled separately using NVIC registers
ISER and ICER. Each is 32 bits, with each bit corresponding to an interrupt source.
CMSIS call:
12)
The pin control register bits 16,17,18 indicate if IRQ7 has been requested, Registers
are NVIC_IPSR and NVIC_ISER which will use the 7 bit, IRQ7 is LLWU_IRQn
To check if LLWU_IRQn is requested or not, read the 11th bit of ISER register
NVIC_GetPendingIRQ(7);
13)
The interrupt PSR (IPSR) view holds the exception number of the currently
executing.
exception handler:
If it is servicing 0x21. it services IRQ(17)/TPM0_IRQn. The register
will have a value of 33 and use the CMSIS code to read IPSR is
Get_IPSR();
3. Chapter #6 – Problems 2, 6, 8
(𝑽𝒊𝒏 −𝑽−𝒓𝒆𝒇
)𝟐𝑩
𝒏=⌊
𝑽+𝒓𝒆𝒇 − 𝑽−𝒓𝒆𝒇
+ 𝟏/𝟐⌋