Question: Setting up the TIM1 timer has a lot more options than the SysTick timer. You can find the settings in Chapter 30 of the STM

Setting up the TIM1 timer has a lot more options than the SysTick timer. You can find the settings in Chapter 30 of the STM manual, and also in Chapter 153 of the textbook (specifically example 15-4). You will need to set the following fields. Write the values to mask/set no mask is needed you can let that blank You can use predefined names for the bits rather than raw hex values

Set TIM1 - CRI for the counting direction to be up MASK CRI VALUE CRI-

MSI clock for this lab. Set the prescaler TIM1 PSC to count at We will use a 4M 100H MASK PSC - VALUE PSC

Set the TIM1-> ARR register to a value that will give a period of 0.01s MASK ARR VALUE ARR

Clear the OCIM field in the TIM1 -> CCMR1 register and select PWM Mode 1 (OCIM 110): MASK CCMR1 - VALUE CCMR1 =

Enable the Output preload enable in TIM1-CCMRI: MASK CCMR1 VALUE CCMR1

Select the output polarity by clearing the CCINP Reld in the TIM1-CCER register MASK CCMR1 - VALUE CCMR1 =

Enable complementary output of Channel 1 (CHIN) by setting the CCINE bit in TIMICCER MASK CCER VALUE CCER

Set the main output enable (MOE) in TIM1-BDTR:

VALUE BDTR - Set the output compare register for channel 1 TIMI.

CCR1 to have a duty cycle of 50 MASK CCRL- VALUE CCR. Part C Servo Motor Control Suppose the PWM signal period is 20 ms (50 Hz) TIMPSC TIMI ARR Calculate the value of CCRI and complete the following table: Servo Motor Position Pulse Width Value of TIM1-CCR1 -90 1 ms 15 ms 90

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!