SYSC3320 - UART, I2C, SPI

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:18 PM on 4/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

UART basics

  • serial communication

  • asynchrnous

  • tx and rx wires

  • data sent bit by bit

  • Start bit (low for one clock cycle) followed by 8 bits (8 bits) + parity bit

  • Stop bit is high for one cycle

  • Send text in ascii

<ul><li><p>serial communication</p></li><li><p>asynchrnous</p></li><li><p>tx and rx wires</p></li><li><p>data sent bit by bit</p></li><li><p>Start bit (low for one clock cycle) followed by 8 bits (8 bits) + parity bit</p></li><li><p>Stop bit is high for one cycle</p></li><li><p>Send text in ascii</p></li></ul><p></p>
2
New cards

Serial communciation vs parallel

1 bit at time

Reliable (less clock skews across differnet wires and crosstalk)

Higher clock rate

Low cost and weight

3
New cards

Synchronous transmissions

  • common clock shared by sender and receiver

  • efficeint transmission since only one wire for data transfer

  • More costly since an extra clock wire is needed

4
New cards

Asyhcnrnous tranmission

  • no clock signal sent

  • both must agree on a rate in advance

    • speacial bits sent to synchrnoize transmission

5
New cards

Simplex

Data transmitted only in one direction

6
New cards

Full duplex

Both direction tranmssion (UART and SPI)

7
New cards

Half duplex

Data can be transmitted in one direction at a time (I2C and CAN)

8
New cards

I2C overview

  • SDA and SCL lines that are normally pulled high

  • multiple devices share a serial bus

  • subordinates respond when addressed

  • Devices have 7 bit address

Sequence:

  1. Generate start bit (low) then address + receive/send signal

  2. Slave checks address. Slave responds with ack if match otherwise nothing.

  3. Master receives or sends data depding on send/receive signal. If master is seniding the data, then the slave will ACK after each byte.

  4. Master sends stop bit (high)

<ul><li><p>SDA and SCL lines that are normally pulled high</p></li><li><p>multiple devices share a serial bus</p></li><li><p>subordinates respond when addressed</p></li><li><p>Devices have 7 bit address</p></li></ul><p>Sequence:</p><ol><li><p>Generate start bit (low) then address + receive/send signal</p></li><li><p>Slave checks address. Slave responds with ack if match otherwise nothing.</p></li><li><p>Master receives or sends data depding on send/receive signal. If master is seniding the data, then the slave will ACK after each byte.</p></li><li><p>Master sends stop bit (high)</p></li></ol><p></p>
9
New cards

I2C code

LookupConfig

CfgInitialize(XIicPs_Config, Config, Config->BaseAddress);

XIicPs_SetClk(&IicInstance, IIC_SCLK_RATE);

// Send data
u8 SendBuffe3r[TEST_BUFFER_SIZE];
u8 RecvBuffer[TEST_BUFFER_SIZE];
u8 SimulatedSlaveEcho[TEST_BUFFER_SIZE]; // to simulate slave response

for (int i = 0; i < TESTBUFFERSIZE; i++) {
sendbuffer[i] = i + 1;
RecvBuffer[i] = 0;
SimulatedSlaveEcho[i] = SendBuffer[i]; //pretend slave received

print everyhting if you like
}

// Master send
Status = XIicPs_MasterSendPolled(&IicInstance, SendBuffer, TEST_BUFFER_SIZE, IIC_SLAVE_ADDR);

// wait until not busy
while (XIicPs_BusIsBusy(&IicInstance));

// Simulate receive
memcpy(RecvBuffer, SimulatedSlaveEcho, TEST_BUFFER_SIZE);

// print sent data
// print received data
// check that each byte matches otherwise return XST_FAILURE;

10
New cards

SPI code

lookup config
cfgintialize

XSpi_SelfTest // self test

// Setup interrupt system
SetupInterruptSystem
// Register interrupt handler for SPI
XSpi_SetStatusHandler(SpiInstancePtr, SpiInstancePtr, (XSpi_StatusHandler)SpiIntrHandler);

XSpi_SetOptions(SpiInstancePtr, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION)

// Manually select slave
XSpi_SetSlaveSelect(SPIInstancePrt, 0x01);

XSpi_Start(SPiInstancPtr);

Setup write and read buffers



TransferInProgress = TRUE; // volatile + static var

XSpi_Transfer(SpiInstancePtr, WriteBuffer, ReadBuffer, BUFFER_SIZE);

while (TransferInProgress); // Updated by interrupt handler

// Check WriteBuffer against ReadBuffer

void SpiIntrHandler(void *CallbackRef, u32 StatusEvent, unsigned int ByteCount) {

if statusevent != XST_SPI_TRANSFER_DONE: errorcount++

TransferInProgress = FALSE;

}