I2C and SPI on a PCB Explained!

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ค. 2024
  • Tech Consultant Zach Peterson looks at two very important protocols for integrated circuits: I2C or Inter-Integrated Circuit Protocol and SPI or Serial Peripheral Interface Protocol. Zach examines how these two common protocols are used on the PCB, as well as a few of the factors that influence their operation.
    0:00 Intro
    0:42 I2C Overview
    3:18 Rise Time?
    5:44 SPI Overview
    9:47 Trace Impedance
    For more PCB Routing videos, click here: • PCB Routing
    For more PCB Design for Beginners videos, click here: • PCB Design for Beginners
    For more Tech Consultant Zach Peterson videos, click here: • Technical Consultant Z...
    👉 Is There an SPI Trace Impedance Requirement?: resources.altium.com/p/there-...
    👉 Serial Communications Protocols Part 5 - SPI Standard: resources.altium.com/p/serial...
    👉 15 Days Free Altium Designer Access: altium.com/yt/altium-academy
    Don't forget to follow us on social to stay up-to-date on the latest Altium Academy content.
    👉 Follow Altium on Twitter: / altium
    👉 Follow Altium on Linkedin: / altium
    👉 Follow Altium on Facebook: / altiumofficial
    👉 Ready to try the industry's best-in-class design experience yourself? Download it today and get started! www.altium.com/downloads?utm_...
    The Altium Academy is an online experience created to bring modern education to PCB Designers and Engineers all across the world. Here you can access a vast library of free training and educational content covering everything from basic design to advanced principles and step-by-step walkthroughs. Join industry legends as they share their career knowledge, review real-life design projects, or learn how to leverage one of Altium's leading design tools. No matter your level of experience, the Altium Academy can help you become a better Designer and Engineer!
    About Altium LLC
    Altium LLC (ASX:ALU), a global software company based in San Diego, California, is accelerating the pace of innovation through electronics. From individual inventors to multinational corporations, more PCB designers and engineers choose Altium software to design and realize electronics-based products.
    #Altium #PCBdesign #ElectronicsDesign
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 114

  • @lbgstzockt8493
    @lbgstzockt8493 ปีที่แล้ว +57

    The fact that all this knowledge is available for free here is amazing, thanks to Altium for making these videos and thank you Zach for explaining so well!

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +1

      You're very welcome!

    • @TheJcrist
      @TheJcrist ปีที่แล้ว

      This is physics, it is common knowledge. Not a secret

  • @exapod23
    @exapod23 ปีที่แล้ว +25

    Excellent explanation of the SPI "impedance matching".

  • @hariharan309
    @hariharan309 ปีที่แล้ว

    It can't get anymore simple than this. Thank you soo much howtobasic!

  • @kkugathasan2777
    @kkugathasan2777 ปีที่แล้ว

    So thankful for this

  • @user.w18
    @user.w18 ปีที่แล้ว +7

    I have seen such resistors with an SPI memory design, and that stayed looping in my mind looking to what the use of such small resistors and why not something high like driving a diode (At level of 100's or K's).
    Thank you very much for educative video is comes on time for me. BTW, I like your PCB series, it is hard to find such resources and learn about hidden tricks.

  • @eduardohernandotorres6995
    @eduardohernandotorres6995 ปีที่แล้ว +13

    Great video as always with Zachariah! Years of using I2C and SPI Buses just following the guidelines (and it always worked) but I had never stopped to think that the limitations were related to the OpenDrain and pushpull topollogies of each one.
    I love these videos because they make you actually think and understand what you are doing.

  • @manyirons
    @manyirons ปีที่แล้ว +7

    Clear, informative, and exactly my speed. Thank you!

  • @myetis1990
    @myetis1990 ปีที่แล้ว +8

    I love this channel because it teaches how to fish instead of giving fish. Thanks my best HW teacher Zach Peterson :)

  • @christopherleadholm6677
    @christopherleadholm6677 ปีที่แล้ว +1

    Thank you for this. Confirmed a few things I had already thought. Awesome.

  • @khanglam706
    @khanglam706 10 หลายเดือนก่อน

    Awesome
    Video!
    Wanted to know how to test these peripherals In a software testing role

  • @RedRacconKing
    @RedRacconKing ปีที่แล้ว +1

    Very useful info for my undergrad senior project! Thanks, Zack!

  • @Bianchi77
    @Bianchi77 4 หลายเดือนก่อน

    Nice info, well done, thanks for sharing it with us :)

  • @leeslevin7602
    @leeslevin7602 ปีที่แล้ว +4

    Fantastic, thank you for clearing up the misconceptions regarding Impedance matching, until now I wasn't sure if I should implement controlled impedance for I2C & SPI.

  • @spencerhanson7808
    @spencerhanson7808 ปีที่แล้ว +4

    I appreciate SO much that you say what abbreviations are! If anyone disagrees, find an abbreviated diagram of the coagulation cascade, Kreb Cycle, or any other biological diagram. If you understood those without prior knowledge of what those abbreviations stood for, I'll tone down my excitement. 😄

  • @antonincerny6684
    @antonincerny6684 ปีที่แล้ว

    Nice video!

  • @Lionel_Walder
    @Lionel_Walder ปีที่แล้ว

    Merci beaucoup, ça me démystifie ces 2 protocoles dont l'I2C que je prévois de faire un PCB

  • @tolikche
    @tolikche ปีที่แล้ว +3

    Thanks for the video) Can you talk more about SPI bus tips and tricks like optimal level shifting technics or pull-up/down resistors.

  • @helmutzollner5496
    @helmutzollner5496 ปีที่แล้ว

    Very interesting. Thank you.

  • @shafi.j
    @shafi.j ปีที่แล้ว

    Old electronics servicing peoples like me 40 years before studied person will not not these communication but we are trying to work in this your videos is very useful 👍

  • @mahdizadeali3181
    @mahdizadeali3181 11 หลายเดือนก่อน

    good, thanks

  • @sailtogether3236
    @sailtogether3236 2 หลายเดือนก่อน

    Thank you! Please tell us more themes about developing PCBs.

    • @AltiumAcademy
      @AltiumAcademy  2 หลายเดือนก่อน

      We’ve got a ton on the channel! What kind of thing are you looking for?

  • @hobibilgisi7177
    @hobibilgisi7177 ปีที่แล้ว

    thanks

  • @Bajran_
    @Bajran_ ปีที่แล้ว +1

    Great, Thank you :)

  • @AleTheGoat0
    @AleTheGoat0 6 หลายเดือนก่อน

    Very informational video that clearly describes how I2C and SPI work on a PCB. My question is how would a layer stack up look like for those examples?

    • @Zachariah-Peterson
      @Zachariah-Peterson 5 หลายเดือนก่อน

      Thank you, layer stackups for these interfaces are quite simple. I2C is basically a slower interface when run in standard mode, its rise time can be on the order of microseconds. With the rise time being that slow a 2-layer board with ground fill on the back layer, or with a ground wire running along the traces, should be enough to suppress radiation. In fast mode and on some modern processors/advanced FPGAs it can have faster rise time and it can get below 100 ns in the fastest cases, for that it is best to use ground fill to help suppress noise if you use 2 layer board. For SPI, the rise time can be very fast, when slower a 2-layer board with ground fill around traces and ground fill on back layer should be okay. In the fastest components with SPI, a 4 layer board might be needed, but those components with

  • @gazzacroy
    @gazzacroy ปีที่แล้ว

    really good video cool stuff, very helpful :)

  • @jasin9413
    @jasin9413 ปีที่แล้ว +1

    Amazing

  • @maheshpalika8985
    @maheshpalika8985 ปีที่แล้ว

    How to validate the spi flash memories.
    What are the things we have to consider.

  • @ThermalWorld_
    @ThermalWorld_ ปีที่แล้ว +1

    Excellent 😁

  • @1828fernando
    @1828fernando ปีที่แล้ว +3

    Great video!!!

  • @amyzhu7386
    @amyzhu7386 11 หลายเดือนก่อน

    Hi Zach, i'm studying on I2C electrical specification recently.
    and i have a question on the validation item--> setup time for re-start condition.
    i'm wondering why it's more important to define setup time for re-start condition than setup time for START condition?
    i think it's neccessary to define setup time for start condition since there's always a START on every transmitting procedure.
    but the re-start condition isn't that frequently appeared.
    do you have any idea on this?
    appreciate if you reply, thanks

  • @GoogleUser-uw2yu
    @GoogleUser-uw2yu ปีที่แล้ว

    You are awesome! 👏

  • @kmacademy6742
    @kmacademy6742 ปีที่แล้ว +6

    Excellent video, please do SDIO/MMC and DDR next.

  • @mortezaghorbani7927
    @mortezaghorbani7927 9 หลายเดือนก่อน

    Very useful info. please make more videos on series and parallel termination resistor reasons and how to route them. for example, using series termination on EXT SDRAM CLK or Parallel Termination ON Diff Pair CLKs Cases. In my case, we have a graphical Circuit with EXT SDRAM as FrameBuffer and MIPI-DSI as LCD Interface but the Data gets Corrupted. using termination can help? How Much Length match will be fine for EXT SDRAM Signals? It's On Two Layer Board With STM32F7 On Top and EXT SDRAM On the Bottom side beneath the Microcontroller and MIPI DSI Lanes as close as possible to the Micro Pins (Around 23 mm Away). All SDRAM Signals Are Between 18 to 37 mm Long Traces, and Delays On ACC, BL0, and BL1 Groups are less than 100ps. What Will be the reasons for Corrupted Data, Data Gets to the LCD But It Gets Corruption in Nearby pixels. Using 4 Layer PCB Can Solve the Problem?

    • @Zachariah-Peterson
      @Zachariah-Peterson 8 หลายเดือนก่อน +1

      If you are not doing MIPI DSI and SDRAM routing on a 4 layer board, then I am not surprised that you are having a problem. I do not know if it is specifically crosstalk or you did not design to the correct impedance, but if you have an interface like DSI or SDRAM then you must design to the correct impedance. Don't use these things like critical length rule because everyone uses them incorrectly (I explained why in another video). And don't apply termination to a component that has an interface with an impedance requirement; that impedance requirement means that the traces just need to be designed to that impedance; the termination circuit will already exist on the semiconductor die. The only cases where you should be applying any kind of termination circuit with discrete components is when 1) the component datasheet tells you to apply it externally; and 2) you are working with RF components below 5 GHz where the output impedance from your RF source will have some reactance.

  • @VanLav
    @VanLav ปีที่แล้ว +1

    Thank you very much for this awesome educative video. I have one more question, I've seen in some SPI designs that engineers use pull-down resistors(about 1k) between SCK and GND, is this impedance really necessary?

    • @9mmiky
      @9mmiky ปีที่แล้ว +1

      Necessary? Technically no, but its one of those things that if you want to maybe build in a spot to test the line, it is a useful thing to have.

  • @Ghost572
    @Ghost572 ปีที่แล้ว +1

    That is actually a better definition using chip select instead of slave select, just from a memory point of view.

  • @Set5001
    @Set5001 5 หลายเดือนก่อน

    Красавчик, классно объясняешь.

  • @BD002010
    @BD002010 2 หลายเดือนก่อน

    Very good video except for the signal rise time increase from 1ns to 10ns from a 22R termination resistor. I am running 2.5ns rise times with 22R terminators just fine.

    • @Zachariah-Peterson
      @Zachariah-Peterson หลายเดือนก่อน

      Well I just stated those numbers as a conceptual example, it is not a hard rule that it goes from 1ns to 10ns. I have also used some ASICs that also maintain very fast rise time with long traces and with the series resistors.

  • @Bill-qo2jb
    @Bill-qo2jb 10 หลายเดือนก่อน

    For connecting 5V, 3.3V and 1.8V I2C devices to 5V MCU, via I2C voltage level translators, is it better to use these translators between 5V 3.3V and 5V 1.8V, or 5V 3.3V and 3.3V 1.8V ?

  • @GuambraMichelin
    @GuambraMichelin ปีที่แล้ว +1

    Thank you for the video!
    I am actually designing a project which interconnects two PCBs and a use a flat cable between the 2 for I2C. Furthermore, the 2nd pcb is quite long (about 30cm). Are there any further considerations I should take into account for this PCB routing?
    Thank you in advance! 😄 keep it up I am learning tons!

    • @jensschroder8214
      @jensschroder8214 ปีที่แล้ว +1

      Make sure that the GND is always carried solidly.
      Keep the data lines roughly the same length.
      Pullups on both sides can help.
      30cm is short for I2C, but it depends on how fast you run the I2C.
      Faster means shorter.
      Philips invented the I2C bus to make it easier to control the many ICs in radio and tube TV sets.
      The goal was always to implement many tasks flexibly using a bus with few pins.
      Every PC today uses I2C for secondary tasks such as fan control, temperature measurement or LEDs blinking.

    • @DrEMC-sf8rx
      @DrEMC-sf8rx ปีที่แล้ว +2

      Yes
      1) add 15pF caps on SCL and SDA - it helps to filter out noise, which is particularly relevant for long traces/cables
      2) follow 60-40 rule for the 0V pins ratio on FCC cable, i.e. for a 10-pin FCC, 6 pins should be signal, 4 pins should be 0V
      3) I typically add series resistors on SCL and SDA as well on driver side, like Zach said in the video. The frequency of SCL can actually be up to 3.4MHz, depending on the design. There're also practical benefits - they limit current in case of a fault or ESD; it's easier to attach logic analyser to a resistor than to a trace; etc.

  • @rafalzasada8826
    @rafalzasada8826 ปีที่แล้ว +1

    12:45 So if USB requires matched impedance it means they have already build in resistors in transmitters therefore they are already "slowed down". How do you achieve high speed when you have to slow down transmitter for impedance matching?

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +2

      I would not say that they have "slowed down" anything, they have designed the transmitter such that it has a specific rise time measured at the output pin when the signal encounters a 50 Ohm single-ended impedance. They didn't design it to one rise time and then add stuff to slow it down. When you see a rise time spec in a datasheet, that number they quote is the number you can expect to measure on that trace, it doesn't really matter what happens inside the transmitter because they have already designed it to operate with a 50 Ohm trace. This is why you would not intentionally place series resistors on the USB outputs when they are already rated for 50 Ohms single-ended impedance.

  • @user-pn9be1zt7n
    @user-pn9be1zt7n ปีที่แล้ว

    Hi Zack, I watched this video again today and I had one question. When should we terminate a load like 50 ohm near receiver side if the datasheet doesn't point out input impedance inside receiver? From the video, it looks like there's only one termination used for driver side.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +1

      The loads you would place on an SPI/I2C link do not have an impedance specification, they are integrated circuits and they do not have a specific impedance. They are purely voltage controlled so they only have a high input impedance because SPI receiver circuits are essentially FET inputs. Part of the reason for a series terminator on the driver is to slow down the bus a little bit to make up for a low bus/load capacitance, this can help pass EMC but it also matches the impedance when the line is very long. That impedance matching plays a dual role of preventing reflections, but it does this by slowing down the bus so that the bus is always electrically short enough to work properly.

    • @user-pn9be1zt7n
      @user-pn9be1zt7n ปีที่แล้ว

      @@Zachariah-Peterson Thank you, Noted!

  • @Chad_Elliott
    @Chad_Elliott ปีที่แล้ว +1

    thanks bud, dunno what this is but just stoned letting it absorb into my subconscious at its free will

  • @rwinner8901
    @rwinner8901 ปีที่แล้ว +2

    Wait, so how does the series termination resistor limit rise times? I thought it was more to limit signal reflections. To my knowledge using a series resistor would certainly limit the current, but I don't see how it could have a capacitive effect with respect to the rise time. Is there anything I'm missing or over-simplifying here?

    • @yetanotherPC
      @yetanotherPC ปีที่แล้ว +1

      Imagine the resistor and load+bus capacitance as an RC circuit, increasing the resistor value would increase the charge time of the capacitor - equivalent to slowing the rise time

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +1

      Yes the series resistor does limit the rise times. It slows down the edge rate because it is equivalent to adding some DC resistance into a circuit with capacitance (in the lumped element view); this basically adds damping to the transient response. If you had a short connection between the driver and the receiver component, you would get the same effect, you basically have an RC circuit that is charging or discharging, so adding some resistance increases the time constant.

    • @rwinner8901
      @rwinner8901 ปีที่แล้ว

      @@Zachariah-Peterson @Philip Canete, Thanks guys. I guess I forgot about the R part in RC time constants.

  • @user-pn9be1zt7n
    @user-pn9be1zt7n ปีที่แล้ว

    It's a good video. Exactly get how to determine an expected rise time and fall time. But just a little be confused with the Topic, protocol explained. The protocol probably will refer to the rule for transmitter and receiver both when they exchange data. Like how to tell and define start bit, data frame, stop bit, and ack bit.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +3

      Thanks, since this is a PCB channel I wanted to focus on the PCB aspects but we'll put together something on the data formats

    • @BTLag
      @BTLag ปีที่แล้ว

      I agree. "Protocol" is the not the best way to describe what this video is about.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +1

      @@BTLag Well then we change it

  • @Chad_Elliott
    @Chad_Elliott ปีที่แล้ว +2

    looks like ryan from the office :p

  • @Dexter101x
    @Dexter101x ปีที่แล้ว

    Trace impedance, are they the same as those squiggly lines you see on the pcb?

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว

      Impedance is a fundamental property of structures that guide electromagnetic waves. All the copper lines on a PCB are guiding an electromagnetic wave between two components, and these copper lines are called traces. The term "trace impedance" refers to the impedance of these copper lines.

  • @AAAAAA-ny4ib
    @AAAAAA-ny4ib 11 หลายเดือนก่อน

    Hello! I send a data packet "slave func data srs16", but the result is this signal "00 slave func data srs16". Why do two zeros appear? ModbusRTU

    • @Zachariah-Peterson
      @Zachariah-Peterson 11 หลายเดือนก่อน

      I can't answer that I would need to know what component you are referring to.

  • @coderebel3568
    @coderebel3568 11 หลายเดือนก่อน

    What about I2S? I'm a hobbyist who wants to experiment with STM32 and some audio codecs but I tried an AD1937 and can't get it to work. I can get the I2C communication working with it, but I suspect the I2S is suffering from ringing. I think I can actually see some ringing on my scope. But then in some I2S videos on TH-cam I see people soldering loose wires without any concern for impedance at all. So I'm kind of lost. In a design for a Dev kit with this chip, I saw some impedance matching on the I2S lines, just a couple pF and a few ohms. But it's hard to figure out whether I'm dealing with a software issue or whether I did something wrong in my hardware design. Maybe I'm not configuring the codec correctly.. Should I definitely have the codec and STM32 on the same pcb? If so then why does it seem some people can get I2S working over some loose wires? Would you recommend I start with a more simple codec first?

  • @dharmikmistry8781
    @dharmikmistry8781 ปีที่แล้ว +1

    Thank you so much Sir. It cleared my doubts. Is there any requirement of signal's length matching in between MISO, MOSI & SCK ?

    • @jensschroder8214
      @jensschroder8214 ปีที่แล้ว

      Master In Slave Out
      Master Out Slave IN
      SCK Clock
      Chip Select, Low = selected
      The data sheet of the IC gives you the necessary timing specifications.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +2

      Not in the same sense that we think about length matching or timing in a parallel bus like DDR4. There is a timing requirement between the clock and signal, but that is a pretty generous limit. IF you want to try and apply length matching rules from a high-speed design to SPI, just stop and think about the rise times I've listed here... You're generally going to be in the nanosecond range and there will be some timing spec to be met at the receiver. Just as an example, let's say we have a 1 ns signal on a Dk = 4 laminate (internal layer for convenience), the length traveled by the signal during its rise time is 15 cm. If, for length matching on a parallel bus, you take a 25% UI value for the allowed skew between sigansl then you get a 3.75 cm allowed mismatch between two signals. The timing spec for that pair of signals might produce a distance mismatch of a similar value. Just make sure you look at the datasheet for the receiver to get the required timing spec and use that to determine an allowed length mismatch.

    • @dharmikmistry8781
      @dharmikmistry8781 ปีที่แล้ว

      @@Zachariah-Peterson thank you so much sir. 👍

  • @elecengguide
    @elecengguide หลายเดือนก่อน

    I have always wondered why there were 33ohm resistors in series on CS pins ... some datasheets are poorly written

    • @Zachariah-Peterson
      @Zachariah-Peterson 13 วันที่ผ่านมา +1

      Sometimes it's not even mentioned in datasheets, and there is not a specific method to calculate.

  • @SirioAstarot
    @SirioAstarot 10 หลายเดือนก่อน

    How working the signal I3S and Slimbus?

    • @Zachariah-Peterson
      @Zachariah-Peterson 10 หลายเดือนก่อน

      That would be a really great topic, I do not use I3C often but I should do a video on it!

  • @Ibrahim-rw4zq
    @Ibrahim-rw4zq ปีที่แล้ว +1

    Execuse me sir, here by rise time do you mean the time required for the signal to go high from low?

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +2

      Yes the term "rise time" refers to the low-to-high signal transition, but sometimes it is used interchangeably for the high-to-low transition time. Sometimes you will see "rise/fall time" if the two values are similar.

  • @lequangdung589
    @lequangdung589 22 วันที่ผ่านมา

    seen

  • @lp1772
    @lp1772 9 หลายเดือนก่อน

    In SPI need to do a length matching .If we are usung multiple slaves .

    • @Zachariah-Peterson
      @Zachariah-Peterson 8 หลายเดือนก่อน

      There is a timing margin specification, but this depends on the clock frequency and the rise time of the signals. It is not the same type of length matching we do with differential pairs, where the clock can be embedded in the serial bitstream and the two opposite polarity signals need to be aligned along their edge rate. The logic transition relative to clock and CS setup and hold times needs to happen within some timing margin that depends on the time between clock transitions. If the clock rate is slow and the interface is fast (this is pretty typical on advanced ASICs with low load capacitance), then the timing margin between two signals can be somewhat large, and this can allow pretty large length mismatch allowance between the signals on the bus.

  • @kaneeskansenthuran7645
    @kaneeskansenthuran7645 ปีที่แล้ว

    ay quá chừng luôn

  • @moses1202
    @moses1202 ปีที่แล้ว +1

    It surprised me a non-asian person pronounce I-two-C. I thought it was a mistake asian people made. Here we call it I-two-C or I-tsuu-C and some people in Taiwan call it I-su-kwe-C.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว

      The protocol is called "I squared C", but I always got in the habit of saying "I-2-C" after hearing other people say this

  • @msmith2961
    @msmith2961 ปีที่แล้ว +3

    First time I heard i²c called i2c.

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +4

      Well everyone writes it i2c instead of i²c, so....

  • @sleepib
    @sleepib ปีที่แล้ว

    Should also mention that MISO may need a pull-up or pull down.

  • @thechildofuniverse
    @thechildofuniverse ปีที่แล้ว

    Why didn't you show it on an PCB??

    • @Zachariah-Peterson
      @Zachariah-Peterson ปีที่แล้ว +3

      There are multiple videos where I've shown it on a PCB. I was talking about some of the routing rules on a PCB and what the topology looks like so that users know how to route it. Do you want to see some examples with explanations?

  • @balajiviswanathan6986
    @balajiviswanathan6986 ปีที่แล้ว

    like+sub, gj

  • @Bob-zg2zf
    @Bob-zg2zf ปีที่แล้ว +1

    you even know I2C.😂 you know everything🙃