2 Microcontrollers Flashcards

1
Q

What is a microcontroller?

A

A microprocessor with RAM, Permanent memory, Digital I/O and other peripherals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the registers that control the ports of a microcontroller?

A
  • DDRA, DDRB: Data direction
  • PORTA, PORTB: Outputs / pull-up resistors
  • PINA, PINB: Input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is bouncing?

A

Bouncing is short signal fluctuations before a signal change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Choose Interrupts or Polling for the following scenarios and explain your choice.

(1) The ”change input”-button on a monitor

A

1) Interrupts. Due to the rarity of this signal, Polling would waste a lot of CPUressources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Choose Interrupts or Polling for the following scenarios and explain your choice.

(2) The wireless-reciever of a garage-opener

A

2) Depends. Again the scarcity of such signals would make Interrupts preferable,however since there might be a lot of signal-noise and erroneous garage-openingswould be a security concern Polling would be preferable in that regard.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Choose Interrupts or Polling for the following scenarios and explain your choice.

(3) The keyboard on a standard desktop

A

3) Polling. Interrupts could cause programm pausations in undesired moments.Additionally often we would also like to know if a key was pressed for x amount ofseconds which would not be measurable with Interrupts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Choose Interrupts or Polling for the following scenarios and explain your choice.

(4) The temperature-sensor of a weather-station

A

4) Polling. This allows for better planability of ressource usage. (I.e. how would onescale Interrupts to get high enough detail without having a lot of interrupts whentemperature changes quickly)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How is an ISR done?

A

► ISR is triggered by event
▪ Save return address (PC) to stack
▪ Clear global interrupt enable bit (I bit)
▪ Clear interrupt flag bit (usually)
▪ Jump to corresponding interrupt vector table entry (interrupt vector)
► Execute jump instruction at interrupt vector
► Save additional context (anything not automatically saved by hardware)
► Execute ISR body
► Restore context
► Leave ISR by assembly instruction RETI
▪ Return to PC popped from stack
▪ Set global interrupt enable bit (maybe delayed)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a counter?

A

Hardware unit that counts external events (Rising edges, falling edges, arbitrary edges)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a timer?

A

Special counter that counts clock cycles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is the reading and writing of a 16 bit value made atomic?

A

