YouTube2Text

EECS 373 - Fall 2026 - Lecture 11: "Serial Bus Over & UART" — Transcript

by Interactive Sensing and Computing Lab · 10,451 words · 1,538 segments · language en · Watch on YouTube

Full transcript

  1. 0:00from last time we talked about serial in
  2. 0:02general
  3. 0:03few extra slides and then we'll talk
  4. 0:05about different serial protocols we'll
  5. 0:07probably get through UR today and maybe
  6. 0:08start a little bit of SPI so for
  7. 0:11announcements uh slide ideation slides
  8. 0:14are due Thursday right in the day then
  9. 0:16we'll have your mic on
  10. 0:19>> I don't have my mic on I do have my mic
  11. 0:22on
  12. 0:27>> is this better
  13. 0:29Quiet.
  14. 0:32>> How about now?
  15. 0:35>> No. Better. [snorts] I can try a
  16. 0:36different mic.
  17. 0:46That's loud.
  18. 0:50How's that? Great. Thanks for letting me
  19. 0:53know. Uh, so team formation is on
  20. 0:56Friday. Uh James has already ordered the
  21. 0:58pizza. Um just come and find find
  22. 1:03partners, find teammates, and if you can
  23. 1:05look through the slides beforehand,
  24. 1:07they're going to be in that folder. And
  25. 1:09then homework is due uh on Monday. Any
  26. 1:13logistics questions?
  27. 1:18>> Yeah.
  28. 1:23>> Uh so technically I'm not going to watch
  29. 1:25you. You do have to sign a piece of
  30. 1:27paper to basically sign in and get free
  31. 1:30pizza so you can you can get out of
  32. 1:32there if you had to. But I really don't
  33. 1:35leave until you have a team because it's
  34. 1:37much harder to find a team when the
  35. 1:39people aren't in the room. And here's
  36. 1:41what happens. There's always a bunch of
  37. 1:43stragglers and they're screwing around
  38. 1:45and that's fine. I get life. And then
  39. 1:47they come to me and say they don't have
  40. 1:48a partner and then I just put them in
  41. 1:49the team and they don't know each other.
  42. 1:51They don't have anything any project
  43. 1:52ideas in common and it's painful, right?
  44. 1:55because then they nobody wants to work
  45. 1:56on the same thing. So don't don't get l
  46. 1:58get in that last group if you can avoid
  47. 2:01it.
  48. 2:04All right. All right. So we're talking
  49. 2:06generally about design considerations
  50. 2:08for USB or sorry for communication
  51. 2:10protocols in general. I'll just review
  52. 2:12them quickly and then we'll go forward.
  53. 2:14So, uh, we talked about wiring, whether
  54. 2:17it's serial or parallel. And then
  55. 2:20there's a bunch of trade-offs that you
  56. 2:21got. And essentially the big trade-off
  57. 2:23with parallel is that you get lots of
  58. 2:25speed. You got parallel wires. Multiple
  59. 2:27bits can go out per clock cycle, but for
  60. 2:31reasons that are a little bit beyond
  61. 2:32this course, they don't really go far.
  62. 2:34It's not it's not in physically long
  63. 2:36distances. That's good for like one chip
  64. 2:38to another chip on device,
  65. 2:40but trying to do a parallel bus over
  66. 2:43like a USB cable length or Ethernet
  67. 2:45cable length is pretty impractical,
  68. 2:47especially if you're trying to get up to
  69. 2:49really high speeds. And so, uh there's a
  70. 2:52trade-off there about distance. And then
  71. 2:54there's also the hidden cost of uh GPAO
  72. 2:58pins or just pins on a piece of silicon.
  73. 3:00how you're just not going to get 32 pins
  74. 3:03out of a really small piece of silicon
  75. 3:05or or lots of uh pins out. So then the
  76. 3:08default is that they're going to go to
  77. 3:10serial communication for usually for
  78. 3:12offdevice chip to chip communic or
  79. 3:14package to package uh communication
  80. 3:18unless they really need the bandwidth.
  81. 3:20Uh and then the bandwidth is usually
  82. 3:21like talking to a video card or talking
  83. 3:23to memory.
  84. 3:25Uh, and then so wiring and parallel
  85. 3:27versus serial is closely related to
  86. 3:30speed. Um, you can see that there's a
  87. 3:32there's an inherent trade-off, but
  88. 3:34that's the other thing when you're
  89. 3:35thinking about a protocol, the higher
  90. 3:36the speed is that there's a set of
  91. 3:38constraints that come into that. So, a
  92. 3:40lot of what your job is going to be in
  93. 3:42the industry is like which is the
  94. 3:44correct protocol for this job. Like I
  95. 3:46have to do a task of getting these
  96. 3:48things to talk to each other. Which one
  97. 3:49should I choose? And these are the
  98. 3:51constraints you have to figure out.
  99. 3:53Another
  100. 3:55set of constraints for these
  101. 3:57communication protocols we'll look at is
  102. 3:59that whether they're synchronous or
  103. 4:00asynchronous. And so synchronous means
  104. 4:03that there's a clock. And so there's a
  105. 4:04method for synchronizing the receiver to
  106. 4:07the transmitter so that the receiver
  107. 4:09knows when the clock cycle when to clock
  108. 4:11in the data. But that's not a
  109. 4:13requirement. You can certainly make a
  110. 4:15protocol and we'll look at one today
  111. 4:16that does not need a clock which is
  112. 4:19nice. You don't have to have an extra
  113. 4:20wire.
  114. 4:21So you reduce those pins that are hard
  115. 4:24to get. And if we also think about like
  116. 4:25wireless communication doesn't have
  117. 4:27inherently have a clock with it. So
  118. 4:29there must be a method here for
  119. 4:31recovering that clock. And we'll talk
  120. 4:32about that with the asynchronous
  121. 4:34versions. But it also makes things
  122. 4:36harder in the sense you have to actually
  123. 4:38recover that clock or figure out when
  124. 4:40you're supposed to be sampling those bit
  125. 4:41transitions.
  126. 4:43Um we talked a bit about the number of
  127. 4:46destination and sources. So a trivial
  128. 4:49case is just one to one. you have a your
  129. 4:51microcontroller is going to talk to say
  130. 4:52a wireless module. There's only one
  131. 4:54wireless module on your device. You're
  132. 4:55talking back and forth. That's pretty
  133. 4:57easy. But when you start getting to I
  134. 4:59have an array of sensors or I have 10
  135. 5:01different sensors of different types or
  136. 5:03maybe I have other IO devices, then
  137. 5:07choosing a protocol that's the right one
  138. 5:09that supports multiple sources or
  139. 5:11multiple uh destinations is important.
  140. 5:16uh the arbitration scheme which is the
  141. 5:18idea of how do you determine
  142. 5:20which device you should talk to. Um
  143. 5:24there are a bunch of different methods
  144. 5:26uh we'll review some uh which are
  145. 5:28related to uh select lines or addresses
  146. 5:31or it's just inherent because it's just
  147. 5:33one source to another source or one
  148. 5:34destination and one source. Uh protocols
  149. 5:37there's different data formats and this
  150. 5:39kind of lives typically above the
  151. 5:41signaling layer. So a lot of lecture is
  152. 5:43going to worry about the signaling layer
  153. 5:44like which lines go high but on top of
  154. 5:47that is the protocol layer and that's
  155. 5:48what is the format of the data and is
  156. 5:51there redundancy.
  157. 5:53All right so any
  158. 5:55questions about these sort of
  159. 5:57constraints or factors when thinking
  160. 5:59about uh communication protocols.
  161. 6:07Okay. So as you look through today and
  162. 6:10next week as we talk about more
  163. 6:12protocols, you should think about uh or
  164. 6:15more yeah communication protocols, you
  165. 6:17should think about which of these
  166. 6:19things, you know, which camp do they fit
  167. 6:21into and which one is allowing which one
  168. 6:23of these factors is allowing them to be
  169. 6:24faster, quicker or more um usable in a
  170. 6:28particular uh scenario.
  171. 6:31Uh I forgot if we asked this question
  172. 6:33yesterday or Monday, but why does ARM
  173. 6:36use parallel buses on the APB and we use
  174. 6:39chip to chips communication? Did we ask
  175. 6:41this question?
  176. 6:44All right, go talk amongst yourselves.
  177. 6:46Figure out a reason why ARM would choose
  178. 6:48to do this uh use parallel internal but
  179. 6:51serial out from device to device.
  180. 7:18My name is Jesus.
  181. 7:48All right. Why do we think why would why
  182. 7:50do we make this choice?
  183. 7:56outside.
  184. 8:04>> It's true.
  185. 8:06>> That's true. Why not use serial
  186. 8:07internally? It's less wiring. Seems
  187. 8:09easy.
  188. 8:11>> Yeah,
  189. 8:22>> Blate. Uh, you can do Yeah, that's true.
  190. 8:24And why wouldn't you want to do it
  191. 8:26internally on a chip? Why wouldn't you
  192. 8:27want to do take the time penalty for
  193. 8:29serial internally?
  194. 8:38Why isn't the APB serial instead of
  195. 8:40parallel?
  196. 8:49You guys have all good ideas. Yeah.
  197. 8:58Yeah.
  198. 9:01>> Right. So like that doing imagine you
  199. 9:02have to wait eight clock cycles just to
  200. 9:04send eight bits somewhere. That would
  201. 9:06just be inefficient. Right. So now
  202. 9:08they're trying to go as fast as
  203. 9:09possible. And the trick is just to think
  204. 9:12about the architectural constraints of
  205. 9:13silicon design. So here this is an old
  206. 9:15picture. This is only 8bit bus. Um I
  207. 9:18don't have I don't know where the buses
  208. 9:19are in the new chips, but um the idea
  209. 9:23here is uh doing eight bits or 32 bits,
  210. 9:26uh you really want that high speed, but
  211. 9:28there's lots of effectively space on a
  212. 9:30chip. You're not bound by these wires.
  213. 9:32So remember these S1, S0, all those
  214. 9:35bumps around, all those squares around
  215. 9:37that's the amount of space that's needed
  216. 9:39for uh IO. So this is these are pads
  217. 9:42that go out and there's just so many a
  218. 9:44limited number of pads you could
  219. 9:46possibly put around the edge. Um but you
  220. 9:49can have because it's the world of the
  221. 9:52small very small things you can have
  222. 9:53massively parallel buses internally and
  223. 9:55you really want the speed. Um but you
  224. 9:58have to pay the penalty to go uh when
  225. 10:00you're going off the device just because
  226. 10:01there's not enough pins.
  227. 10:04Uh, I can't think of any any time I've
  228. 10:06ever seen a serial bus on a piece of
  229. 10:09silicon.
  230. 10:12I've seen it from die to die, but not
  231. 10:14for a piece of silicon. Okay.
  232. 10:17Uh, yeah. And then this is just the
  233. 10:19counter example. This is just reminding
  234. 10:21you that these these bumps are like
  235. 10:23literally this like trying to get more
  236. 10:25in here. I can't get in this little die.
  237. 10:27I can't get like thousands of these. I
  238. 10:29can't get hundreds of these. I I'm
  239. 10:30really limited in the number of bumps.
  240. 10:32little they call these bumps. These are
  241. 10:34uh these little pads here. They're
  242. 10:35called bumps. Uh there's a number of
  243. 10:37them that you can get off and they do
  244. 10:39have chips where you they basically
  245. 10:40cover as much of the surface area as you
  246. 10:42can with um pads or bumps, but uh
  247. 10:46there's still limitations and it's costs
  248. 10:48a lot. Okay.
  249. 10:52All right. Well, we're going to move on
  250. 10:53to um UART somewhere in here. There we
  251. 10:58go.
  252. 11:02Okay. So, we're going to talk about uh
  253. 11:05three communication buses in general.
  254. 11:08All these lectures go together that it's
  255. 11:09broken up over multiple slide decks. Um
  256. 11:13if you want, so today we're going to
  257. 11:15talk about UR if you want to learn more
  258. 11:16like really the data sheet at this point
  259. 11:19uh is a great source to learn about it.
  260. 11:22You should be more or less at the point
  261. 11:24where you can figure out how the
  262. 11:25peripheral works by reading the data
  263. 11:26sheet. It doesn't give you lots of
  264. 11:27background. It kind of assumes you've
  265. 11:29taken the course but you could probably
  266. 11:31figure out how it works. Um there is
  267. 11:33this textbook uh again is for a
  268. 11:35different microcontroller but the
  269. 11:37exposition the discussion of how serial
  270. 11:39ports works is uh still relevant and so
  271. 11:42you can get more information there but
  272. 11:44the web also has lots and UART in
  273. 11:46particular is an old protocol. Um all
  274. 11:48the ones we talk about are well
  275. 11:50documented on the web.
  276. 11:52Okay so universal asynchronous receiver
  277. 11:56transmitter. Um so this is a as it
  278. 11:58suggests a type of trans uh protocol
  279. 12:02that is asynchronous meaning there's no
  280. 12:03clock. Um it's a particularly old
  281. 12:06standard. It used to be that computers
  282. 12:09before there was Ethernet would talk to
  283. 12:11each other over a version of this
  284. 12:13protocol. And you may find uh in a
  285. 12:16research lab or something some devices
  286. 12:18with protocols like RS232 and RS2 or 422
  287. 12:23um those still uh are underneath are
  288. 12:26just UART protocols. So it is a
  289. 12:30wellestablished
  290. 12:31uh signaling method. Um,
  291. 12:37it's relatively configurable in a sense
  292. 12:39that the protocol really just defines
  293. 12:42what the signaling is and like what the
  294. 12:44waveform looks like, but it leaves lots
  295. 12:46of flexibility for how big packets
  296. 12:48should be, what how they're encoded,
  297. 12:50what speeds are there, so it's not
  298. 12:52overly constrained. And so, you know, a
  299. 12:55little history lesson I was saying like
  300. 12:57this is the back of your maybe your
  301. 12:59grandparents first computer looked like
  302. 13:01this. I don't know. Um but they used to
  303. 13:03have all these connectors here. DB uh 9
  304. 13:06was the standard for just normal serial
  305. 13:08ports and RS232
  306. 13:10uh was there. So my question to you uh
  307. 13:13is why are we still using UART today?
  308. 13:15Like this came out in 1971 I think UART
  309. 13:19was a pro established as a protocol. Why
  310. 13:21are we still teaching it now? What could
  311. 13:24be the market forces or the reasons why
  312. 13:28it was in computers and now we're
  313. 13:29talking about a microcontroller? Take
  314. 13:31take 60 seconds. Think about it.
  315. 13:47[snorts]
  316. 14:22All right. Why do you think not even I
  317. 14:25am this old? So why are we still
  318. 14:27teaching this in 2026?
  319. 14:35>> Yeah.
  320. 14:38>> I'm sorry.
  321. 14:40>> Yeah, maybe. But none of these computers
  322. 14:44probably run anymore. So it's not like
  323. 14:45I'm trying to talk to them. Although
  324. 14:47that's not a bad reason. I bet that's a
  325. 14:48good reason why it existed. So in 2000
  326. 14:52or so, PCs started going switching to
  327. 14:54USB, but that we still had uh UART type
  328. 14:57ports then. So, but now we're 26 years
  329. 15:01later. What are some other reasons?
  330. 15:03Yeah,
  331. 15:05I'm sorry. It's simple. Oo, I like that
  332. 15:08one. It's simple. Right. So this was
  333. 15:10state-of-the-art for 1971 when you had
  334. 15:13the and even these computers are like
  335. 15:15that's 80s and that's 2000s I think. But
  336. 15:18so UART was a way for computers to talk
  337. 15:20to each other and then they had
  338. 15:21complicated switching protocols so you
  339. 15:23could have multiple computers talk to
  340. 15:24each other but it was still basically
  341. 15:26like take one wire to another your
  342. 15:29buddy's computer and hook them up.
  343. 15:30That's the kind of modality. Uh and then
  344. 15:33computers got much much faster but
  345. 15:34microcontrollers haven't done the same
  346. 15:36thing. Microcontrollers more or less
  347. 15:37stayed at the same performance level.
  348. 15:39they just got cheaper and cheaper and
  349. 15:41smaller and smaller. And so now the
  350. 15:44legacy part comes through because we
  351. 15:45have this existing protocol. It's not
  352. 15:48really good for
  353. 15:50modern say year 2000 computers to talk
  354. 15:52to each other, but it's still relevant
  355. 15:55and there's lots of hardware that
  356. 15:56supports it in terms of chipsets and
  357. 15:58other things for microcontrollers talk
  358. 15:59to each other. So that's kind of like
  359. 16:01how the embedded system industry
  360. 16:03inherited UART uh just because it was
  361. 16:05well known engineers understood it and
  362. 16:08it's dead simple
  363. 16:11uh at least in the in the realm of what
  364. 16:13a embedded system could be. Um so you
  365. 16:16might find even in the lab if you're
  366. 16:17trying to build uh your projects you
  367. 16:19might find these things they're just
  368. 16:20called DB9 connectors. You don't have to
  369. 16:21remember what they are but the the big
  370. 16:24takeaway here is that there's these two
  371. 16:25lines here. Receive data, transmit data.
  372. 16:28the extra data lines aren't really
  373. 16:30necessary, aren't used anymore, but they
  374. 16:32were the handshaking protocols, uh the
  375. 16:35the acknowledge bits, you see clear
  376. 16:37send, ready send, all those extra
  377. 16:39handshaking methods used to be required,
  378. 16:42but now we have relatively fast
  379. 16:43electronics. We don't really need them
  380. 16:45anymore, especially for how embedded
  381. 16:46systems uses them.
  382. 16:49Um, also, uh, we'll see in a minute that
  383. 16:53RS232, R, RS422, and 485, those were
  384. 16:58almost exactly the same protocols in a
  385. 17:00sense of
  386. 17:02uh, the signals that were sent out. It's
  387. 17:04just that they had different power,
  388. 17:07voltage levels, right? They were trying
  389. 17:08to accomplish different tasks. So if
  390. 17:11you're only going to go from 0 to 5
  391. 17:12volts, you can't really go that far
  392. 17:14until noise or degradation or just the
  393. 17:17inductance and capacitance starts
  394. 17:18messing up your bits. And so they
  395. 17:21started increasing the voltage and
  396. 17:22differential means that there's one line
  397. 17:24that goes positive, one line that goes
  398. 17:25negative. Uh RS232 is and you are
  399. 17:28generally single-ended. But now they're
  400. 17:30just these are different different
  401. 17:31versions and all they really indicate is
  402. 17:33that the signaling is different but the
  403. 17:35underlying mechanism is the same.
  404. 17:38And so here's an example of what a UART
  405. 17:40packet would look like. We'll go through
  406. 17:41it in a little bit more detail later,
  407. 17:43but here's 5 volts, 0 to 5 volts. The
  408. 17:46voltage doesn't actually matter, but
  409. 17:47this is what standard UART was. And then
  410. 17:50RS232 would kick it up to plus or minus
  411. 17:5312 volts. And so, uh, you might notice
  412. 17:55that one is in inverted of the other
  413. 17:57one. And so, when I was undergrad, I was
  414. 17:59asked to hook up to some ancient
  415. 18:01machine. I had my little USB
  416. 18:03microcontroller, uh, and had a little
  417. 18:05USB converter. And then I would go and
  418. 18:07talk to um uh this old RS232 device and
  419. 18:12I couldn't figure out why it couldn't
  420. 18:14understand me at all. And what I didn't
  421. 18:16realize is that the part of protocol
  422. 18:18just inverts the signal and all they do
  423. 18:20is they have this big in buffer this big
  424. 18:22inverter and it just sends it through.
  425. 18:23The inverter goes from -12 to positive
  426. 18:2512 and just inverts the signal. So
  427. 18:28that's the that's the history lesson of
  428. 18:29where this protocol came from. So today
  429. 18:32we primarily use it just for two devices
  430. 18:35talking to each other. Uh you have a
  431. 18:38transmit. So this is when one device is
  432. 18:40sending data to the other one and then
  433. 18:42you have a receive. Now the problem is
  434. 18:44there's no idea of a master. There's no
  435. 18:46one individual in charge. And so it's
  436. 18:49the TX goes to the RX of the other
  437. 18:52device and the RX listens to the TX of
  438. 18:55the other device. It's not that the TX
  439. 18:57of device one goes to TX of device two.
  440. 19:00Right? that would only make sense if it
  441. 19:02was um there was a master and there was
  442. 19:04a peripheral. So I made this mistake
  443. 19:07when I made one of my first boards. I
  444. 19:09didn't really understand the protocol
  445. 19:10and I just said, "Oh well, this is my
  446. 19:12microcontroller and that's the
  447. 19:13peripheral device and so TX here goes to
  448. 19:16TX there, right? That's what the
  449. 19:17signal's name is." And uh well, what I
  450. 19:20learned after that is that I would
  451. 19:22always put extra zero ohm resistors and
  452. 19:25a configuration there that if I ever
  453. 19:26need to, I could solder them and switch
  454. 19:28those signals around. just something
  455. 19:30that you will uh maybe painfully learn
  456. 19:32one day. Um the other trick here is with
  457. 19:36all the protocols we talk about the
  458. 19:37number of signals that they have. Uh
  459. 19:39typically we say this one has two but
  460. 19:41there's always implicitly ground. And
  461. 19:44why does anybody know why you would have
  462. 19:46to have a ground?
  463. 19:49Yeah.
  464. 19:52>> Nope. Uh ground plane maybe. But yeah.
  465. 19:59Yes, they have to have we have to have
  466. 20:00the same sense of uh voltage, right? So,
  467. 20:03if this one is like a 100 volts higher
  468. 20:05than this one, uh bad things can happen.
  469. 20:07One other kind of reason
  470. 20:11the inverse of voltages
  471. 20:16guys took 215
  472. 20:19current, right? Current has to go in a
  473. 20:21loop. So if I just if I have no return
  474. 20:25loop here and I just raise the voltage
  475. 20:27over here, no no current's going to fly
  476. 20:29over to the other thing, right? And so
  477. 20:31if there's uh you have to have some
  478. 20:33return path here uh for your signal. So
  479. 20:37um just whenever we're looking at
  480. 20:39communication protocols uh you always
  481. 20:42have to remember that include ground and
  482. 20:44every year we see it not your fault.
  483. 20:45You're learning about embedded systems.
  484. 20:48person says, "I can't get this serial
  485. 20:49bus to work." And we look at their
  486. 20:51hardware and there's no ground. And you
  487. 20:53know, maybe it'll work intermittently at
  488. 20:55certain points, but there's no guarantee
  489. 20:56it's going to work. You actually have to
  490. 20:58have that ground pin,
  491. 21:01but there's no clock, right? So, um,
  492. 21:04this thing is just going to send out
  493. 21:06signals. They're going to look like
  494. 21:09like literally it's going to look like
  495. 21:11this top thing as a function of time.
  496. 21:13You're going to get highs and lows.
  497. 21:15So, how is it possible that this device
  498. 21:19is going to be able to figure out when
  499. 21:21to sample the data? So, I take 60
  500. 21:24seconds, brainstorm, figure out some
  501. 21:26ways in which if you're the device 2 and
  502. 21:28you're receiving data, how do you know
  503. 21:30when to clock?
  504. 21:44>> [snorts]
  505. 21:51>> Happy birthday.
  506. 22:24What do you think? How do how can we
  507. 22:26figure out how to clock the signal in?
  508. 22:31Maybe somebody over here. I missed this
  509. 22:33side of the room. Need brave people.
  510. 22:38>> Yes, he's bravest person.
  511. 22:43>> They do. Absolutely. Uh but how do you
  512. 22:46know when? Just knowing that the data is
  513. 22:48coming in at a certain time, a certain
  514. 22:50rate doesn't tell me when I'm supposed
  515. 22:52to like clock it in.
  516. 22:55>> Yeah.
  517. 23:07Okay. Yeah. But but okay. Yeah.
  518. 23:16>> What's that?
  519. 23:18>> Sure. Okay. Let's let me I'm gonna jump
  520. 23:20a little bit ahead in slides. So I kind
  521. 23:22of look at like this. Like I'm here
  522. 23:27and I gotta figure out I can use there
  523. 23:30could be a start and stop bit something
  524. 23:31that says this is the start of the frame
  525. 23:33and this is the the stop of the frame.
  526. 23:34But how do I know where to put those
  527. 23:37clock edges on there, right? So if I
  528. 23:39kind of go ahead Oh, did that work? No,
  529. 23:41they didn't work. At one point I had
  530. 23:42this thing would slide back and forth.
  531. 23:44But like imagine those little clock
  532. 23:45edges are sliding back and forth. Like
  533. 23:47how do I know when the middle of D3 is?
  534. 23:54If you had to create a circuit to do it,
  535. 23:56what would you think? Or a method
  536. 24:01and assume that you can know the clock
  537. 24:02rate.
  538. 24:06No idea. So I look at this uh kind of
  539. 24:10like analogy is like you're pushing a
  540. 24:11kid. I don't know why you would do this.
  541. 24:14When I I had I had my daughter when I
  542. 24:16made this slide, I never pushed her with
  543. 24:17a blindfold on. But if you did, you
  544. 24:19imagine that you have to know when the
  545. 24:21child is there. so that you push them at
  546. 24:22the right cadence. Otherwise, you're
  547. 24:24just going to push your hand forward.
  548. 24:25You're going to miss the child, maybe
  549. 24:26get hit in the face. I don't know. Okay.
  550. 24:29So, how so how do you know when? Well,
  551. 24:31the trick is you have to effectively
  552. 24:33measure the start bit and you know how
  553. 24:37long it's supposed to be and then you
  554. 24:38have to have some hardware inside that's
  555. 24:40going to over sample the clocks
  556. 24:44here. So, you have a clock that's going
  557. 24:46faster. You see a clock edge coming down
  558. 24:48and then you count. You say this should
  559. 24:51be the middle of my start bit. And then
  560. 24:53you say, "Aha, that was eight clock
  561. 24:55cycles. I know the baud rate. I'm eight
  562. 24:57times over sampling. I'm going to go
  563. 24:58eight clocks forward. And then I know 16
  564. 25:00clocks from now will be the midpoint."
  565. 25:03Right? So you have to over sample this.
  566. 25:04You have to a know the baud rate. And
  567. 25:06then you have to guess essentially, but
  568. 25:08you have to count off some. You have to
  569. 25:10be have a clock that's faster than your
  570. 25:12data rate coming in to figure that out.
  571. 25:16>> Yeah.
  572. 25:19Nope. It's an asynchronous protocol.
  573. 25:24>> This is uh this is internal to your
  574. 25:26device. So I am a receiver and I have a
  575. 25:30clock that's running 16 times faster
  576. 25:32than you are.
  577. 25:34And so I am trying to figure out okay I
  578. 25:36saw a falling edge after a long period
  579. 25:38of time. So say that start bit was high
  580. 25:41for a long period of time and then the
  581. 25:42transition comes down and I say okay
  582. 25:45that's the signal that we're going to
  583. 25:46start a packet and now I'm going to
  584. 25:48count forward
  585. 25:50basically uh eight and then 16 and say
  586. 25:52that's when I'm supposed to sample.
  587. 25:56>> Yeah.
  588. 26:01So how do you know that the speed is 16?
  589. 26:04>> Ah so um the guy up there said you know
  590. 26:07the clock speed you know the data speed.
  591. 26:10So APR you have to agree that data is
  592. 26:12going to come in at a certain rate but
  593. 26:15you don't but that just because you know
  594. 26:16the rate doesn't know you doesn't mean
  595. 26:18you know when. So this is all about
  596. 26:20trying to figure out the when when do I
  597. 26:23clock in data at D0
  598. 26:26right? Because if I'm doing the counter
  599. 26:28example is here when I'm pushing the kid
  600. 26:31on the swing, when do I push? If I have
  601. 26:34my eyes closed, I don't know when. I can
  602. 26:36hear the swinging go back and forth. So
  603. 26:37maybe I know the rate, but I don't know
  604. 26:39when.
  605. 26:42And so the way to do that is on device
  606. 26:44you over sample. you sample essentially
  607. 26:46faster or you have a clock here that is
  608. 26:50sampling is not the right term but you
  609. 26:51have a clock that's running uh in this
  610. 26:53case uh 16 times faster so that you can
  611. 26:57uh count and guess where that edge is
  612. 26:59going to be. What do you think the
  613. 27:00downside of this is? What's going to
  614. 27:02happen after a long period of time?
  615. 27:08>> Yeah.
  616. 27:11>> Yeah. because there's no guarantee,
  617. 27:14remember? Um, so you have an internal
  618. 27:16clock. It's pretty good. It's not
  619. 27:17perfect. It's pretty good. And they have
  620. 27:18an internal clock. It's pretty good.
  621. 27:20It's not perfect. And you've both agreed
  622. 27:21on a rate. But over time, there's going
  623. 27:24to be some drift between those clocks.
  624. 27:25They're not perfectly synchronized. So
  625. 27:28you're only saying here every 16 times
  626. 27:30I'm going to go and clock in the data
  627. 27:32whatever it is. But over eventually
  628. 27:34they're going to become out of sync. And
  629. 27:35this is a question of how long, right?
  630. 27:37Is it, you know, a few bits? Is it a
  631. 27:40week? Right? And typically this protocol
  632. 27:43is more in the let's be conservative.
  633. 27:44Let's assume it's like 10 bits before we
  634. 27:48have to send a new start bit to
  635. 27:50synchronize
  636. 27:55questions.
  637. 27:58Okay. All right. So I got a little out
  638. 28:01of order.
  639. 28:03Um so where that is done on device is so
  640. 28:07this is an example of the uh UART
  641. 28:10module. So they have I forgot what it's
  642. 28:11called universal serial interface
  643. 28:15channel. I think that's what it stands
  644. 28:17for. Um as we'll see later that this
  645. 28:20thing can be reconfigured for multiple
  646. 28:22different tasks. Uh so it can be UART or
  647. 28:26I squared C or SPI. These are other
  648. 28:27protocols you'll learn about. But inside
  649. 28:30here they have uh the baud rate
  650. 28:31generator and I for what the PPC stands
  651. 28:34for something in particular. I don't
  652. 28:35know my notes aren't here. It's the
  653. 28:37programmable
  654. 28:39I don't know the programmable
  655. 28:42pre-processor. So basically what it does
  656. 28:45is it it's the thing that is counting
  657. 28:49beforehand. And so the baud generator
  658. 28:50says I got my basically a register that
  659. 28:52tells me what the baud rate is and then
  660. 28:54it says okay this is the rate at which
  661. 28:56data should be coming in and the um
  662. 28:59programmable prep-processor is doing the
  663. 29:0116 times or n times over sampling. I
  664. 29:04don't know on this particular processor
  665. 29:06many of them you can say it's eight or
  666. 29:0716 or even 32 depending on you know how
  667. 29:10you want to configure it but it does
  668. 29:12require a trade-off right now your
  669. 29:13internal clock as you're receiving this
  670. 29:15thing has to be faster than the baud
  671. 29:17rate back in the day when they're back
  672. 29:19in 1971 when they were building this
  673. 29:21that was probably much more higher
  674. 29:22burden here we're at you know 100 mega s
  675. 29:25or megga hertz on uh for your chip
  676. 29:28clocks and you're probably only at best
  677. 29:30megahertz uh even hundreds a kilohertz
  678. 29:34uh for a symbol rate on UR. So the
  679. 29:37oversampling is not that big a deal
  680. 29:38anymore.
  681. 29:41What questions you have?
  682. 29:45I see questions. I see your faces.
  683. 29:47You're like, I don't understand anything
  684. 29:48this guy's saying.
  685. 29:54Why don't you talk to each other and
  686. 29:56explain to each other how this
  687. 29:57oversampling thing works?
  688. 30:18The clock's internal. That clock is
  689. 30:20internal to the device. It's not shared
  690. 30:21between devices.
  691. 30:28All
  692. 30:52right. So, just just for clarity,
  693. 30:55there's no shared clock between these
  694. 30:56devices.
  695. 30:58So if device one is sending packets over
  696. 31:00here, device two is waiting for that
  697. 31:02edge to come down and then it has an
  698. 31:04internal clock that is n times faster,
  699. 31:0716, 32 or 8 times faster and then it's
  700. 31:09figuring out where it should be
  701. 31:12sampling. Yeah.
  702. 31:18>> Correct.
  703. 31:20>> Unit of time. We'll call it baud. This
  704. 31:22is called a baud rate.
  705. 31:24>> Okay.
  706. 31:28that
  707. 31:29>> uh
  708. 31:32it could be uh the the architects of
  709. 31:35these protocols said like let's talk
  710. 31:37about not internal clock rates because
  711. 31:39those clock rates could be different
  712. 31:41right this system could be running at
  713. 31:43meghahz the other one could be kilohz
  714. 31:45you could have different oversampling or
  715. 31:48faster sampling clocks and so they just
  716. 31:50talked about the signal itself has a
  717. 31:52certain rate to it baud rate
  718. 31:54>> so the hardware do
  719. 31:59Yeah.
  720. 32:02>> Yeah. Yeah. Yeah.
  721. 32:09[snorts]
  722. 32:16>> Uh yeah, I did jump around a little bit.
  723. 32:18So baud rate is established a priority.
  724. 32:21Two programmers agree beforehand that
  725. 32:23this is the baud rate. And how you would
  726. 32:25normally do it is you will look at the
  727. 32:27data sheet and the data sheet will tell
  728. 32:28you what the baud rate of this device is
  729. 32:30or it'll tell you it supports these uh
  730. 32:33baud rates. You might work in a serial
  731. 32:36terminal program on your computer. And
  732. 32:38you'll see that there's lots of
  733. 32:39different baud rates to choose from. And
  734. 32:42so then you would have to choose the one
  735. 32:43that you've programmed into your
  736. 32:44microcontroller. And sometimes the
  737. 32:46computers are fancy now and it will just
  738. 32:48detect it'll automatically detect the
  739. 32:50baud rate coming off your
  740. 32:51microcontroller.
  741. 32:56Yeah.
  742. 32:57>> So to that point like if you wanted to
  743. 32:59establish a log across machines like
  744. 33:02default log and then you pack it over
  745. 33:05with a new rate is upgrade that rate.
  746. 33:07>> Uh don't do that.
  747. 33:09>> You could I mean I don't know why you
  748. 33:11want to. Um typically like the default
  749. 33:14baud rate is like 960 0 for whatever
  750. 33:17reason. I know it's like really slow and
  751. 33:18everybody agrees on it. Uh we'll get to
  752. 33:20the start bit in just a second. Um I
  753. 33:21forgot. I know. I forgot. Um,
  754. 33:24but uh I don't think there's any reason
  755. 33:27why you're dynamically changing the baud
  756. 33:29rate because typically the hardware the
  757. 33:32physical layer is not changing and
  758. 33:34that's one thing that would change it,
  759. 33:36right? You make your wires really long
  760. 33:39and now they can't support the higher
  761. 33:41frequencies. Okay. Well, now you'd have
  762. 33:43to shorten it. But that's usually not
  763. 33:44happening. These are not hot swap
  764. 33:46plug-and-play USB style protocols.
  765. 33:49Uh, yeah. All right. Any other questions
  766. 33:52before I get to start bit?
  767. 33:54These are good questions. Okay, start
  768. 33:57bit. Uh, so here is the general
  769. 34:00protocol. There are variations to it. So
  770. 34:04in almost all cases, unless otherwise
  771. 34:06specified, the bus is typically held
  772. 34:09high. Okay, so here we're you see that
  773. 34:12the line comes in from the sender is
  774. 34:14high. uh just assume it's been high for
  775. 34:17quite a long time, much longer than a uh
  776. 34:20bit width. And now the device is looking
  777. 34:23for the start and the start is I was in
  778. 34:26a a state where the bus was idle. So
  779. 34:28you're you're but in bus idle state. It
  780. 34:30transitions down and that's the
  781. 34:32indication of a start bit that falling
  782. 34:34edge. Then it does its uh calculation to
  783. 34:38figure out well based on the baud rate,
  784. 34:40how fast my clock is going, then I can
  785. 34:42go and figure out where to sample. at B
  786. 34:450, at B1, at B2.
  787. 34:56>> I think the I think the protocol says
  788. 34:57it's like two and a half symbol widths
  789. 35:01and a symbol is this distance here,
  790. 35:05right? So you there is a you cannot jam
  791. 35:08these things too close to each other or
  792. 35:10else you're not you don't ever get into
  793. 35:12the idle state of the state diagram.
  794. 35:19B34
  795. 35:21and B5 are all
  796. 35:23>> Oh, yeah. Uh oh. Ah. Okay. So, now he's
  797. 35:27getting he's getting good here. So, we
  798. 35:30have to have a start bit and you also
  799. 35:32have to agree on how many bits are in
  800. 35:34the in the packet beforehand.
  801. 35:36So, typically it's going to be eight
  802. 35:38bits, but there's no reason why it can't
  803. 35:39be five, six, seven. I've seen nine bits
  804. 35:42as well. eight bits just happens to be a
  805. 35:44happy number. All the engineers choose
  806. 35:46it. Um there's also an optional par bit
  807. 35:49uh is doesn't have to be there. So the
  808. 35:51par bit is there and that's just telling
  809. 35:53you uh it's a summation of the uh the
  810. 35:57ones I believe was if that's right. Um
  811. 36:00and it says if this bit is high that you
  812. 36:02can check then you can count up all the
  813. 36:04ones and if the bit is high and that and
  814. 36:06it's an odd number then it matches. If
  815. 36:07it's a odd number then it's um uh zero.
  816. 36:10So now you have a way a data redundancy
  817. 36:13way to figure out what was uh if that
  818. 36:16packet is valid. Uh and then there's a
  819. 36:19stop bit and sometimes they enforce two
  820. 36:21spot stop bits because they want to make
  821. 36:22sure there's more timeout time for the
  822. 36:24hardware to recover. Usually it's
  823. 36:26because the hardware has to do tasks
  824. 36:28like take that eight bits that's now in
  825. 36:31uh your silicon and then like shift it
  826. 36:32out to somewhere else. So if they did it
  827. 36:34too fast so the extra stop bit helps
  828. 36:37with that. Uh yeah questions.
  829. 36:52Uh, so you said why is it always
  830. 36:54essentially what I've got is why is it
  831. 36:55always hacked active high? Why not
  832. 36:56something else?
  833. 36:58No, no, that's what they did. That's
  834. 37:00what they did. So I could imagine a
  835. 37:02reason. The reason is I have my uh
  836. 37:05device plugged in and I want to know am
  837. 37:07I connected to anything?
  838. 37:09And if it's active low, you assume
  839. 37:11you're connected. You don't know. But if
  840. 37:12it's active high, at least you know that
  841. 37:14you're connected.
  842. 37:15>> Does that answer your question?
  843. 37:16>> Yeah.
  844. 37:17>> Okay. Yeah.
  845. 37:22Y
  846. 37:27>> you could be insane and you could do it
  847. 37:29for communication. That's fine. Um but
  848. 37:31it's going to be too hard. So you would
  849. 37:33just do it because we're going to assume
  850. 37:36that the hardware doesn't change during
  851. 37:38this transaction. Uh you plugged it in
  852. 37:40and now you've user said go or start or
  853. 37:42something. Um that the uh number of
  854. 37:45symbols and the rate doesn't change and
  855. 37:47you know you you're not adding a parody
  856. 37:49bit. You're not adding an extra stop
  857. 37:51bit.
  858. 37:54>> Yeah, you have to configure it. Yep.
  859. 37:59Other questions?
  860. 38:05Um,
  861. 38:06yeah. And this just showing off that
  862. 38:08there's certainly are other types of
  863. 38:10data frames. And typically you see this
  864. 38:12nomenclature here. It's like, do I have
  865. 38:14it here? I'm sure it's somewhere. Um
  866. 38:19that's it's like it'll be like uh 9
  867. 38:23um n or 8 n1 and the 8 n1 this is uh
  868. 38:28eight is a number of bits n would be no
  869. 38:31uh par bit and then one is the number of
  870. 38:33stop bits. So you'll see these kind of
  871. 38:34like these three symbols that indicate
  872. 38:37uh what frame it's at or like what's
  873. 38:39what's the frame type what how how is
  874. 38:42data encoded. The other thing that's not
  875. 38:44known is whether it's LSB or MSB. You
  876. 38:47have to kind of you have to agree abi
  877. 38:50what it is. And so you might think like
  878. 38:52that's a lot of stuff to configure, but
  879. 38:54it also gives you lots of flexibility.
  880. 38:56You can change the speed. You can change
  881. 38:57the number of bits. You can change all
  882. 38:59those things. Yeah.
  883. 39:02>> What do they look like?
  884. 39:05>> They're just extra time that stopped.
  885. 39:12Yeah, it's just telling you there's a
  886. 39:14timeout between
  887. 39:16uh signals. So, let's see. Is there
  888. 39:19here's an example of like what two spot
  889. 39:22I think what they're trying to say here
  890. 39:23is here's what two stop bits would look
  891. 39:24like before the next stop stop bit. So,
  892. 39:26I was wrong. It's not two and a half.
  893. 39:27It's up to two. It's not two and a half.
  894. 39:32I thought that there was a more of a a
  895. 39:33mandatory timeout in this protocol. Does
  896. 39:36that answer your question?
  897. 39:38Yeah. Okay.
  898. 39:41And then let's see maybe did I I may
  899. 39:44have said the polarity wrong or the par
  900. 39:46bit wrong. So if the total is even then
  901. 39:49the parity bit is one. Oh I think I did
  902. 39:51say it wrong. And then the if the total
  903. 39:53number of bit you take the bits you
  904. 39:54figure out if it's odd. You sum them. If
  905. 39:56it's odd or even then um if it's odd par
  906. 39:59then you get a one. And so now you can
  907. 40:00imagine if you get one bit flip. If one
  908. 40:02bit flips then your par is changed. your
  909. 40:04summation of all the ones changes and
  910. 40:07now you can check to see if that packet
  911. 40:09is valid or not. And that's just a nice
  912. 40:12way you could you get an invalid packet
  913. 40:13you can ask the transmitter for another
  914. 40:16version of that packet. So a little bit
  915. 40:18of uh redundancy built in there.
  916. 40:20Oftentimes I think you asked what
  917. 40:22happens with the you get bad data
  918. 40:24happens all the time. It's going to
  919. 40:25happen in Tun Lab. It's going to be
  920. 40:26great. You just get garbage, right? uh
  921. 40:29oftentimes uh you I don't know if you
  922. 40:32ever looked at an ASKY character table
  923. 40:34there are so many ASKI characters that
  924. 40:36if you misinterpret a a packet it kind
  925. 40:39of lands to some asy character and so
  926. 40:42now you get gibberish out and so that is
  927. 40:45a common error or there's just no uh you
  928. 40:48just get an error there's no actual data
  929. 40:49in there so that is just a known failure
  930. 40:53case of this parody bit comes in there
  931. 40:55to help with that to see if it's
  932. 40:57unlikely that you got gibberish in and
  933. 40:59the parody was right. Um, yeah.
  934. 41:05Yeah.
  935. 41:08>> Yep. You have to a par decide if there's
  936. 41:09a parody bit.
  937. 41:20>> No, it's dependent on the data. So if
  938. 41:22the data is uh if if you sum them all up
  939. 41:25and it's uh even then the parity is one.
  940. 41:28Oh the par even sorry.
  941. 41:33Okay. Is there an example? No.
  942. 41:37Okay. Uh so then we had this idea of
  943. 41:41baud rate.
  944. 41:42So uh sorry the data rate and baud rate
  945. 41:45are two different things. And why they
  946. 41:47chose this is a little unclear. So here
  947. 41:50we have uh this is the rate at which uh
  948. 41:53packet or symbols come through not the
  949. 41:56rate at which data comes through. And so
  950. 41:58you're saying well isn't that the same
  951. 41:59thing? Why is a symbol and a symbol here
  952. 42:01means like just this this is just a
  953. 42:04trans like this indicates one bit right
  954. 42:07this is also a symbol these are all
  955. 42:09symbols and certainly in wireless
  956. 42:10communication you often times many
  957. 42:12transitions could equal a symbol. Um but
  958. 42:15here we're just saying that okay uh uh
  959. 42:18you have a certain number of symbols go
  960. 42:20through but how is that different than
  961. 42:21data rate? Well remember by the
  962. 42:23definition here
  963. 42:25not all of these bits are data bits
  964. 42:28right so here we have a start bit a par
  965. 42:31bit and a stop bit. Well those three
  966. 42:32bits aren't data even though the par you
  967. 42:35know technically has some idea about
  968. 42:37data it's not those are overhead to your
  969. 42:39protocol. So here your baud rate is just
  970. 42:43about your data rate how many how much
  971. 42:45data gets through per second not your uh
  972. 42:47or your symbol rate which is uh just
  973. 42:50sorry baud rate is about symbol rate not
  974. 42:53about your data rate
  975. 42:57what's going on
  976. 43:00and so here's just an example of an a
  977. 43:02fictitious uh thing that could increase
  978. 43:05your baud rate here right because here
  979. 43:08uh each symbol has more encodes more
  980. 43:11data than just the single symbol. So
  981. 43:13here you can encode two bits with this
  982. 43:15particular encoding scheme. Now this is
  983. 43:16fictitious. This is not how um UART
  984. 43:19works, but it's just showing that like
  985. 43:21the number of bits per symbol does not
  986. 43:25uh the same as the symbol itself. There
  987. 43:27are ways to trick the system and get
  988. 43:29more information through per symbol.
  989. 43:36No questions. Okay. Um
  990. 43:41yeah, I think I just said this, but here
  991. 43:43this is the most common um baud rate. So
  992. 43:46each frame has in this particular case
  993. 43:48say like one start bit, eight uh data
  994. 43:51bits, one stop bit, no parody bits. And
  995. 43:53so you might say, okay, well u I'm going
  996. 43:56to go through and um
  997. 43:59uh calculate what the baud rate is.
  998. 44:01That's not actually it. Instead, you
  999. 44:02have to consider about the overhead of
  1000. 44:04the protocol.
  1001. 44:06Okay, now we had jumped ahead because I
  1002. 44:08put these out of order. The asynchronous
  1003. 44:10versus the synchronous.
  1004. 44:12All right, let's go through a particular
  1005. 44:14this is like a standard oscilloscope
  1006. 44:16transaction. Here you're seeing is
  1007. 44:17between 0 to three to three volts
  1008. 44:19because that's typically how you're
  1009. 44:20going to see for most microcontrollers.
  1010. 44:23Um here we have a start bit, stop bit uh
  1011. 44:26start bit and then we have data bits. In
  1012. 44:28this particular case, you have to know
  1013. 44:30beforehand that it's LSB first. Uh, and
  1014. 44:33then you have um a stop uh one start
  1015. 44:36bit, one stop bit. This is what it's
  1016. 44:38telling you. Eight data bits, no par,
  1017. 44:40and that's the baud rate. And then you
  1018. 44:41can go through and you're just going,
  1019. 44:43you have to figure out where to clock in
  1020. 44:45your data. So it could be all zeros uh
  1021. 44:48and then you just have to really trust
  1022. 44:50that like you, you know, did the math
  1023. 44:52correctly or it could just be one high
  1024. 44:53thing and you got to make sure that you
  1025. 44:54figured out where it is. Uh and then of
  1026. 44:57course you can send one packet after
  1027. 44:58each other. I think that this is very a
  1028. 45:00very optimistic uh data transfer cycle
  1029. 45:03in the sense that your hardware had to
  1030. 45:05be ready to send both of that those
  1031. 45:07packets which means typically you have a
  1032. 45:10buffer full of data and then you're
  1033. 45:12asking your peripheral to clock out that
  1034. 45:14data. Um but if you're say you're taking
  1035. 45:17data all the way from the core and say
  1036. 45:18now send this over UART then you go
  1037. 45:20another thing all the way from the core
  1038. 45:21you have to pay the penalty to go
  1039. 45:23through the advanced peripheral bus and
  1040. 45:24send it all out which has a latency
  1041. 45:26associated with it. So this would be a
  1042. 45:28scenario where you have a buffer in your
  1043. 45:30peripheral and you're telling it to
  1044. 45:31clock out this data.
  1045. 45:38What questions do you have?
  1046. 45:46>> Yeah. So I didn't I should just show you
  1047. 45:49the nomenclature, but it's essenti like
  1048. 45:50here I'm telling you what how many bits
  1049. 45:52it is, but typically it's something like
  1050. 45:53this. Um
  1051. 45:57like for this it would be like
  1052. 46:01one eight.
  1053. 46:04Oh no, you don't usually don't do the
  1054. 46:05one because it's always one start bit.
  1055. 46:07It would be like eight
  1056. 46:09uh n for no par and then one. So that's
  1057. 46:13like the nomenclature for this
  1058. 46:14particular thing. So there's always one
  1059. 46:16start bit is optional one or two stop
  1060. 46:19bits and it's telling you the number of
  1061. 46:21data bits and the number of par bits. So
  1062. 46:23it would be eight for uh data bits, n
  1063. 46:27for no par or a p and then you would
  1064. 46:30have a one or two for stop bits. So you
  1065. 46:32have to know that information beforehand
  1066. 46:34has to be given to you. That's the
  1067. 46:36information. And then you also have to
  1068. 46:37know the bud rate.
  1069. 46:44You want to decode one of these things
  1070. 46:46for yourself. Super exciting.
  1071. 46:51And can you pass them like that way
  1072. 46:53behind you too?
  1073. 46:59You can pass them up that way.
  1074. 47:04There you go. Thank you.
  1075. 47:11You're going to fasten this way and that
  1076. 47:13way.
  1077. 47:16Go.
  1078. 47:22My bad.
  1079. 47:34>> Did I tell you if it's most significant
  1080. 47:36bit? I don't think I did. Yeah.
  1081. 48:27>> [clears throat]
  1082. 48:30>> That's
  1083. 48:40Amen.
  1084. 48:52This is
  1085. 49:08crazy.
  1086. 49:22I think I forgot to say there was lsb.
  1087. 49:24It doesn't really matter but and you
  1088. 49:27would have to use an asky table to
  1089. 49:29figure out what uh asky character it is.
  1090. 49:31We would provide that to you if we
  1091. 49:32carried on the exam. But here you can
  1092. 49:34assume it's LSB.
  1093. 49:54start.
  1094. 50:22Okay.
  1095. 50:51You got a Let's go.
  1096. 51:18Hey,
  1097. 51:37I know.
  1098. 51:54Yeah. Yeah. Yeah.
  1099. 52:30I'm sure
  1100. 52:37Number
  1101. 53:02[clears throat]
  1102. 53:33Smells like water.
  1103. 53:35>> Wow.
  1104. 53:42>> [clears throat]
  1105. 54:04>> My god. Thank you.
  1106. 54:27>> No, we will not.
  1107. 54:35section.
  1108. 54:58[groaning]
  1109. 55:01We had more
  1110. 55:04Yeah.
  1111. 55:22[cough]
  1112. 55:31Right.
  1113. 55:34kind of warm up. Yeah.
  1114. 55:41[clears throat]
  1115. 55:53I love you.
  1116. 56:05[clears throat]
  1117. 56:26Yummy.
  1118. 56:38Let's
  1119. 57:26Yeah, I think so.
  1120. 57:37What you get for your
  1121. 57:56All
  1122. 58:04right. What do we get for
  1123. 58:06>> uh uh your what what asking character is
  1124. 58:10this?
  1125. 58:13>> Does anybody get anything other than G?
  1126. 58:17>> Good. I'm glad to see I always check my
  1127. 58:18work by asking me first. If I get enough
  1128. 58:20people that agree with my answers, then
  1129. 58:22I'm like, "Okay, go forward." But how do
  1130. 58:24we figure that out? So here the trick is
  1131. 58:27uh try and do this. So here the uh this
  1132. 58:30is giving you all the information and
  1133. 58:31then we just wrote it out for you just
  1134. 58:33to to help uh figure it out. So we're
  1135. 58:37always going to assume that we're in the
  1136. 58:39uh idle state high. So we've been high
  1137. 58:42for a while
  1138. 58:44and then the transition from high to low
  1139. 58:47indicates the beginning of a start bit.
  1140. 58:49So like right here would be that start
  1141. 58:50bit. And so we're going to call this
  1142. 58:52test. Okay. [sighs]
  1143. 58:54Now, it is technically a zero, but it's
  1144. 58:56better to call it x. It's not actually
  1145. 58:57data. And now, the trick would be, well,
  1146. 59:00what happens if it was actually like
  1147. 59:02this, right? The first bit, we made it
  1148. 59:04easy for you because the first bit is a
  1149. 59:06one, but the first bit is zero. Well,
  1150. 59:08then you better be pretty confident that
  1151. 59:09you know what the bar rate is. Then
  1152. 59:11you'd have to go through and do the math
  1153. 59:13to figure out, wait, is this really a
  1154. 59:16one or a zero? Or is this a long zero or
  1155. 59:19is this a one? Right? Kind of you'd have
  1156. 59:22to know. The only thing that tells you
  1157. 59:23that is the B rate. [snorts] That make
  1158. 59:25sense?
  1159. 59:29No. Yes. Okay.
  1160. 59:33And so then we're going to get one one
  1161. 59:37zero
  1162. 59:41one
  1163. 59:43and then zero. And then we're back here
  1164. 59:45to uh stop bit
  1165. 59:49I guess. Uh put this T here for now. So
  1166. 59:52here we have start bit, stop bit. It's
  1167. 59:53good to label them as those things and
  1168. 59:56then you can go put this in an ASP
  1169. 59:58table. Uh we said it was the lowest uh
  1170. 1:00:01significant bit first which is I don't
  1171. 1:00:03know if that's the default. That's just
  1172. 1:00:05a common state for u uh that it's LS.
  1173. 1:00:10So if you're going to label this on an
  1174. 1:00:12exam or homework like label out that
  1175. 1:00:14they start and stop. It's it's better
  1176. 1:00:16not or parody bits if they're there.
  1177. 1:00:17It's better not to label them as ones
  1178. 1:00:19and zeros. Does anybody have a question
  1179. 1:00:21about how we got here?
  1180. 1:00:29All right. So then we got G. And how do
  1181. 1:00:31you get you? Well, you go look up on an
  1182. 1:00:32ASI table. Did I give you ask table? No.
  1183. 1:00:35In exam, we would give you an ASI table.
  1184. 1:00:37Uh but you can look online or not. But
  1185. 1:00:39it's really the ones and zeros. And asie
  1186. 1:00:41is used so often you might as well as
  1187. 1:00:44system engineers be aware of it. All
  1188. 1:00:46right. So how do you go about figuring
  1189. 1:00:48out the bud rate?
  1190. 1:00:59It's like this period.
  1191. 1:01:02>> Yeah.
  1192. 1:01:06>> Just like the the duration basically.
  1193. 1:01:09>> So you could just go take that number
  1194. 1:01:11and divide by one.
  1195. 1:01:14>> But and so the one problem is your your
  1196. 1:01:16graph might not be perfect, right? There
  1197. 1:01:18might be some errors. So it's just the
  1198. 1:01:21number of bits is by the number of
  1199. 1:01:23period of time. So you can go all the
  1200. 1:01:24way [clears throat] up to 9 uh 37.5.
  1201. 1:01:28But then you have to count all those
  1202. 1:01:29bits, right? So the bottom rate number
  1203. 1:01:31changes. It's just the time interval
  1204. 1:01:33divided by the number of bits. And so
  1205. 1:01:35what is that people get?
  1206. 1:01:41>> 9600.
  1207. 1:01:42>> 9600. That's what I got. I saw at least
  1208. 1:01:45three people got 9600. So, I'm locking
  1209. 1:01:47that answer in. Any questions on how to
  1210. 1:01:50decode this.
  1211. 1:01:56Now, one thing to to think about is that
  1212. 1:01:59um this we kind of show this as one
  1213. 1:02:02single transaction on one line, but
  1214. 1:02:04there could be two different there are
  1215. 1:02:06two lines, a transmit and receive line,
  1216. 1:02:08and they're separate lines so that each
  1217. 1:02:10device doesn't they don't collide. And
  1218. 1:02:12they don't have to be synchronized at
  1219. 1:02:14all to send data. Like it's not that one
  1220. 1:02:16sends data and then they wait and the
  1221. 1:02:18other one does. Happens to be that's
  1222. 1:02:20often the case where they could just be
  1223. 1:02:21sending data at the same time. You could
  1224. 1:02:23have half the packet like coming in from
  1225. 1:02:25the other transmission other line under
  1226. 1:02:28here. There's no guarantee that one is
  1227. 1:02:30talking while the other one's not
  1228. 1:02:31talking. Um they don't have to because
  1229. 1:02:34they have two separate physical lines.
  1230. 1:02:37Okay,
  1231. 1:02:39let's see. And uh I put those answers to
  1232. 1:02:42be online. You can do those. Okay. uh
  1233. 1:02:44what they are. It's not exactly 96 bits.
  1234. 1:02:46It's approximately and that's because
  1235. 1:02:48there is error in these. It just it's
  1236. 1:02:51allowing there to be error in the
  1237. 1:02:53protocol. Uh because the crystals aren't
  1238. 1:02:56always the same. The clock division, the
  1239. 1:02:58biggest source of error is that you have
  1240. 1:02:59a really fast crystal, really precise,
  1241. 1:03:01[clears throat] beautiful crystal, but
  1242. 1:03:02then the baud rate is not an even number
  1243. 1:03:05of that crystal. So then you you have an
  1244. 1:03:07approximation and that's why protocol
  1245. 1:03:10allows approximately 10% error
  1246. 1:03:13accumulation because they know over 9 10
  1247. 1:03:16uh symbols that you're not going to lose
  1248. 1:03:18phase lock. You're not going to start um
  1249. 1:03:22[snorts]
  1250. 1:03:23counting a different bit than you should
  1251. 1:03:24have.
  1252. 1:03:27Uh oh, there's a missing slide here. But
  1253. 1:03:30essentially inside here
  1254. 1:03:37So this is an example of uh your um
  1255. 1:03:43uh your uh microcontroller. Uh this is
  1256. 1:03:46uh inside the the biggest trick of
  1257. 1:03:48almost all the serial protocols is that
  1258. 1:03:50it is a way to go from the world of
  1259. 1:03:53serial to the world of parallel. Like
  1260. 1:03:55that's what almost all these things are
  1261. 1:03:57trying to accomplish internally. And
  1262. 1:03:59it's just a chip register, right? So
  1263. 1:04:01serial data comes in and you don't want
  1264. 1:04:04your core going out here and sampling
  1265. 1:04:06one bit at a time, right? That would
  1266. 1:04:08just be inefficient. So the this device
  1267. 1:04:11here is perfect shift shifting in pull
  1268. 1:04:15it out as paradol data. And so this is
  1269. 1:04:18the this is why we still use UR today.
  1270. 1:04:21So the simplicity of this structure and
  1271. 1:04:23its flexibility, the you know people
  1272. 1:04:26developing microcontrollers said, "Oh,
  1273. 1:04:28we're just going to borrow that because
  1274. 1:04:29it's such a well utilized and useful
  1275. 1:04:32structure from the uh ancient PC world."
  1276. 1:04:35They reuse this uh to figure that out.
  1277. 1:04:37And then you see the same thing here.
  1278. 1:04:39The difference now is that um modern
  1279. 1:04:41microcontrollers, they give you a FIFO
  1280. 1:04:43buffer and you have interrupts and all
  1281. 1:04:45these other signals. And the goal here
  1282. 1:04:47really is that you will set your thing
  1283. 1:04:49up and uh data will come in and it'll
  1284. 1:04:51fill up the the 54 buffer and I forgot
  1285. 1:04:53exactly what the size is for your
  1286. 1:04:55particular device. But you can imagine
  1287. 1:04:57data comes in you get an interrupt or
  1288. 1:05:00something. You have to pull the data out
  1289. 1:05:01fast enough so that the next data piece
  1290. 1:05:03of data that you push in doesn't get
  1291. 1:05:05overwritten. So you'll find when you do
  1292. 1:05:07your labs uh that there's these
  1293. 1:05:09concurrency problems where if you're not
  1294. 1:05:10servicing interrupts fast enough or
  1295. 1:05:12you're not uh setting up your buffers
  1296. 1:05:15properly and your buffer size that your
  1297. 1:05:17data can get overwritten and now you're
  1298. 1:05:19saying well wait a second something's
  1299. 1:05:20wrong right I'm sending packets but I
  1300. 1:05:23sent five packets I only received four
  1301. 1:05:25or even one that's really not the
  1302. 1:05:28transmitter side it may be your side but
  1303. 1:05:29you're not pulling the data out fast
  1304. 1:05:31enough. So that's a common set of
  1305. 1:05:33problems
  1306. 1:05:36and that leads to this idea that often
  1307. 1:05:39times you're you're going to set up an
  1308. 1:05:41IRQ handler or interrupt that says you
  1309. 1:05:43get a bite in or your buffer is full and
  1310. 1:05:46then you send uh a signal to your core
  1311. 1:05:50which [snorts] pulls the data out to
  1312. 1:05:51make sure that it's not going to get
  1313. 1:05:52bothered. Same thing for writing. You
  1314. 1:05:54might have a large um multicar string
  1315. 1:05:58that you have to send out. Um you could
  1316. 1:06:00if there is a buffer you can fill with
  1317. 1:06:02the buffer and say you know flush that
  1318. 1:06:04buffer or you said when you have the
  1319. 1:06:07buffer has been emptied you send up the
  1320. 1:06:09IRQ that interrupts the core and then
  1321. 1:06:11you just send out the next flight. So
  1322. 1:06:13that's just a way to make maximum use
  1323. 1:06:16utility out of your device to get
  1324. 1:06:18maximum transfer without having to be
  1325. 1:06:20pulling for any of those other things.
  1326. 1:06:23Any questions?
  1327. 1:06:29Okay. Um the modern instantiation of uh
  1328. 1:06:33UART is there's a couple different
  1329. 1:06:35places where you're going to see it all
  1330. 1:06:36the time. Um and that is usually you're
  1331. 1:06:39trying to get off of device. And so here
  1332. 1:06:42you have my little microcontroller with
  1333. 1:06:44a RX and TX and then a common chip that
  1334. 1:06:47you find there. There are other brands.
  1335. 1:06:48Uh but it's FTPDR chip. Uh I don't
  1336. 1:06:51decide right in there. I just know it's
  1337. 1:06:53called FPDR. I think that's the acronym
  1338. 1:06:55for the company and they have a FTE 232
  1339. 1:06:58whatever are and basically this chip
  1340. 1:07:00holds the USB interface. It does the
  1341. 1:07:02entire USB protocol which is painful and
  1342. 1:07:06the amount of signaling and overhead and
  1343. 1:07:08confirmation packets and you this in 373
  1344. 1:07:11you don't want to deal with that
  1345. 1:07:12overhead uh because it's unless there's
  1346. 1:07:15a nice library or something you can
  1347. 1:07:16instantiate but you certainly wouldn't
  1348. 1:07:17want to do it yourself. You don't want
  1349. 1:07:18to busy the floor with it. So here you
  1350. 1:07:21would have your microcontroller and you
  1351. 1:07:22already know this chip and then there's
  1352. 1:07:24a USB cable that comes through to your
  1353. 1:07:25computer and you would look at the data
  1354. 1:07:27sheet of this chip and maybe there's
  1355. 1:07:29some configuration packets. You say okay
  1356. 1:07:31I want you to be USB 2. I want you to do
  1357. 1:07:33XYZ and you have to know what the B rate
  1358. 1:07:36is and the symbol rate and then this
  1359. 1:07:37thing is just going to send over
  1360. 1:07:40uh the you know the asky characters or
  1361. 1:07:43whatever the message is to the computer
  1362. 1:07:45and then this chip is going to handle
  1363. 1:07:47the entire protocol for you. So that is
  1364. 1:07:50essentially on your dev kits already.
  1365. 1:07:52There is a chip that's effectively
  1366. 1:07:54equivalent to the FDI chip that is doing
  1367. 1:07:56this task. It's a bridge between UR uh
  1368. 1:07:58and USB. Now your particular device does
  1369. 1:08:01have an internal USB peripheral. You can
  1370. 1:08:04use that if you want. Um there's just
  1371. 1:08:06different trade-offs can be made.
  1372. 1:08:10Uh yeah, it's just the same. This is
  1373. 1:08:12just a standard schematic showing
  1374. 1:08:14[clears throat]
  1375. 1:08:15the actual USB connector. And you have
  1376. 1:08:17to have a bunch of extra little
  1377. 1:08:18circuitry around there to handle. USB is
  1378. 1:08:21really noisy actually because it's like
  1379. 1:08:23consumer grade and all horrible things.
  1380. 1:08:25But aside from that, it this works out
  1381. 1:08:27really well. And then the other way that
  1382. 1:08:30almost every one of you will use this
  1383. 1:08:32probably on your project is this a way
  1384. 1:08:35to make a radio uh communication. So you
  1385. 1:08:38do Bluetooth or maybe XP or Ziggp. These
  1386. 1:08:41are different protocols. And instead of
  1387. 1:08:43worrying about how does wireless work
  1388. 1:08:45and how do I get wireless signals to go,
  1389. 1:08:47you're just going to make this uh bridge
  1390. 1:08:50in which you will send over uh some
  1391. 1:08:53configuration data to the um the the
  1392. 1:08:57bridge module, the XP module. It will
  1393. 1:08:58basically say this is your channel, this
  1394. 1:09:00is your ID and then you will it will do
  1395. 1:09:03all the radio communication
  1396. 1:09:04synchronization all those other things
  1397. 1:09:06and then your computer or your other
  1398. 1:09:08device will just pick up.
  1399. 1:09:09[clears throat]
  1400. 1:09:10Just think of how we use UR is really as
  1401. 1:09:13a bridge to the external world through
  1402. 1:09:15these other chips. That's the modern way
  1403. 1:09:17that we're using now.
  1404. 1:09:21Questions? Yeah.
  1405. 1:09:22>> If you go back a couple slides to
  1406. 1:09:25device, does that
  1407. 1:09:28request data
  1408. 1:09:30mismatch?
  1409. 1:09:31>> I'm sorry. Is it do what? Does that chip
  1410. 1:09:34angle like oh the period is wrong when
  1411. 1:09:38you requesting the money that's a good
  1412. 1:09:40question probably
  1413. 1:09:43like so that would all be coming from
  1414. 1:09:45here so your microcontroller hit the
  1415. 1:09:47wrong thing right now this um I don't
  1416. 1:09:50know how it's set up a data sheet
  1417. 1:09:52typically
  1418. 1:09:54you have to see I don't know uh let's
  1419. 1:09:57see can we look there's some of them
  1420. 1:09:58that have an error a bus error signal
  1421. 1:10:01that you can choose [clears throat]
  1422. 1:10:02I'd have to look through all the
  1423. 1:10:03schematics but they actually provide
  1424. 1:10:05like all these extra pins and some of
  1425. 1:10:08those you can actually see are leftovers
  1426. 1:10:10from the old protocol. So like this is
  1427. 1:10:12clear channel this is like I forgot what
  1428. 1:10:15these bits are but they implement these
  1429. 1:10:17extra functionalities so that you can
  1430. 1:10:18get that feedback
  1431. 1:10:21um
  1432. 1:10:23and then it it's doing all the error
  1433. 1:10:24handling uh between you and USB. So if
  1434. 1:10:27that has an error uh it will talk to the
  1435. 1:10:30computer and figure that out.
  1436. 1:10:35Okay.
  1437. 1:10:37Uh and then uh just to kind of wrap up,
  1438. 1:10:41this is a weirdly formatted slide, but
  1439. 1:10:43uh on your particular device, you have a
  1440. 1:10:45US uh serial interface channel. So
  1441. 1:10:48there's a module called FA and it has um
  1442. 1:10:51up to six uh channels. Now a channel is
  1443. 1:10:54not a single wire. A channel just means
  1444. 1:10:57essentially a protocol. though you have
  1445. 1:10:59these configurable modules that can be
  1446. 1:11:02UART or SPI or I squared C. Those are
  1447. 1:11:06other protocols you'll learn about
  1448. 1:11:07later. I2S is an audio protocol. Um I
  1449. 1:11:10actually don't know what LIN is. Um but
  1450. 1:11:13there are different types of protocols
  1451. 1:11:15and because they're relatively simple
  1452. 1:11:17now like 15 20 years ago you might get a
  1453. 1:11:21device that can only do SDI or only do I
  1454. 1:11:24or they might need different modules to
  1455. 1:11:26dedicated different antennas. Now uh
  1456. 1:11:29digital logic is relatively cheap. The
  1457. 1:11:32IP to put that on a chip is readily
  1458. 1:11:34available and now you have these six
  1459. 1:11:36different modules essentially three
  1460. 1:11:39modules each with two channels. But
  1461. 1:11:40regardless that can do lots of different
  1462. 1:11:43protocols. So now it's just a task for
  1463. 1:11:45you to figure out okay I which protocols
  1464. 1:11:48do I want to have on my embedded system?
  1465. 1:11:51Which pins are available? And then you
  1466. 1:11:52can reallocate uh these modules to do
  1467. 1:11:55those different tasks. Um, so they're
  1468. 1:11:58reconfigurable. They have uh, you know,
  1469. 1:12:01uh, word buffers, so they do have hypos
  1470. 1:12:03in them so that you don't have to
  1471. 1:12:05constantly pull data out and it helps
  1472. 1:12:08you miss less packets. It makes the
  1473. 1:12:09assumption across 16 bits. And then each
  1474. 1:12:11of the modules has IRQS. And so those
  1475. 1:12:15IRQs can be data is available, data got
  1476. 1:12:17sent, error, all those other uh, other
  1477. 1:12:19things. And those are configurable as
  1478. 1:12:21well.
  1479. 1:12:23All right. Uh, pros and cons. So only
  1480. 1:12:26two wires, no clock signal, so that's
  1481. 1:12:28nice. And it has error correcting in it.
  1482. 1:12:31Um, so those are all like pretty good
  1483. 1:12:34features. Uh, the the challenge here is
  1484. 1:12:36that the the data frame is going to be
  1485. 1:12:37limited to like 9 uh bits at max unless
  1486. 1:12:41you try and like really make some sort
  1487. 1:12:42of custom thing, but typically your
  1488. 1:12:45hardware is going to be at that level.
  1489. 1:12:47And it doesn't really support multiple
  1490. 1:12:50uh peripherals or multiple uh
  1491. 1:12:52controllers at once, even though it once
  1492. 1:12:53did. uh that's just not the
  1493. 1:12:55functionality that we have now. So, it's
  1494. 1:12:57usually one device to another device. Um
  1495. 1:13:00[snorts] oops. It's not really a con
  1496. 1:13:02anymore, but the hardware has to do the
  1497. 1:13:05oversampling or the hardware has a clock
  1498. 1:13:07that's 1632 or eight times faster. Back
  1499. 1:13:11in the day, that was a problem. I
  1500. 1:13:12suppose now it's not really a con. It's
  1501. 1:13:14just something to think about. Uh and
  1502. 1:13:16then last one, last two is that uh you
  1503. 1:13:20have to agree on everything a priority.
  1504. 1:13:22USB is nice. You don't have to agree on
  1505. 1:13:23anything. The protocol itself negotiates
  1506. 1:13:26speeds uh and that sort of stuff. But
  1507. 1:13:28here you have to actually have read the
  1508. 1:13:30data sheet or the device you're plugging
  1509. 1:13:33in. You as programmers have to agree on
  1510. 1:13:35the spec of how you're going to encode
  1511. 1:13:38data least significant most significant
  1512. 1:13:41bit fog rate all those sort of things.
  1513. 1:13:43And then inherently you're going to be
  1514. 1:13:45limited in how good that packet can be
  1515. 1:13:48because you're dealing with the
  1516. 1:13:49stability of the clock and more
  1517. 1:13:51accurately the inaccuracies of your
  1518. 1:13:53clock dividers to hit basically their
  1519. 1:13:55body.
  1520. 1:13:56Okay,
  1521. 1:13:58any last questions? [clears throat]
  1522. 1:14:08>> Nope, that [clears throat] is data bits.
  1523. 1:14:10So there
  1524. 1:14:13>> uh there you can go up to 9 bits. Almost
  1525. 1:14:15everything is 8 bits. Everything you're
  1526. 1:14:16going to see in the world is 8 bits. You
  1527. 1:14:18could it's very uh your hardware is
  1528. 1:14:20going to support up to 9.
  1529. 1:14:25[clears throat]
  1530. 1:14:38Yeah. What is it?
  1531. 1:14:44You so why do you have parity bit? What
  1532. 1:14:47would you do with it? So you're a
  1533. 1:14:49receiver, you know, do not trust that.
  1534. 1:14:52That's all you can do with that. Say
  1535. 1:14:53this pack is then you can choose to get
  1536. 1:14:56more data. Ask for it if that's
  1537. 1:14:58available or you just throw away.
  1538. 1:15:01>> All right. Thank you. See you on Friday.

About this transcript

This page contains the full transcript of EECS 373 - Fall 2026 - Lecture 11: "Serial Bus Over & UART" by Interactive Sensing and Computing Lab , generated from the public captions YouTube serves with the video. The transcript has 10,451 words across 1,538 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.