 Welcome to my desk it is another Sunday night or weekend night. It's me Lady Ada here at my desk working on some electronics Gonna talk about some electronics design and more with me mr. Lady Ada. Hello there on camera control any news or updates You want to know peep-to-peep? Oh, it's just jump right in No, no news is good news. No news. Good news. All right, so Let's go to the overhead. So I finally finally finally finished my UPD I Programming code for standalone programming. So UPD I is is I don't know what it stands for probably universal programming Debug interface or something. It's from microchip and it's for the latest AT-TINY Mega chips as well. It's their programming interface Actually, I don't have an Arduino UNA with me, but the traditional way that Arduino's were programmed is through a six-pin interface the ISP six-pin clock data and data out reset interface and Their new chips are programmed with a one pin interface. It's a asynchronous sorry, it's a Synchronous you are so it's one pin and it's you are received and transmitted and automatically Switches, you know, it's usually receive mode after it seems a command It goes into output mode sends the data over that same line and then goes back into receive mode Which means you only need to use one pin and it's also shared with the reset line For some pins sources for some chips and so you can use it for high voltage programming or low voltage, you know, whatever and It's a it's a nice interface because I feel like they kind of figured out like oh instead of this three-pin interface Which requires again three pins and it's you know, so you have to have a special adapter because as you are you can actually put together a programming interface using just a FTDI cable You know you have the FTDI cable and on the end, you know You have the the power ground data in data outliers and then all you have to do is put one resistor between the TX line and The serial input pin so this is TX to resistor to UPDI and this is the RX line Because that way your transmission isn't overwritten by the chips transmission line Just gives you like a little bit of a you know It gives you some softness to that line so it doesn't overdrive the synchronous one pin you are So that's cool. But you know, again, even though you can program it within a you know $5 Serial USB to serial cable. I do want to have The ability to program these chips from another microcontroller. Why because it lets me build test jigs very easily the chip Itself, you know, I don't want to have a computer involved in the test procedure because anytime you have a computer involved there's like operating system updates and like People get locked out and and like the computer needs to reboot and like maybe they don't have a power plug Whatever it's it's annoying and they have to type things in it's better to have a microcontroller Do it because then you can put a single button on the micro press the button It programs the chip for you and then you know It can it can beep or buzz or light up a LED or OLED to tell you that the chip has been programmed or something Wrong, it'll give you an error message So this is the breakout that I designed so this it's so small But this is an 80 tiny 817 and I brought all the GPIO pins out It's got two stomach your T pins because I'm using this as a I squared C to whatever adapter You can see that there's a power LED. It's green and then there's a readily the that's a blink Program that's running on it because that's what I've been programming it with and then Over on the computer, you know, I have the UPDI code, which is part of GitHub and I'll show off It's in a branch Called UPDI over on AVR Prague You know have added the two files for UPDI Prague C++ and H it's from AVR Prague master Yeah, it's from another person's project. I've basically adapted them. I'll give them credit because it's a it's an open source license But that's just Arduino friendly So that I can have Images what I want to program into the chip. I store it basically in a header or C++ file So this is just the hex like literally like I just copy and paste it into The C++ file and then I can Write that image using AVR Prague dot write image after I've connected and verified that the UPDI Target is the chip I want. So what does that look like? Let me reset This board and then this is this is kind of going but I'll I'll scroll up to the top So it starts the program mode verify that it sees a chip it erases the chip and then it writes Pages so memory on microcontrollers is stored in flash pages You don't write one byte at a time like EEPROM usually write a page and that you know Helps because for the most part you have to do this kind of a right erase right cycle for flash memory It's kind of it takes time and you have to get this voltage, you know up this this 12 volt internal voltage And so you don't want to do one by a time. So it's too long. You really want to do like 32 64 128 bytes at a time Usually pages are between 8 and 128 bytes You basically have to write one page at a time not a big deal if you're writing flash memory Usually you're actually a racing the whole thing and then writing it all at once so this flash is 64 bytes at a time and it goes through and It writes the memory one thing that is interesting is you see that the first address it writes to is actually 8,000 hex that's because even it was actually kind of nice old AVR chips Program memory, you know was started address zero and program memory and RAM memory were totally separate like there's no They're completely different Memory interfaces, which is why you had like special prog mem Words that you had to put into the compiler if you wanted to read from flash or write You know if you want to store data in flash memory, you'd have to use like read problem memory word or whatever for AVR is because Address zero in RAM and address zero in flash, you know, you had to tell it whether you wanted that data from RAM or from flash What's cool is it, you know, if you're used to cortex chips on the other hand Or pretty much anything other than these old AVRs your memory is like, you know 32 bits or 16 bits or whatever 32 bits usually and You have one address space for everything. So your flash memory would start, you know, your RAM Maybe he's in the first chunk and then you have some user pages maybe and then you have Your interrupt stuff and then you'd have flash memory and then you'd have your peripherals and it's like one if you look at like the data sheet for a Samdi 21 or something it'll have the address locations of all the peripherals and it's like it is one big memory space Which is cool because you don't have to do this like weird like oh, I'm going into the peripheral address memory And I'm going to the RAM memory I'm going to flash memory. So that's why it starts a long story short That's why it starts at 8,000. I only I don't know about 20 minutes on that Luckily the the code that I'm adapting had a little variable called flash start and I was like and then I also compared the output from Programming with a USB serial cable versus my code and I was like, oh wait, I'm wearing the wrong Location and memory and that's how I kind of discovered this offset thing. So once I fix the offset You know, I'm good to go. I write all the pages and then when I read You don't have to read in pages. You'll have to write in pages. And so when I read memory, I'm reading This is 64 bytes. I'm reading 256 bytes. Why it's four times faster because it's you know You don't do this whole setup get the chip into the right situation and then and then read the data One other thing that's kind of interesting about This You know, this is kind of what if you have the debug output on this is what it looks like what I think is kind of interesting is that It it actually there's like a sub-assembly language like basically you PDI years you're actually sending commands to the chip like store and load and Repeat there's like it in an assembly language that you program it with and so There are commands you use but you can also kind of craft together a little programs To perform functions to read and write data and so you can you can speed things up again Because if you want to write a Page you tell it okay, you know, I want to write data to this address And I want you to repeat it 64 times and you can like kind of bang out the data instead of writing one byte at a time To the pointer Which is what you would do with a VR ISP It's just like a detail if you've ever written a low-level program or your it is kind of nice I see what they're doing here. Although you really need to have the the command list ready Like because it isn't just like one command that does a bunch of stuff for you. It's like all these load and stores It's definitely something. I'm glad I didn't have to write this from scratch. I only had to adapt it. So That's that Okay, so I thought we really thought we'll push up to questions. Okay, I thought really fast I would put together a tester for this So This is oh, sorry port-a-prog was the program that I used to get the UPDI code They did an amazing job. Thank you person who did this who I can't remember my head Who it is, but they're wonderful. Thank you Open source to the rescue now the code is available in Arduino. So you can use it with Arduino Okay, so this is the breakout and one thing is, you know, like I mentioned you you program it with this asynchronous You are and you do want to program it pretty fast Like you don't want to use it does autobot detection every bite every command starts with the the byte 0x55 which is a square wave in you are it's like zero one zero one zero one zero zero one and so it does Autobot because it's looking for that 55 and and so it knows what what the baud rate is by measuring the time between each pulse However, you don't want to run it slow. You want to run it 115 point 2k We might be a little faster, although that's kind of the standard baud rate And so one thing to note about this is I have been able to program small chips Like an 80 tiny 85 or or even just a bootloader using an Arduino Uno or compatible to program the board But I won't be able to do that with these chips because the Uno doesn't have an extra hardware You are that hardware you are is used for debugging. I can't I can't use that for Program those chips so the programmer has to be something like a metro M zero or M four because that will have a spare Hardware you are that's not useful programming and debugging like You can use software serial and believe me. I wrote software serial So I know it is kind of sort of possible to do but it's a little flaky. It's not worth the hassle I'm just gonna update this instead of using a Arduino Uno to be the program test to choose a metro M zero instead So this is the board and so I want to make a little test jig something that This plugs on to now. It is all annoying that this doesn't have holes in it But you know, I think we can make a little plastic cutout maybe Instead so I'm going to go to Other mail which is where I I live my my testers live So I'm gonna make a new ones. This is gonna be pav xxx. I don't know the part number yet This is the 80 tiny 8x Seven Okay, so What I do then is I'm going to Grab the board files and and paste them here so I've got another copy of the board files and I'm now editing a copy not the original and First off just to make sure I remember I'm going to delete all the lines And then in the schematic I'm going to I'm gonna keep the headers because they're useful, but I'm going to delete the stem a qt connectors. They do not need those Also don't need the regulators or the pull-ups Leave the chip For the very moment, but I will delete that shortly only the only reason I want the chip is is I'll show in a minute Why but I'd like to keep the chip here. I'll note that the pins are not totally They're not totally in order like it starts 0123 and that kind of skips a bunch and then 765 goes the opposite way And then 321 and then it kind of goes sort of an order So just and this is that programming pin you PDI also note. It's a reset pin. So this is a dual purpose pin Okay, so then what I'm going to do is I'm going to add a shield Layout so again, I'd like to use Arduino compatible shields as the brains for my testers because If the board gets broken and they do die, it's really easy again another one I don't like to do fully custom boards a little shield thing is it's not too bad so I'm going to find a R3 Beplace I think this is good. I do not need the 2x3 header So great now. I've got an Arduino layout here Okay, so one thing is I'm definitely going to want to test the I squirts. I'm gonna use I squared C to connect to this. So I want this SCL SDA to connect to my test brains SCL SDA Together cool beans Okay, next up, there's that UPD. I pan remember I get to use the hardware you art to connect to this So I'm gonna go over here okay, and I'm going to use the hardware you are and of course, I cannot remember whether it's RX or TX So I'm just gonna put Whoa, I'm gonna put a 1k resistor on both and then I don't know I'll figure out I'll figure out later Which is the arcs and just the TX if you're if you're worried you're gonna get them wrong because you will just make it so it doesn't matter Do you guys see no problem whichever one is the correct one? I'll put the 1k resistor the other one I'll put a zero resistor and then I get my problem solved and I don't think about it Isn't that nice? No resistor. No problem. No resistor. No problem. Okay, so next I have to power the board and Usually I would power the board directly from the five volt on the mic controller However, I'm noticed that UPDI like Because this chip the UPDI is shared with a reset You're you kind of want to do a hard sometimes you've won a hard reset the board Which means you really want to like power it off power don't so I do want to power the VCC I'm going to connect it to one of the GPIOs and it's that will power the the board and then that will They'll be good to go. Okay, so here we are Why is this purple? This is on B. Okay, that's fine so then let me get rid of This ground plane Let me Get rid of All this v-place stuff. Let's go back to commons. Okay, this is fine I'm also going to make sure this is a dimension layer. So I'm gonna change this to be T-place great So next Well, this looks like it kind of lines up a little bit like this and get these these SCL SDA So let me put this like right here One thing. Oh, this is annoying. I don't like when this happens V in connects automatically to be in because they have the Same name hate fat So I'm going to quickly Remove this Okay, so the next question is how to test all of the pins. Well What I'm probably going to do is I'm going to have it like self test Which means that you know, I'm going to program it with firmware and then it will compare Whether pins are connected and the way I do that is I connect alternating pins And then in the code I put one pin high and I check that if the other one's high and then I pull it low and check that it's low and as long as the pins are Alternating I'll catch shorted pins because If if I pull one high and any of the other GPIO pins are pulled high I know that it's shorted together It's amazing the point is I just want to make sure that I'm skipping every other set other than of course the power pins and I want to make sure that they're not since this is the thing that's likely to be shorted I just have to make sure that it doesn't connect between Two shorted pins so thankfully I kind of split it out in a way that it's not there's no All pins are next to each other or next to each other here. So it looks like TXD. I'll connect to seven RxD I'll connect to six. So let's do that So SCL and SDA I'm not going to touch because of course those are kind of the microcontroller and Then I like to rename this You know the a double of the Whatever the name is I kind of put both pins in there So this is three and five and then I'm gonna call this three underscore five and this is 20 and two 22 oh and then unfortunately sometimes this happens I have like two left So I kind of have to I back up and I connect this one to here So now I definitely don't have any that are next to each other Because again, I wouldn't be able to detect if they're shorted if they're next to each other because I'm shorting them here Okay, cool, and then this here anymore I start connecting the Pads together and I'm gonna use nice chunky traces Chunky cool And then this Goes here All right, half done. Not too bad for this one. I'm going to use the bottom. Okay, cool Okay, next up is the UPDI pins. Let's do that I'm gonna change these to be Chunkier Let's make these 12 of sixes so they're nice and easy to solder Okay, cool Good, it's time for research. It's never gonna search. Okay, so I'll wrap this up But that's the start and then I'll do the same on the other side alternate and then I'll connect the VCC to one of the GPIO pains and That way I'll be able to power it on program it and then have it perform a self test And they program it with the final firmware and we're good to go So that's that's me starting a tester. Maybe I'll finish it next time Okay, cool. All right, let's do the great search The great search brought to you by did you key? Thanks, did you key and Bleeding it uses the power of engineering smarts and more to search did you key site to find something you might need We might need yes, someone might need what is this week's? Great search. Okay, so let's go to the Computer all right not surprisingly this week's great search is about a product that is not available But you can't get and how are you gonna find a replacement? So for a lot of boards that we've made you know boards with AVR chips boards with Expressive chips they do not have native USB they have native you are and The you are it is how you program them and you are it is how you debug them and how you can send data to a Computer and such Again, we love native USB But a lot of chips still don't have them lower cost chips particularly don't have USB core attached and so you'll see on a board like this This is the main processor chip the at mega 328 are very favorite And then over here this chip as you can see this is a USB port this chip converts the USB from here to you Are to communicate with the mic controller there so two separate chips We've been using USB to your chips for easily 20 years I mean, I think we started with the FT2 32 bl which we actually put some in the store recently because we found half a real and They are Pretty much an essential part and you can use a microcontroller and program it to become a USB to your converter But we we really just set up refer to use an off-the-shelf one We find that they can handle bar rates much better They often have modem control pans. They can light up LEDs. They they can have you know, a lot more capabilities And I think they're a lot more reliable and rugged. I've sort of I've liked them a little bit more So that said the chip that we've used a lot recently is the CP CP 2104 from Sylab's a lovely USB to your chip inexpensive easy to use doesn't work or a crystal Doesn't require a lot of components a very plug-and-play and works up to like two or three Negabots really fast good, especially if you have ESP 32 chips because those they are very large chips and if you want to program them You want to push that data out as quickly as possible. So Lovely the CP 2104 so I was like, oh, you know, let's buy some more CP 2104s And then I'm like, let's go over here and then like, okay, let's okay They don't stop but maybe we can back order them and it now says not recommended for new design and our ND Yeah, I know and our ND. It's not end of line, but it's kind of the like You know the the best my date is these approaching quickly, right? This is this is they're still available. You can still buy them, but not recommended for new designs You can still maintain all designs, but please don't design this in we can't really stop you But you're going to be sad because this is going to be discontinued shortly Why does this happen? Even for chip as popular as this I think it's actually because they really do want to push people towards maybe a cheaper process Or they there's a little bit of bugs or or improvements that they want to make and they kind of wanted to shift you over again So I can get this but not recommended for new designs. So question is What do we do instead? So let's look at you know, if we're going to you know And of course I contacted it, you know So I was like, oh, do you have a drop-in replacement and they said no we don't we have this other chip It's not a drop-in. It's very similar But I was like, well, you know what might as well look to see if there's any other chips Just in case I'm kind of missing out and see what the market is because there's a couple different companies that make USB to your chips so let's go to interface controllers and Because of course we're doing a new design we want only active stuff not an R&D and We want a particular function the function we want is a Bridge that is USB to you are not that there are like USB to ethernet USB to FIFO USB to I squared C USB to SPI, but we want in particular USB to you are and Let's apply all now, you know, we're doing a design spec And so I don't really care if it's in stock right now What I care about is like can I get it in general? Is it is it normally stocked as available? So there's a couple things so there are some chips that are available right now You know the FT 2321 Sorry 231. This is from FTDI classic maker of USB to serial converters However, you know, I'm kind of interested in pricing and so I'm going to say, you know what 500 quantity It's about how many I buy at a time What's what's my what's a good bet for pricing? I price and On does not Maybe because reels are bigger, so Do 1,000 We are the sort by price is not quite sorting by price That's a new one. Let me get rid of Quangby pricing. This is exciting. Okay. Um, so I Don't know why okay, so the There's Cypress and they make the Cy 7c Series of converters I use them. They're you know about four dollars a piece There's also the like I mentioned the FT 230 also about two dollars a piece The replacement that Cylabs recommends is actually one of the ones that's up here. It's and it's a dollar fifty So if you're if you're going for price and it's it's close enough There is the CP 2102 now one thing to watch for the CP 2102 is this is Unusual never really seen it before but it's a chip that's available in three packages, but they're all with the same name So they're all QFNs But there's a 20 QFN a 24 QFN and a 28 QFN so One thing to watch for is, you know, usually I'm like, oh just use like, you know The first chunk of the name and then and then the package, you know in QFN or tea stop And I'll tell you you actually need to have the full part number because This one is the QFN 20. This one is the QFN 24 and this is the QFN 28 so looking at the 24 Let's show you the thing because I went through this data sheet and we'll find The interesting part so good news is like it can go really fast three megabod, which is nice There are different GPIO functions for each package and There was a cute spreadsheet. Oh, sorry. It's at the very top. Okay so there's the 28 24 and 20 and each one has slightly different Functionalities, they're all lead-free. Yay the 20 is the simplest it doesn't have charger battery detect it doesn't have vio and VDD pins Which means you can't have it like 1.8 power. It's I think whatever, you know VDD IO is 3.3 volts and you can't have to stick with that the 24 adds the vio and VDD pins and the 28 adds Battery charging detection that has more GPIOs the battery charge detection is kind of interesting. I You know, it's kind of I think for If you have something where you want to like Determine if you have enough power availability like it can output to tell you like yes You can you can draw that much power from the charger from the USB port to charge your battery the Qfn-24 is the one that is closest to the CP 2104 in pinout. It is like 95% the same. It is not 100% the same the difference is There's no VPP pin. So usually on the CP 2104 there's a programming pin that you have to put a 10 microfiber capacitor on you don't need to do that and The other part that is most important is there is now this requirement for a V bus Divider, this is that like a detection circuit to tell it when V bus is connected Historically you would wire this up directly to the V bus pin You know, they've changed the design. You now have to use a resistor divider So it's not drop-in compatible It's it's a little sad because you know, I also feel like if it had been like one resistor was needed You know, you could have like used that VPP capacitor and maybe like rerouted that package You know instead of a capacitor would have been a resistor and you can route it But for whatever reason they've they've changed it so that you you definitely need to have this resistor divider so in my Breakouts Sorry USB serial, you know, so I designed another thing to note is there's the CP 2102 and the CP 2102 n Also different you want the n variety So the good news is that you know, it's it's not too bad of a difference It's not too different than Then the CP 2104, you know, I've in this design I've added these two resistors that V bus detect over here and you can see in the previous design. This isn't where the the VPP capacitor was like this is kind of an empty space I deleted that and sort of shoved these wires down to make room for these two resistors So that said, um, you know, it's I wish it was drop-in replacement. It's not but They're gonna have it in stock, you know in a month It's about the same price as the CP 2104 You do have to do a slight re-spin, but All in all, it's not a bad re-spin And so like you'll have to pay for another stencil and the program if you're if you're doing your assembly But I'm pretty confident that functionally you're gonna have the same You know functionality and support that you had in the CP 2104 whereas Jumping to a different USB serial converter. I'll say each one of them has its own little quirks The side labs ones are a little different quirks than the FTDI ones which have different quirks in the side press So I'm probably just going to move to this You know version and I do like the QFN package I know there's other USB serial converters that come in like T-SOP, but this is so nice and compact and it's so reliable I really like that you can go at high bot rates and it's consistent I like the LED drivers and and it doesn't do weird things when you plug it in sometimes other chip You know like pins start tobbling Kind of funky when you plug it in but this one is very reliable. So I I like it. So I'm going to Have to re-spin about 10 different boards from the CP 21 to CP 2102 It's what it is. We're living in this land But when they come in back into Stockholm would order some samples and get those boards designed. So that's a great search Hopefully helpful for others lacking the CP 2104s in this silicon shortage life we have Where in the world is that part A? Alright, that's the desk of Lady A to this week. We got a bounce. Okay, everybody. All right We'll see everybody joined a week shows Tuesdays Wednesdays Thursdays and Fridays. That's right this week tune in keep it high on socials and more and Thanks for joining us. It's not everybody. That is your desk of Lady A to thanks everybody