Parallel reading and writing by Reading the Low-Byte and Writing the High-Byte first, then vice-versa. (However disabling ISR is neccessary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Watchdog?

A

A watchdog is a timer that counts from an initial value to zero. When zero is reached, the μC is restarted. In the main loop of the program, the watchdog counter is reset tothe initial value.This is useful to recover from unintended infinite loops: When themain loop is not executed for too long, the Microcontroller restarts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why might it be necessary to temporarily disable interrupts when reading 16 bitvalues?

A

Reading 16 bit values requires two cycles (on 8-bit platforms). Interrupts could occurbetween those two cycles and could corrupt the 16-bit value that is accessed by themain program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What analog devices can be found on a ATmega16?

A
  • 4 PWM channels
  • an 8-channel-10-bit A/D converter (Successive ApproximationConverter)
  • an Analog comparator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is PWM and how does it work?

A

Pulse width modulation

  • produces a rectangular signal
  • with a configurable frequency and high time.

PWM is a

  • hardware feature
  • that usually can produce signals with a much higher frequency than would be possible by producing the signal in software.

PWM can be used to
- reduce the average voltage delivered on a PIN.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the disadvantages of the binary weighted resistor circuit?

A

Many different types resistors or many resistors are needed for BWRC (or many resistors of the same type in series, which is not preferable in practice).

–> This leads to either bad quality of the produced voltage level due to different deviations from the nominal value of the resistances, or to high costs if high-precision resistances are used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Usual properties of digital I/O pins

A

▪ are grouped into ports of 8 pins (on 8-bit architecture).
▪ are bidirectional (i.e., can be used as input or output pins)
▪ can have alternate functions (i.e., can be used for purposes different than
digital I/O, e.g., as analog I/O pins)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the meaning of DDR?

A

Data Direction Register

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What ist the meaning of PORT?

A

Port Register

20
Q

What is the meaning of PIN?

A

Port Input Register

21
Q

Properties of DDR:

A

▪ read/write
▪ specifies for each bit of the corresponding port whether it is an input or
an output bit

22
Q

Properties of PORT:

A

▪ read/write
▪ specifies for the output pins whether the output value is high or low
▪ ATmega16: also used for controlling pull-up resistors for input pins (see
next slides)

23
Q

Properties of PIN:

A

▪ read only (writing has no effect or unintuitive semantics)
▪ contains the current value (high or low) of all pins (input and output)
▪ usual purpose: reading values of input pins

24
Q

What is polling?

A

▪ Periodically check for event
▪ Disadvantages:
• Waste of CPU time if the event occurs infrequently
• Polling sequence has to fit in the rest of the code
(hard to modify or extend)

25
Q

What are interrupts (IRs)

A

▪ MCU polls the signal and interrupts the main program if a state change is detected.
▪ MCU calls an interrupt service routine (ISR) which handles the event

26
Q

What is the meaning of ISR?

A

Interrupt Service Routine

27
Q

When Interrupts should be favored?

A

▪ Event occurs infrequently
▪ Long intervals between two events
▪ The exact time of the state change is important
▪ Short impulses, polling might miss them
▪ Nothing else to do in main, could enter sleep mode

28
Q

When Polling should be favored?

A

▪ No precise timing is necessary
▪ The state is important
▪ Impulses are long
▪ The signal is noisy (Interrupts would be triggered very often)

29
Q

A long ISR delays the main program for a long time! How would you do to avoid this situation?

A

Sometimes it is useful to move some of the ISR code to the main routine.

30
Q

Which side effects have to be considered if more than one IR is used?

A

▪ The execution of an ISR delays the reaction on all other IRs.
▪ The order of IR events may have influence on the behavior.
▪ Results in complex timing (cf. lectures on real time)

31
Q

On which register Timer/Counter are based on?

A

A counter register, which can be incremented or decremented

32
Q

Important for the behavior of the Timer/Counter is (are) the according control register(s):

A

▪ mode of operation
▪ which prescaler to use (timer)
▪ start & stop counting
▪ enable/disable interrupts

▪ (often also a compare register additionally)

33
Q

What are other features of Timer/Counter than just counting events and measuring time?

A

Input capture
• Used to timestamp (mostly external) events
• Whenever the event occurs, the timer automatically
copies its current count value to an input capture
register

Output compare
• Used to generate signals
• Whenever a certain timer value is reached, the
output compare event is triggered (can
automatically set or clear an output line).

Pulse Width Modulation (PWM)
• Special case of output compare
• Timer generates a periodic digital output signal
with configurable high-time and period.

34
Q

RC low-pass filter properties:

A
► Simple and cheap
► 1-PIN
► Uses PWM
► Proportional to PWM (high-time/period)
► Low quality
► Initially delayed (by charging time)
35
Q

What are the properties of a Flash Converter?

A

► Direct application of DAC principle
► Flash means fast: Simultaneous check
► Complexity of converter: 2r-1 comparators needed for encoding
► Thus expensive

36
Q

What are the Properties of an Analog Comparator?

A
► Compares simply V1 and V2
► Output 1 when V1 > V2
► Else 0
► Suffers from meta-stability
► Obviously 1 bit
► Basis for more complex solution
37
Q

What are the properties of the Tracking Converter?

A

► DAC used to do ADC
► Counter holds digital estimate of value
► Counter changed linearly according to
outcome of comparator
► Sample and hold
► Disadvantage: Tracking takes some time, worst case
𝒪(2^(𝑟)), –> 00000 →00001 →00010 →… →01110 →01111 →01110 →…
► In the beginning not precise

38
Q

What are the properties of a sucessive Approximation Converter?

A

► Has a successive approximation register (SAR)
► More sophisticated algorithm for approximation used than with the tracking converter:
▪ Starts with 𝑏it 2^(𝑟−1)
▪ Changes are made in exponential steps
▪ Only, but always r comparisons needed, 𝒪(𝑟)

39
Q

What errors can occur during the analog to digital conversion?

A
  • Offset Error
  • Gain Error
  • Differential Non-Linearity
40
Q

Explain the effect of Aliasing

A

► Signal has a higher frequency than conversion
► Shannon criterion not met
► Converted signal is only an “alias” of original signal
► Anti-aliasing filters are low-pass filter

41
Q

What are the conditions for an ISR?

A

Conditions:

  • Global Interrupt Enable Bit = 1
  • Specific Interrupt Enable Bit = 1
  • Specific Interrupt Flag = 1
42
Q

What types of edges does a counter contain?

A
  • rising edges
  • falling edges
  • arbitrary edges
43
Q

Methods for ADC:

A

▪ Simple: Analog Comparator
▪ Flash Converter
▪ Tracking Converter
▪ Successive Approximation Converter

44
Q

Methods for DAC

A

▪ RC low-pass filter
▪ Binary weighted resistor circuit
▪ R-2R ladder

45
Q

How to calculate the average voltage (value of the signal) for PWM?

A

value=(hightime/period)·VCC