Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how do I code this? Timing and Interrupts The STM32 has four built-in timericounters. These counters count based upon a clock input. The clock input

how do I code this? image text in transcribed
Timing and Interrupts The STM32 has four built-in timericounters. These counters count based upon a clock input. The clock input is based upon the 72MHz microcontroller clock. The 72MHz is first divided by a "prescaler." The prescaler divides the 72MHz clock by a value between one (1) and 2. For example, if the prescaled value is 1000 , the 72MHz clock is scaled to a 72kHz clock. This scaled clock is input to a 16-bit registerioounter. The 16-bit register/counter counts (at the prescaled rate) from 0 to 65535 . (The registericounter could count from zero to a value less that 65535 if programmed to do so.) When the 16-bit register/counter counts to 65535, an "overflow" condition occurs. So if the prescaled clock is 72kHz, an overflow occurs every 65536/72000=0.91022 seconds. The best way to track the overflows is with an "interrupt service routine." This routine will be executed whenever an overllow occurs. Let us call the interrupt service routine "overflow () " We can get this interrupt service routine to execute by using a "member function" called "attachInterrupt () " The Arduino/STM32 code to have the timer execute "overflow () (upon overfiow) is shown in Listing 1 . Listing 1. Timer code with interrupt service routine. The overtlow () routine gets executed once every 0.91022 seconds

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

Do folk remedies such as snake venom and bee venom treatments work?

Answered: 1 week ago

Question

Solve each equation. x + 6x = 2

Answered: 1 week ago