Interfacing Devices using SPI

 

COMSATS UNIVERSITY ISLAMABAD

MICROPROCESSOR SYSTEMS AND INTERFACING

 

LAB REPORT #12

 

SUBMITTED TO:

SIR KHIYAM IFTIKHAR

SUBMITTED BY: -

S/NO

NAME

REG NO

1

JUNAID AHMAD

CIIT/FA19-BEE-089/ISB

2

IBRAR AHMAD

CIIT/FA19-BEE-083/ISB

3

JARRAR MALIK

CIIT/FA19-BEE-087/ISB

 

 

DATE:

18-12-2021

 

 

 

 

Lab # 12: Interfacing Devices using SPI

EXPLANATION ABOUT SPI:

Serial Peripheral Interface (SPI) is an interface bus commonly used to send data between microcontrollers and small peripherals such as shift registers, sensors, and SD cards. It uses separate clock and data lines, along with a select line to choose the device you wish to talk to. SPI works in a slightly different manner. It’s a “synchronous” data bus, which means that it uses separate lines for data and a “clock” that keeps both sides in perfect sync. The clock is an oscillating signal that tells the receiver exactly when to sample the bits on the data line. This could be the rising (low to high) or falling (high to low) edge of the clock signal; the datasheet will specify which one to use. When the receiver detects that edge, it will immediately look at the data line to read the next bit.



In Lab Task:

SPI Programming in AVR:

The given code contains functions to write bytes to SPI and writing to DAC. Your task is to write code to send a sequence of numbers to the DAC to generate a saw-tooth wave. Use gain =2x

CODE:




CIRCUIT DIAGRAM:



SIMULATIONS:



 CRITICAL ANALYSIS

In this lab I learnt about the features and characteristics of SPI (serial peripheral interfacing) which is used to communicate the microcontroller with registers and SD cards. It has 4 lines or more which work synchronously. SPI consists of two shift or more registers. One at master side, others at slave side. In SPI, only one side generates the clock signal. The side that generates the clock is called the “master”, and the other side is called the “slave”. There is always only one master (which is almost always your microcontroller), but there can be multiple slaves. When data is sent from the master to a slave, it’s sent on a data line called MOSI, for “Master Out / Slave In”. moreover, I got to know that it works in slave or master mode and in order to select these modes first we put the values in CPOL  and CPHA which are actually bits of SPCR representing polarity and phase, also Digital to Analog converter  MCP4821 was used and it was communicated through SPI protocol which produced a sawtooth  waves as observed in lab task.

 

إرسال تعليق

Post a Comment (0)

أحدث أقدم