Timer Counters, Serial Data incl SPI Flashcards
What are the basic functions of a counter?
To count based on the comparison of input signals.
To generate pulses based upon inputs and register values.
What is Pulse Width Modulation?
An approximation of analogue output.
What are the main applications of Counter/Timer?
PWM.
Generating a frequency (tone).
Counting high frequency pulses.
Describe PWM.
TCNTn starts at zero and increases upon every clock signal on input to the counter.
The value in the counter register TCNTn increases continuously until it equals the value in the Output Compare Register.
The output which was previously high now switches to low.
The counter carries on increasing, even though the output is now low, until the counter contains the maximum value it can.
When the counter hits the maximum value it wraps back around to zero, setting the output high and it starts again.
The larger the number placed in the OCR, the longer the output stays high.
How does a counter generate a frequency (tone)?
TCNTn starts at zero and increases upon every clock signal on input to the counter.
The value in the counter register TCNTn increases continuously until it equals the value in the Output Compare Register.
When it reaches this value it swaps the state of the output pin ans resets TCNTn to zero.
If the value in OCR is large, a low frequency is generated as there is a long time between the changes of state of the output pin.
If the value in the OCR is small, a high frequency is generated as there is a short time between the changes of state of the output pin.
How does a counter count high frequency pulses?
A counter can generate pulses up to 1MHz.
Every pulse increments the counter by 1.
A high frequency signal would cause the counter to wrap around very quickly.
Every 65536 pules the counter wraps around to zero.
What is the difference between series and parallel data transfer?
Parallel data transfer involves transferring all 8 bits simultaneously.
It needs 8 wires plus ground.
Parallel data transfer is OK for short distances but impractical for long distances due to having lots of wires.
Series data transfer involves transferring 1 bit at a time.
It only needs 1 wire plus ground.
Describe Serial Peripheral Interface.
One master device can communicate both ways with multiple slave devices.
There are 3 common wires between all slave: MOSI, MISO, Clock.
To communicate with a slave, select it by making its slave select line low.