















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
its for cmp3006 and 3010 some of the university notes it will be help
Typology: Lecture notes
1 / 23
This page cannot be seen from the preview
Don't miss anything!
Atmega 328 Pinout
Analog Interfacing
Converts Analog Signal to Digital number
Sensor
Component
Analog Voltage (0V - 5V)
Single Bit
Button
Two state (HIGH/LOW)
Sensor/
Button
HIGH/LOW
Asynchronous Communication
UART (Serial Port)
No synchronization on sending & recieveing
Both sides must agree on the transmission speed (e.g. 9600bps)
They are supposed to run at precisely the same rate
Synchronous Communication
Synchronization on sending & recieveing
Uses separate line for clock signal to synchronize
They run at precisely the same rate with the clock signal
SPI: Serial Peripheral Interface
SPI: Serial Peripheral Interface
SPI OVERVIEW – THE REGISTERS
SPI REGISTERS
The SPSR register contains the SPIF flag. The flag is set when 8 data bits have been
transferred from the master to the slave.
The WCOL flag is set if the SPI Data Register (SPDR) is written during the data transfer
process.
Setting bit SPE bit enables the SPI
SPCR
This bit causes the SPI interrupt to be executed if the SPIF bit in the SPSR Register is set and if the
Global Interrupt Enable bit in SREG is set. For our design example we will be polling the SPIF bit.
Consequently, we will leave the SPIE bit in its default (SPIE = 0) state.
When the SPE bit is one, the SPI is enabled. This bit must be set to enable any SPI operations.
Data Order = 0 When the DORD bit is one (DORD = 1), the LSB of the data word is transmitted
first, otherwise the MSB of the data word is transmitted first.
This bit selects Master SPI mode when set to one, and Slave SPI mode when cleared
SPCR
The Clock Polarity (CPOL) and Clock Phase (CPHA) bits define how serial data is transferred
between the master and the slave.
SS Pin
You can set the direction to output and SPI will not control the pin
If you set the direction to input, It should be externally pulled up
if you make it externally low, the SPI module stops working in master mode and switches to slave mode by clearing
the MSTR bit in SPCR, and then sets the SPIF bit in SPSR.
SS pin is always input and you can not control it by software.
You should hold it externally low to activate the SPI.
When SS is driven high, SPI is disabled and all pins of SPI are input. Also the SPI module will
immediately clear any partially received data in the shift register BUT IT WILL NOT BE
Master Operating Mode
Note: After the transmission, the byte in the Master shift register is moved to the Slave Shift
register and the Byte in the Slave shift register is moved to the Master shift register. It means
that send and received happens at the same time. If you only want to read a byte, you should
transmit a dummy byte like 0xff and then read the received data!