Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An MCU programmer wants to develop a real time chronometer, which can count to 1 0 0 minutes, on STM 3 2 F 4 by

An MCU programmer wants to develop a real time chronometer, which can count to 100 minutes,
on STM32F4 by using a timer peripheral (TIM2). TIM2 has a 16 bit TIMx_PSC register, a 32 bit
TIMx_ARR register, and a 32 bit TIMx_CNT register. TIM2 is connected to the APB1 bus. The source
clock of the timer is clock of the bus. Assume that all required settings and variable declarations are
done and the code will be executed after resetting.
(i) APB1 bus has arranged to have a clock frequency of 50MHz. Analyze the below code and
determine the values, those should be written to related registers. Show your calculations and
justify your results. Determine the period of the timer and the time it takes to create an interrupt request.

...
TIM_HandleTypeDef htim2;
...
int main(void)
{
...
TIM2->PSC=.......................................................;
TIM2->ARR=.......................................................;
HAL_TIM_Base_Start_IT(&htim2);
...
}
...
Interrupt handler void TIM2_IRQHandler(void)
{
HAL_TIM_IRQHandler(&htim2); //clears IRQ
splitsecond= splitsecond +1; //salise
if (splitsecond ==100)
{
splitsecond =0;
second= second+1;
}
if (second ==60)
{
second =0;
minute= minute +1;
}
if (minute ==100)
{
minute =0;
}

}
Interrupt handler void EXTI0_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); //clears IRQ
i=TIMx_CNT;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Is male dominance universal? Is so, why?

Answered: 1 week ago