0
0
Embedded Cprogramming~10 mins

Input capture mode 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 initialize the input capture mode on Timer1.

Embedded C
TCCR1B = (1 << ICES1) | (1 << [1]);
Drag options to blanks, or click blank then click option'
ACS12
BCS11
CCS10
DICNC1
Attempts:
3 left
💡 Hint
Common Mistakes
Using ICNC1 instead of a clock select bit.
Choosing CS11 or CS12 which set different prescalers.
2fill in blank
medium

Complete the code to enable the input capture interrupt.

Embedded C
TIMSK1 |= (1 << [1]);
Drag options to blanks, or click blank then click option'
AICIE1
BOCIE1A
COCIE1B
DTOIE1
Attempts:
3 left
💡 Hint
Common Mistakes
Using TOIE1 which is for overflow interrupt.
Using output compare interrupt enables OCIE1A or OCIE1B.
3fill in blank
hard

Fix the error in the input capture ISR declaration.

Embedded C
ISR(TIMER1_[1]_vect) {
    // Handle input capture event
}
Drag options to blanks, or click blank then click option'
ACAPT
BCOMPA
COVF
DCAPTURE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CAPTURE' instead of 'CAPT'.
Using overflow (OVF) or compare (COMPA) vectors by mistake.
4fill in blank
hard

Fill both blanks to configure input capture to trigger on falling edge and enable noise canceler.

Embedded C
TCCR1B = (0 << [1]) | (1 << [2]);
Drag options to blanks, or click blank then click option'
AICES1
BICNC1
CCS10
DCS11
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing ICES1 and ICNC1 bits.
Using clock select bits instead of these control bits.
5fill in blank
hard

Fill all three blanks to read the input capture value, clear the flag, and start the timer with no prescaling.

Embedded C
uint16_t capture = ICR1;
TIFR1 |= (1 << [1]);
TCCR1B = (1 << [2]) | (0 << [3]);
Drag options to blanks, or click blank then click option'
AICF1
BCS10
CICES1
DTOIE1
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to clear the overflow flag instead of input capture flag.
Using wrong bits to start the timer.
Confusing edge select bit with timer start bits.