0
0
Embedded Cprogramming~10 mins

Timer prescaler and clock division in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the timer prescaler to divide the clock by 8.

Embedded C
TIM->PSC = [1] - 1;
Drag options to blanks, or click blank then click option'
A8
B4
C2
D16
Attempts:
3 left
💡 Hint
Common Mistakes
Setting PSC directly to 8 instead of 7.
Confusing prescaler value with division factor.
2fill in blank
medium

Complete the code to configure the timer clock division to divide by 4.

Embedded C
TIM->CR1 |= [1];
Drag options to blanks, or click blank then click option'
ATIM_CR1_CKD_1
BTIM_CR1_CKD_0
CTIM_CR1_CKD_0 | TIM_CR1_CKD_1
DTIM_CR1_CKD_2
Attempts:
3 left
💡 Hint
Common Mistakes
Using only TIM_CR1_CKD_0 which sets division by 2.
Combining bits incorrectly.
3fill in blank
hard

Fix the error in the code to correctly set the prescaler for a 1 MHz timer clock from an 8 MHz source.

Embedded C
TIM->PSC = [1];
Drag options to blanks, or click blank then click option'
A1
B8
C7
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting PSC to 8 instead of 7.
Setting PSC to 0 which means no division.
4fill in blank
hard

Fill both blanks to create a timer configuration that sets prescaler to divide by 16 and clock division to divide by 2.

Embedded C
TIM->PSC = [1] - 1;
TIM->CR1 |= [2];
Drag options to blanks, or click blank then click option'
A16
BTIM_CR1_CKD_0
CTIM_CR1_CKD_1
D8
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong prescaler value.
Setting wrong clock division bits.
5fill in blank
hard

Fill all three blanks to configure a timer with prescaler dividing by 10, clock division dividing by 4, and enable the timer counter.

Embedded C
TIM->PSC = [1] - 1;
TIM->CR1 |= [2];
TIM->CR1 |= [3];
Drag options to blanks, or click blank then click option'
A10
BTIM_CR1_CKD_1
CTIM_CR1_CEN
DTIM_CR1_CKD_0
Attempts:
3 left
💡 Hint
Common Mistakes
Not subtracting 1 for prescaler.
Using wrong clock division bits.
Forgetting to enable the counter.