1 00:00:26,080 --> 00:00:28,740 Thank you for watching. 2 00:00:44,580 --> 00:00:59,980 Thank you for watching. 3 00:01:12,340 --> 00:01:29,380 Thank you for watching. 4 00:01:49,540 --> 00:01:51,760 I'm proud to see as many people as I do here. 5 00:01:51,860 --> 00:01:56,160 You are obviously the hardcore who are both awake and have not left after checkout time, 6 00:01:56,240 --> 00:01:56,960 so thank you for coming. 7 00:02:00,020 --> 00:02:04,580 So, basically, my talk today is on 8-bit microcontrollers. 8 00:02:04,860 --> 00:02:07,180 I'll be going over a bunch of different aspects of them. 9 00:02:07,320 --> 00:02:08,640 It's kind of a shotgun presentation. 10 00:02:09,440 --> 00:02:14,360 I am Phil King, and the reason I might have something useful to say about this 11 00:02:14,360 --> 00:02:18,780 is because I'm a hardware engineer who's been designing with these things on and off for over a decade now. 12 00:02:19,280 --> 00:02:23,400 I am also an enthusiast who's building all sorts of weird things at any given time, 13 00:02:23,500 --> 00:02:29,580 and I actually have taught a course on this stuff, so I picked up some idea of what to present. 14 00:02:30,480 --> 00:02:33,060 The forum here is really different than I'm used to, 15 00:02:33,180 --> 00:02:36,960 so there will be glitches, and I ask you to indulge me. 16 00:02:37,700 --> 00:02:40,220 If there's anything you need to know, please raise your hand. 17 00:02:40,420 --> 00:02:43,380 I will be taking questions throughout, but I also have a Q&A period at the end, 18 00:02:43,900 --> 00:02:47,280 and the reason you should be interested in what I have to say 19 00:02:47,280 --> 00:02:50,680 is because we've got some really neat stuff you can do with 8-bit systems, 20 00:02:50,760 --> 00:02:53,580 8-bit microcontrollers, and, of course, free stuff. 21 00:02:54,080 --> 00:02:55,180 Since that's always... 22 00:02:55,180 --> 00:02:55,560 Yeah? 23 00:02:55,960 --> 00:02:56,360 Yeah. 24 00:02:57,780 --> 00:02:58,480 I'll be getting... 25 00:02:58,480 --> 00:02:59,220 He asks, 26 00:03:00,300 --> 00:03:03,740 They aren't yet, they will be, and the URL is at the end of the presentation. 27 00:03:04,680 --> 00:03:06,040 So they will be available. 28 00:03:06,220 --> 00:03:07,500 You don't need to write all this crap down. 29 00:03:09,620 --> 00:03:13,340 With regard to getting free stuff, since that's what you're all wondering about since I mentioned that last, 30 00:03:13,560 --> 00:03:18,400 the free stuff specifically is an Atmel STK100 starter kit. 31 00:03:19,800 --> 00:03:21,040 They are these things. 32 00:03:21,160 --> 00:03:23,620 This is the hardware that I have developed this presentation around. 33 00:03:24,100 --> 00:03:25,700 They're a really slick little kit. 34 00:03:25,820 --> 00:03:28,880 I don't even know off the top of my head what the price of these things is. 35 00:03:28,960 --> 00:03:29,260 Retail? 36 00:03:29,260 --> 00:03:30,120 I think they're about $150. 37 00:03:30,760 --> 00:03:33,900 But I've got some of them to give away, and there's two different ways to get one. 38 00:03:34,020 --> 00:03:37,360 You can either suggest a project idea during the Q&A period, 39 00:03:37,540 --> 00:03:39,120 in which case we will... 40 00:03:39,120 --> 00:03:42,560 Be prepared to elaborate, and I'd like to discuss ideas, 41 00:03:43,340 --> 00:03:47,800 and I may or may not invoke the audience to give you the thumbs up or thumbs down 42 00:03:47,800 --> 00:03:50,380 on whether your idea merits a starter kit. 43 00:03:50,780 --> 00:03:56,140 And then the other way is to get a starter kit by submitting a feedback form with a project idea. 44 00:03:56,240 --> 00:03:59,000 And this is if you're not willing to hold your project up to public humiliation, 45 00:04:00,240 --> 00:04:03,140 feel free to write down the feedback information at the end. 46 00:04:03,200 --> 00:04:08,300 This is basically the way I bribe my audience to give me recommendations on how to make these talks better. 47 00:04:08,680 --> 00:04:11,100 I've been doing variations on this for a while now, 48 00:04:11,200 --> 00:04:12,760 and hopefully it's evolving and getting better. 49 00:04:12,860 --> 00:04:14,460 But if it sucks, I need to know that. 50 00:04:18,640 --> 00:04:20,120 So, specifically, what am I going to hit on? 51 00:04:20,260 --> 00:04:21,820 I'm going to hit on what are microcontrollers? 52 00:04:22,180 --> 00:04:24,420 Presumably, if you're here, you have a pretty good idea what that is, 53 00:04:24,480 --> 00:04:25,900 so I'm not going to dwell on that real long. 54 00:04:26,680 --> 00:04:28,360 Why am I focusing on the tiny ones? 55 00:04:29,260 --> 00:04:31,420 The talk title is Eight Pins and Eight Bits, 56 00:04:31,480 --> 00:04:34,920 and I'll get into what exactly that means in terms of the starter kit shortly. 57 00:04:35,580 --> 00:04:36,480 What can they do? 58 00:04:36,560 --> 00:04:39,060 What exact functionality do you have in these things? 59 00:04:39,380 --> 00:04:40,280 What are the development tools? 60 00:04:40,440 --> 00:04:43,500 Both what am I using and what if you want to be using something else? 61 00:04:43,960 --> 00:04:45,760 And then I'll do a bunch of application examples. 62 00:04:46,440 --> 00:04:50,300 I don't have specific demonstrations of most of the application examples 63 00:04:50,300 --> 00:04:54,660 because a lot of them are derived from other people's projects, application notes, things like that. 64 00:04:54,740 --> 00:04:57,480 And instead, I look at them in terms of putting them on this hardware 65 00:04:57,480 --> 00:04:59,080 and what you would want to do. 66 00:04:59,260 --> 00:05:00,480 What would you want to do to adapt them to your needs? 67 00:05:01,180 --> 00:05:03,480 And then finally, the Q&A period at the end. 68 00:05:05,180 --> 00:05:06,280 Always got to have one of those. 69 00:05:09,040 --> 00:05:11,060 Okay, so what exactly is a microcontroller? 70 00:05:11,540 --> 00:05:16,480 Some of you are actually old enough to have started out working like I did on 8-bit computers 71 00:05:16,480 --> 00:05:18,860 before Intel ruled the world. 72 00:05:22,520 --> 00:05:23,680 Was that a 4? 73 00:05:24,200 --> 00:05:25,020 A 4-bit. 74 00:05:25,520 --> 00:05:25,960 Impressive. 75 00:05:26,400 --> 00:05:29,240 But there was a time when 8-bits was what you needed. 76 00:05:29,260 --> 00:05:33,720 And that's what you got, at least in anything that had a single-piece processor. 77 00:05:34,700 --> 00:05:39,900 Now, most 8-bit processors, which, by the way, still represent the largest market share 78 00:05:39,900 --> 00:05:45,020 in terms of number of CPU core shipping, are found almost entirely in microcontrollers, 79 00:05:45,060 --> 00:05:49,860 which is an 8-bit CPU core together with a bunch of resources stuck around it. 80 00:05:49,960 --> 00:05:52,860 And the common canonical examples are memory. 81 00:05:53,000 --> 00:05:58,440 For example, some ROM or Flash or EEPROM ports, which are programmable I.O., 82 00:05:58,440 --> 00:06:02,420 where they've generally taken all of the internal bussing to the processor, 83 00:06:02,500 --> 00:06:05,180 kept it in the chip, and then they give you some ports out to pins 84 00:06:05,180 --> 00:06:09,400 so you can twiddle individual electrical connections as I.O. ports 85 00:06:09,400 --> 00:06:12,360 rather than dealing with them as memory-mapped I.O. 86 00:06:12,480 --> 00:06:16,740 And then a variety of peripherals, depending on what you're using. 87 00:06:16,920 --> 00:06:19,160 I mentioned timer, interrupt controller. 88 00:06:19,740 --> 00:06:21,260 These are sort of the basic ones. 89 00:06:21,680 --> 00:06:23,180 Larger microcontrollers will have more. 90 00:06:23,300 --> 00:06:24,980 I'm dealing with really, really small ones. 91 00:06:25,260 --> 00:06:27,820 And then generally, a microcontroller is a self-contained architecture, 92 00:06:28,440 --> 00:06:29,680 requiring only a few other components, 93 00:06:30,080 --> 00:06:33,700 or in the case of some of these parts, literally no other components to build a system. 94 00:06:35,460 --> 00:06:39,000 So why am I so obsessed with the tiny ones, little 8-pin, 8-bit jobbies? 95 00:06:39,620 --> 00:06:40,860 First of all, because we can. 96 00:06:41,640 --> 00:06:46,120 It's really cool to see what you can do with a part that has only 8 wires coming out of it. 97 00:06:46,860 --> 00:06:48,840 Also, learning to make use of minimal resources. 98 00:06:49,280 --> 00:06:53,040 There are some folks in the demo crowd who know that 1K is a lot of program space, 99 00:06:54,040 --> 00:06:57,560 but there are a lot of people who have gotten away from the roots, 100 00:06:58,440 --> 00:07:01,820 so it's fun to see what you can do in a very small, very small package, 101 00:07:01,940 --> 00:07:04,720 both in terms of physically and in terms of code space. 102 00:07:05,160 --> 00:07:06,300 And then minimal wiring. 103 00:07:06,480 --> 00:07:08,640 And I put that up kind of as a joke, but when you've only got 8 pins, 104 00:07:08,760 --> 00:07:10,760 there's just not that much wire you're going to need. 105 00:07:11,380 --> 00:07:14,120 And if you hate soldering things together, or you hate wire wrapping, 106 00:07:14,240 --> 00:07:16,480 this is a good way to keep the wire count down. 107 00:07:18,300 --> 00:07:20,780 So what are some of these interesting minimal systems? 108 00:07:21,580 --> 00:07:25,140 And one category I sort of synthetically lumped a lot of them into is implants, 109 00:07:25,420 --> 00:07:28,260 which are things you want it to be small enough that you can put it places, 110 00:07:28,260 --> 00:07:32,640 people won't notice it, that it's unobtrusive, or that it fits inside some existing system. 111 00:07:32,880 --> 00:07:34,620 So, bugs or portable stuff. 112 00:07:36,660 --> 00:07:41,260 Another, essentially, arguably an implant also, but a separate category is mod chips. 113 00:07:41,500 --> 00:07:45,900 And I will sort of glance over that, but I know that's of interest to at least some of this crowd. 114 00:07:47,140 --> 00:07:48,740 And then telemetry devices. 115 00:07:48,940 --> 00:07:52,160 One of the things that came out in the project discussions last year is a lot of people said, 116 00:07:52,220 --> 00:07:54,020 I want to build a telemetry widget for blah. 117 00:07:54,600 --> 00:07:57,420 And so that's a really good application 118 00:07:57,420 --> 00:08:00,460 for a really small controller where you want to collect a few bits of data 119 00:08:00,460 --> 00:08:03,380 and either log it or send it off over over a link somehow. 120 00:08:05,220 --> 00:08:07,820 And so what are the 8-pin microcontrollers? 121 00:08:07,840 --> 00:08:11,880 If you look at the whole family, the ones that I have been able to track down, 122 00:08:12,020 --> 00:08:16,580 there may be others I have overlooked, if so, I apologize, and feel free to add them to the heap, 123 00:08:16,700 --> 00:08:22,700 but the common ones available now are the Atmel AT-Tiny series and a couple of the other AT series, 124 00:08:24,080 --> 00:08:26,340 and then the Microchip PIC-12C, 125 00:08:26,420 --> 00:08:27,400 and I believe they've just come out, 126 00:08:27,400 --> 00:08:29,840 with an 8-pin version of either the 14 or the 16C. 127 00:08:30,900 --> 00:08:33,220 There are also, that's why I said there's a few other PICs. 128 00:08:33,500 --> 00:08:36,260 I'm going to be focusing on the Atmel AVRs. 129 00:08:36,820 --> 00:08:40,380 Like so many things in this world, your choice of processor, 130 00:08:40,580 --> 00:08:43,200 your choice of microcontroller rapidly becomes a religious topic. 131 00:08:44,520 --> 00:08:46,820 I like the AVR because it's got some neat features 132 00:08:46,820 --> 00:08:48,860 and because I can get free development hardware for them. 133 00:08:50,920 --> 00:08:53,480 Yeah, the PIC is also a good part. 134 00:08:53,560 --> 00:08:55,660 A lot of people have a lot of experience with the PIC, 135 00:08:55,680 --> 00:08:57,280 but I'm just going to be running off. 136 00:08:57,280 --> 00:08:57,920 I'm going to be running off on the AVR 137 00:08:58,370 --> 00:09:00,560 and showing you what you can do with this board. 138 00:09:01,760 --> 00:09:03,960 So the common features to the AVR architecture, 139 00:09:04,300 --> 00:09:05,800 whether they're the 8-pin or not, 140 00:09:05,940 --> 00:09:07,440 are that it's a RISC instruction set. 141 00:09:08,220 --> 00:09:10,540 The closest you may have run into 142 00:09:10,540 --> 00:09:13,700 if you haven't done microcontroller development is MIPS, 143 00:09:13,940 --> 00:09:15,800 the MIPS RISC instruction set. 144 00:09:16,920 --> 00:09:18,000 It's a Harvard architecture, 145 00:09:18,180 --> 00:09:20,880 meaning that you have separate code and data space. 146 00:09:21,900 --> 00:09:23,760 There's 32 general purpose registers, 147 00:09:23,940 --> 00:09:27,140 although as with most 32 general purpose registers, 148 00:09:27,260 --> 00:09:29,280 they're not all quite general. 149 00:09:30,040 --> 00:09:31,640 And then there's a status register, 150 00:09:31,900 --> 00:09:33,100 and then there's a set of I.O. registers 151 00:09:33,100 --> 00:09:34,500 that vary from part to part. 152 00:09:34,700 --> 00:09:36,980 But every one of them has a block of I.O. space. 153 00:09:38,920 --> 00:09:41,120 Some of the features of the RISC instruction set 154 00:09:41,660 --> 00:09:43,160 that make it really good, 155 00:09:43,260 --> 00:09:45,160 even for a small application like this, 156 00:09:45,360 --> 00:09:47,400 is simple fixed length instructions. 157 00:09:48,060 --> 00:09:49,960 In the AVR instruction set, 158 00:09:50,020 --> 00:09:51,840 virtually everything is a 16-bit word, 159 00:09:52,800 --> 00:09:55,100 which means that when you get the pipeline, 160 00:09:55,360 --> 00:09:56,720 the execution pipeline full, 161 00:09:57,260 --> 00:10:00,660 they're able to click along at one cycle per instruction. 162 00:10:01,220 --> 00:10:03,540 If you've done any development with, say, an 8051, 163 00:10:03,760 --> 00:10:04,900 depending on the implementation, 164 00:10:05,160 --> 00:10:07,480 the 8051 will run up to 12 cycles per instruction, 165 00:10:08,400 --> 00:10:10,100 which really starts to bog it down. 166 00:10:10,220 --> 00:10:14,980 It's nice that you can run an AVR at one megahertz 167 00:10:14,980 --> 00:10:18,340 and get, in the best possible case, one MIPS out of it. 168 00:10:19,380 --> 00:10:20,960 And then it's a load store architecture, 169 00:10:21,180 --> 00:10:22,580 meaning that anything you want to manipulate, 170 00:10:22,700 --> 00:10:24,300 you drag into a register, you twiddle it, 171 00:10:24,380 --> 00:10:25,180 you shove it back out. 172 00:10:25,220 --> 00:10:26,880 There are no direct operations on memory. 173 00:10:28,660 --> 00:10:30,620 Some of the general purpose register oddities, 174 00:10:30,700 --> 00:10:32,740 I mentioned that they're not all quite equal. 175 00:10:33,620 --> 00:10:37,420 If you do a load from data in program space, 176 00:10:37,640 --> 00:10:38,980 and that may sound a little odd, 177 00:10:39,040 --> 00:10:41,000 but there is a special instruction called LPM 178 00:10:41,000 --> 00:10:42,900 for loading constants that you've stored 179 00:10:42,900 --> 00:10:44,520 in your flash code space. 180 00:10:45,200 --> 00:10:47,340 They get explicitly loaded to R0. 181 00:10:47,480 --> 00:10:48,440 That's hardwired into it. 182 00:10:48,780 --> 00:10:50,200 If you do a load immediate, 183 00:10:50,720 --> 00:10:52,460 because of the way the instruction is set up, 184 00:10:52,480 --> 00:10:53,780 if you think about it, you've got 16 bits 185 00:10:53,780 --> 00:10:55,120 for this instruction word. 186 00:10:55,120 --> 00:10:56,540 If you're doing a load immediate, 187 00:10:56,740 --> 00:10:58,380 eight of them are taken up with the immediate value, 188 00:10:59,500 --> 00:11:01,320 and some of them have to be for the op. 189 00:11:01,440 --> 00:11:02,980 They wanted four of them for the op, 190 00:11:03,040 --> 00:11:04,720 which means they've only got four bits left over 191 00:11:04,720 --> 00:11:06,400 for the register description, 192 00:11:06,700 --> 00:11:08,740 which means that you can actually only address 193 00:11:08,740 --> 00:11:10,500 16 registers for immediate instruction, 194 00:11:10,660 --> 00:11:12,940 so they arbitrarily chose the upper half of the register set. 195 00:11:13,020 --> 00:11:15,720 So you get R16 to R31 if you want to do a load immediate. 196 00:11:16,060 --> 00:11:18,300 You cannot load immediate into R0 to R15. 197 00:11:19,240 --> 00:11:20,460 And then there are several, 198 00:11:21,520 --> 00:11:23,720 two register indices that are set up. 199 00:11:23,720 --> 00:11:26,600 In the case of the small parts, 200 00:11:26,720 --> 00:11:28,920 the only one that they implement is the Z index, 201 00:11:29,180 --> 00:11:32,060 which is the concatenation of R30 and R31. 202 00:11:33,820 --> 00:11:36,620 And to give you an idea of how this stuff all maps together, 203 00:11:37,160 --> 00:11:40,900 there is data space which has the register file 204 00:11:40,900 --> 00:11:42,720 also at the top of data space, 205 00:11:42,860 --> 00:11:45,060 which means you can access registers 206 00:11:45,560 --> 00:11:47,100 by doing memory access, 207 00:11:47,400 --> 00:11:49,960 and you can treat the registers as a block of SRAM, 208 00:11:50,040 --> 00:11:51,420 which is useful because some of the parts 209 00:11:51,420 --> 00:11:53,500 have no other SRAM, and in fact, 210 00:11:53,720 --> 00:11:56,180 they've only got 32 bytes of SRAM in the register file. 211 00:11:58,280 --> 00:12:00,620 They also map the I.O. registers, 212 00:12:01,160 --> 00:12:03,640 which have their own sort of pseudo I.O. space 213 00:12:03,640 --> 00:12:05,560 immediately after the register file. 214 00:12:05,800 --> 00:12:07,260 So on all of the AVR parts, 215 00:12:07,560 --> 00:12:12,340 the data address space is known to be 216 00:12:12,340 --> 00:12:15,720 the first 0 to 1F is going to be your register file, 217 00:12:15,960 --> 00:12:18,420 and 20 to 5F is going to be your I.O. space. 218 00:12:19,380 --> 00:12:21,320 SRAM, if there is any, begins after that. 219 00:12:21,620 --> 00:12:22,680 External SRAM, 220 00:12:22,680 --> 00:12:23,900 if the chip supports any, 221 00:12:24,000 --> 00:12:24,680 and none of these do, 222 00:12:24,820 --> 00:12:25,820 some of the larger ones do, 223 00:12:25,920 --> 00:12:26,760 happens after that. 224 00:12:29,420 --> 00:12:32,960 So the specific features of the AT-Tiny11, 225 00:12:33,160 --> 00:12:34,180 the part that we're looking at, 226 00:12:34,420 --> 00:12:37,160 are it's an 8-pin DIP or SOIC package. 227 00:12:38,180 --> 00:12:40,600 I have some pictures later on. 228 00:12:40,680 --> 00:12:43,040 I don't know if everyone here is familiar with an 8-pin DIP. 229 00:12:43,100 --> 00:12:45,120 It's a really standard package. 230 00:12:45,360 --> 00:12:46,580 It's relatively small. 231 00:12:46,900 --> 00:12:48,020 If you want it smaller, 232 00:12:48,040 --> 00:12:49,460 you can go to the surface mount SOIC. 233 00:12:50,560 --> 00:12:52,340 There are six I.O. lines available. 234 00:12:52,680 --> 00:12:54,740 Or actually, I should say five I.O. and one input, 235 00:12:54,820 --> 00:12:55,860 if you disable the reset. 236 00:12:56,020 --> 00:12:56,600 If you think about it, 237 00:12:56,640 --> 00:12:59,400 that means you've got six I.O. and power and ground. 238 00:12:59,760 --> 00:13:02,020 So it's making good use of its pins. 239 00:13:02,400 --> 00:13:03,840 And then in this particular part, 240 00:13:03,920 --> 00:13:06,020 you've got 1K byte of code flash, 241 00:13:06,180 --> 00:13:07,700 because it's a 16-bit instruction word 242 00:13:07,700 --> 00:13:09,400 that's 512 instruction words. 243 00:13:10,000 --> 00:13:11,220 And some of you are thinking, 244 00:13:11,300 --> 00:13:12,840 what can you possibly do with 512 words? 245 00:13:12,940 --> 00:13:14,040 Some of you are probably thinking, 246 00:13:14,160 --> 00:13:14,300 why? 247 00:13:14,480 --> 00:13:15,720 Well, that's a ton of space. 248 00:13:16,620 --> 00:13:18,040 The truth lies somewhere in the middle, 249 00:13:18,100 --> 00:13:21,480 and I'll touch on some of the cool things you can do 250 00:13:21,480 --> 00:13:22,600 in a relatively small space. 251 00:13:22,600 --> 00:13:24,220 When I'm talking about the applications. 252 00:13:27,940 --> 00:13:28,880 More features. 253 00:13:29,440 --> 00:13:31,660 There's a variety of speed grades available 254 00:13:31,660 --> 00:13:33,720 for the ATtiny11. 255 00:13:33,940 --> 00:13:37,100 And you can sort of map into a space 256 00:13:37,100 --> 00:13:40,180 of what power and speed performance you want. 257 00:13:40,460 --> 00:13:42,400 You can run them up to six megahertz. 258 00:13:42,600 --> 00:13:44,700 The ATtiny11 specifically comes in speed grades 259 00:13:44,700 --> 00:13:46,340 up to six megahertz at five volts. 260 00:13:46,520 --> 00:13:49,820 And then in lower voltage versions that run, 261 00:13:49,960 --> 00:13:51,980 for example, down to 2.7 volts 262 00:13:51,980 --> 00:13:52,780 at two megahertz. 263 00:13:53,180 --> 00:13:54,820 Another nice thing about this is 264 00:13:54,820 --> 00:13:57,300 it's a fully static CMOS implementation, 265 00:13:57,560 --> 00:13:58,940 meaning that you can actually run the clock 266 00:13:58,940 --> 00:13:59,800 all the way down to zero. 267 00:14:00,220 --> 00:14:02,260 It's got a couple of standby power modes 268 00:14:02,260 --> 00:14:04,040 that will turn itself off, 269 00:14:04,180 --> 00:14:06,400 and it can also be set to wake on interrupt, 270 00:14:06,660 --> 00:14:10,480 which means if you know the next behavior 271 00:14:10,480 --> 00:14:11,900 the system wants to respond to 272 00:14:11,900 --> 00:14:12,880 is something outside of itself, 273 00:14:13,040 --> 00:14:14,440 it can actually just put itself to sleep, 274 00:14:14,480 --> 00:14:16,100 and it will wake up on an external interrupt. 275 00:14:16,420 --> 00:14:17,840 And you can drop the power consumption 276 00:14:17,840 --> 00:14:19,080 down to a few microamps. 277 00:14:19,600 --> 00:14:21,860 And then even when it's running, 278 00:14:22,600 --> 00:14:23,920 running relatively fast, 279 00:14:24,100 --> 00:14:25,080 it's fairly low power. 280 00:14:25,620 --> 00:14:28,160 And then I quote the data sheet 281 00:14:28,160 --> 00:14:29,600 at less than five milliamps 282 00:14:29,600 --> 00:14:31,360 at one megahertz at five volts. 283 00:14:31,640 --> 00:14:33,300 If you bring the voltage down, 284 00:14:33,400 --> 00:14:36,380 you can bring the power down within reason. 285 00:14:36,960 --> 00:14:38,960 There's some other implications 286 00:14:40,160 --> 00:14:42,220 to running the voltage at different levels, 287 00:14:42,300 --> 00:14:44,320 and I'll touch on those briefly later. 288 00:14:46,680 --> 00:14:49,160 It also has a whole bunch of different clocking options, 289 00:14:49,260 --> 00:14:50,700 and this is kind of cool as well, 290 00:14:50,700 --> 00:14:52,060 because when you're building a minimal system, 291 00:14:52,240 --> 00:14:54,320 you don't want to have to hang an oscillator off this thing. 292 00:14:54,380 --> 00:14:54,660 You can. 293 00:14:54,960 --> 00:14:56,320 You can externally clock it. 294 00:14:56,340 --> 00:14:57,480 You can stick an external crystal, 295 00:14:57,580 --> 00:15:00,060 and it actually has an oscillator amplifier circuit 296 00:15:00,060 --> 00:15:00,860 built into it. 297 00:15:01,160 --> 00:15:03,180 In that case, you burn two of your eight pins 298 00:15:03,180 --> 00:15:04,640 just sticking a crystal on it. 299 00:15:04,700 --> 00:15:06,300 If you only need four, that's fine. 300 00:15:07,960 --> 00:15:10,640 If you want to hook an external oscillator up to it, 301 00:15:10,720 --> 00:15:12,040 you can do it with only one pin. 302 00:15:12,160 --> 00:15:13,960 In that case, it's just the input, the clock input. 303 00:15:14,620 --> 00:15:16,020 You can also do it with zero pins 304 00:15:16,020 --> 00:15:17,520 with the onboard RC oscillator. 305 00:15:18,480 --> 00:15:20,280 The upside is it takes zero pins, 306 00:15:20,700 --> 00:15:22,340 and it runs at one megahertz at five volts, 307 00:15:22,520 --> 00:15:26,040 although it runs at 350 kilohertz at three volts. 308 00:15:26,160 --> 00:15:28,980 It runs at 110 kilohertz at two volts. 309 00:15:29,260 --> 00:15:33,620 It runs at 1.1 megahertz at zero degrees Celsius. 310 00:15:33,740 --> 00:15:37,760 It runs at 900 kilohertz at 70 degrees Celsius. 311 00:15:38,180 --> 00:15:39,640 In other words, it's not regulated. 312 00:15:39,640 --> 00:15:40,940 It's going to drift all over the place. 313 00:15:41,120 --> 00:15:42,200 If you've got an application 314 00:15:42,200 --> 00:15:44,180 where you're only interacting with people, this is okay. 315 00:15:44,300 --> 00:15:45,560 If you've got an application 316 00:15:45,560 --> 00:15:48,220 where you're doing asynchronous serial communication, 317 00:15:48,600 --> 00:15:50,180 you may want a more stable clock. 318 00:15:50,700 --> 00:15:53,040 The AT12 part, for example, 319 00:15:53,040 --> 00:15:55,480 has a calibrated oscillator onboard, 320 00:15:55,760 --> 00:15:57,260 and they actually test it at the factory 321 00:15:57,260 --> 00:16:00,800 and guarantee the constraint of that one megahertz RC oscillator. 322 00:16:01,220 --> 00:16:03,480 On the AT1011, it's going to drift all over the place. 323 00:16:05,960 --> 00:16:08,680 The specific microcontroller resources 324 00:16:08,680 --> 00:16:10,160 they've stuck on this particular part 325 00:16:10,620 --> 00:16:12,420 are a hardware watchdog timer. 326 00:16:13,420 --> 00:16:15,460 In this case, they actually run the watchdog timer 327 00:16:15,460 --> 00:16:19,340 off the same oscillator as the self-clocking RC circuit. 328 00:16:19,340 --> 00:16:20,860 So the watchdog runs at 1 megahertz, 329 00:16:20,940 --> 00:16:21,900 and you can divide that down 330 00:16:22,360 --> 00:16:24,400 by any of a whole bunch of pre-scale values, 331 00:16:25,200 --> 00:16:26,680 or you can disable it. 332 00:16:26,860 --> 00:16:31,060 If it's on and your system has turned on the watchdog 333 00:16:31,060 --> 00:16:33,140 and fails to kick it before it times out, 334 00:16:33,340 --> 00:16:35,100 the watchdog will trigger a reset. 335 00:16:36,000 --> 00:16:38,340 This is useful if you're building a system 336 00:16:38,340 --> 00:16:39,660 that you're afraid might go brain damage. 337 00:16:39,860 --> 00:16:41,620 It's also useful if you're building a system 338 00:16:42,140 --> 00:16:44,360 where you want to be able to time out on confusion, 339 00:16:44,560 --> 00:16:45,700 and I'll touch on that later. 340 00:16:46,240 --> 00:16:48,900 There's actually some good software system reasons 341 00:16:48,900 --> 00:16:49,820 you might want a watchdog timer. 342 00:16:50,000 --> 00:16:51,580 It's got an 8-bit counter timer. 343 00:16:52,040 --> 00:16:56,660 It's a counter when you trigger it based on an input pin. 344 00:16:57,240 --> 00:16:59,840 It's a timer when you hook it up to the clock, 345 00:17:00,360 --> 00:17:02,860 and you can use this for doing all sorts of real-time 346 00:17:02,860 --> 00:17:04,300 or quasi-real-time applications. 347 00:17:05,000 --> 00:17:06,760 There is an analog comparator, 348 00:17:06,840 --> 00:17:10,820 which allows you to get a single-bit comparison 349 00:17:10,820 --> 00:17:14,060 of two analog inputs on two of your I.O. pins. 350 00:17:14,440 --> 00:17:16,040 It can also generate an interrupt, 351 00:17:16,200 --> 00:17:17,720 so if you want to be monitoring 352 00:17:18,900 --> 00:17:21,300 the analog level and cause the system to wake up, 353 00:17:21,360 --> 00:17:24,020 you can actually trigger on analog comparator fire. 354 00:17:25,120 --> 00:17:26,380 And then the interrupt controller, 355 00:17:26,580 --> 00:17:28,100 which hooks some of these together. 356 00:17:28,420 --> 00:17:29,860 You have an external interrupt pin. 357 00:17:30,120 --> 00:17:32,980 You've got an interrupt on any pin change. 358 00:17:33,280 --> 00:17:34,840 You can actually cause the system to interrupt 359 00:17:34,840 --> 00:17:38,640 when any of the external pins change value, 360 00:17:39,120 --> 00:17:41,420 so they can effectively all be used as interrupt. 361 00:17:41,660 --> 00:17:42,600 Obviously, you've got to be careful, 362 00:17:42,700 --> 00:17:43,920 because you could interrupt a lot 363 00:17:43,920 --> 00:17:46,960 if you've got that hooked up to a high-speed signal. 364 00:17:47,960 --> 00:17:49,280 You've got timer counter overflow, 365 00:17:49,600 --> 00:17:50,800 and then you've got the analog comparator. 366 00:17:51,980 --> 00:17:53,420 What does it not have? 367 00:17:53,920 --> 00:17:56,260 This is where the rubber meets the road 368 00:17:56,260 --> 00:17:58,280 on some of the eight-pin stuff. 369 00:17:58,600 --> 00:18:01,140 It has no SRAM beyond the general-purpose registers. 370 00:18:01,260 --> 00:18:04,200 That means if you need more than 32 bytes to do anything, 371 00:18:04,980 --> 00:18:06,300 this is not the part for you. 372 00:18:06,580 --> 00:18:09,780 It does not support any sort of external SRAM. 373 00:18:09,840 --> 00:18:11,200 Obviously, with eight pins, 374 00:18:11,280 --> 00:18:12,840 you're not going to have a real big address data bus. 375 00:18:13,840 --> 00:18:16,080 It also means that because there's no external SRAM, 376 00:18:16,080 --> 00:18:17,880 the stack is three deep, 377 00:18:18,020 --> 00:18:19,360 meaning it's real easy to blow it, 378 00:18:19,460 --> 00:18:20,960 and it's implemented in hardware. 379 00:18:21,240 --> 00:18:23,340 It's nine bits wide of custom hardware. 380 00:18:23,480 --> 00:18:25,620 You cannot explicitly push or pop anything into the stack. 381 00:18:25,720 --> 00:18:28,980 Only when you do calls will it stick the PC, 382 00:18:29,120 --> 00:18:30,360 the program counter, into the stack. 383 00:18:31,360 --> 00:18:33,400 Otherwise, the stack is effectively not there. 384 00:18:33,800 --> 00:18:35,360 Also, if you do blow the stack, 385 00:18:35,480 --> 00:18:37,200 it has the interesting behavior of wrapping around. 386 00:18:39,160 --> 00:18:43,180 If you do a call, call, call, call, 387 00:18:43,680 --> 00:18:45,820 you will have lost the first call return address, 388 00:18:46,080 --> 00:18:47,500 and the fourth will now sit over the first. 389 00:18:49,160 --> 00:18:50,800 It also has no hardware UART. 390 00:18:50,840 --> 00:18:52,340 One of the things I talk about a little bit later 391 00:18:52,340 --> 00:18:54,340 is implementing a software UART, 392 00:18:54,420 --> 00:18:55,560 which is really quite doable. 393 00:18:55,720 --> 00:18:57,100 It has no EEPROM storage. 394 00:18:57,280 --> 00:18:59,080 That may seem a little non-sequitur, 395 00:18:59,120 --> 00:19:01,120 but many of the parts do have a small chunk, 396 00:19:01,200 --> 00:19:03,340 a third memory space that is EEPROM space 397 00:19:03,340 --> 00:19:05,520 for storing lookup tables, constants. 398 00:19:05,980 --> 00:19:07,300 This is a non-volatile space, 399 00:19:07,440 --> 00:19:08,520 normally, that the part can write to. 400 00:19:08,580 --> 00:19:09,680 In this case, it just isn't there. 401 00:19:09,980 --> 00:19:11,480 And then there's no ATD converter. 402 00:19:12,420 --> 00:19:15,840 You can add a serial ATD converter if you want, 403 00:19:15,840 --> 00:19:17,860 or if you really need that, use a part that has it, 404 00:19:17,900 --> 00:19:19,300 but this particular part doesn't. 405 00:19:20,720 --> 00:19:22,220 What development tools am I using? 406 00:19:22,980 --> 00:19:26,280 The assembler of choice I use is Atmel AVR Studio, 407 00:19:26,560 --> 00:19:28,560 which is an integrated development environment 408 00:19:28,560 --> 00:19:30,480 with an editor and an assembler. 409 00:19:30,700 --> 00:19:31,800 It also includes a simulator, 410 00:19:32,040 --> 00:19:33,780 so you can actually simulate your code, 411 00:19:34,520 --> 00:19:35,800 obviously, within the constraints 412 00:19:35,800 --> 00:19:37,300 of not having the hardware in the system. 413 00:19:38,640 --> 00:19:41,900 If you're using the AVR Studio with this particular board, 414 00:19:42,000 --> 00:19:43,540 you have to use a separate ISP package 415 00:19:43,540 --> 00:19:44,780 in system programming, 416 00:19:44,780 --> 00:19:46,300 and that allows you to program 417 00:19:46,300 --> 00:19:48,220 through the parallel or serial port, 418 00:19:48,420 --> 00:19:50,800 and then the development hardware, 419 00:19:50,880 --> 00:19:51,920 as I talked about a little bit earlier, 420 00:19:52,060 --> 00:19:53,340 is the STK100. 421 00:19:53,580 --> 00:19:54,700 I don't know why I'm holding it up. 422 00:19:54,720 --> 00:19:56,000 No one can see it when, in fact, 423 00:19:56,020 --> 00:19:59,260 I have a slide of it in just a second. 424 00:19:59,300 --> 00:19:59,580 There we go. 425 00:20:00,040 --> 00:20:02,000 There is what the board looks like. 426 00:20:03,540 --> 00:20:04,580 You see the parallel port 427 00:20:04,580 --> 00:20:06,200 and serial port connections on the left side. 428 00:20:06,320 --> 00:20:07,720 You've got a prototyping area on the right. 429 00:20:08,840 --> 00:20:12,220 The stack of sockets about mid-board 430 00:20:12,220 --> 00:20:13,680 is where you plug in the various parts. 431 00:20:13,840 --> 00:20:14,520 You can see it supports 432 00:20:14,780 --> 00:20:17,420 two flavors of 8-pin part 433 00:20:17,420 --> 00:20:18,860 and then a 20 and a 28-pin. 434 00:20:19,240 --> 00:20:20,840 There's also a microcontroller on it 435 00:20:20,840 --> 00:20:22,560 that's doing the system programming. 436 00:20:22,980 --> 00:20:23,140 Yeah? 437 00:20:23,320 --> 00:20:24,740 Are there any OS requirements 438 00:20:24,740 --> 00:20:25,680 for the development environment? 439 00:20:26,520 --> 00:20:28,400 This particular OS only runs, 440 00:20:28,540 --> 00:20:30,100 or this particular development only runs 441 00:20:30,100 --> 00:20:31,280 under a rather unpopular OS. 442 00:20:31,840 --> 00:20:33,280 There are other options, 443 00:20:33,340 --> 00:20:34,520 and I'll touch on that in just a minute. 444 00:20:35,300 --> 00:20:36,800 But a good question. 445 00:20:37,120 --> 00:20:39,120 The white circular thing 446 00:20:39,120 --> 00:20:40,620 is actually a piezoelectric speaker 447 00:20:40,620 --> 00:20:43,720 that allows you to do sound output, 448 00:20:43,720 --> 00:20:45,280 and I'll touch on that 449 00:20:45,280 --> 00:20:47,340 as a neat application of these parts shortly. 450 00:20:48,340 --> 00:20:50,240 And then another nice thing about this board 451 00:20:50,240 --> 00:20:52,540 is it has its own power regulator built in, 452 00:20:52,600 --> 00:20:55,980 so you feed it basically 7 to 20 volts AC or DC, 453 00:20:56,200 --> 00:20:57,800 and it's any polarity of DC, 454 00:20:57,940 --> 00:20:58,760 and it's fine with that. 455 00:21:01,840 --> 00:21:02,880 As I mentioned, 456 00:21:03,080 --> 00:21:04,640 it accommodates the 20 to 28 pins, provides, 457 00:21:04,940 --> 00:21:07,080 oh, it also provides four LEDs and four buttons. 458 00:21:07,200 --> 00:21:08,420 The fifth LED and button 459 00:21:08,420 --> 00:21:10,440 were the power and reset, respectively. 460 00:21:10,440 --> 00:21:14,140 And then there's various jumpers 461 00:21:14,140 --> 00:21:17,440 next to all of the sockets 462 00:21:18,180 --> 00:21:20,080 that allow you to turn on and off 463 00:21:20,080 --> 00:21:20,760 some of the functionality. 464 00:21:21,080 --> 00:21:23,020 If you want to wire things out directly, 465 00:21:23,260 --> 00:21:26,160 the jumpers make great wire wrap posts. 466 00:21:27,240 --> 00:21:29,900 And then this is a really good system 467 00:21:29,900 --> 00:21:33,280 for getting a minimal development going. 468 00:21:34,760 --> 00:21:36,360 But once you're going, 469 00:21:36,440 --> 00:21:37,780 it's also really easy to transition 470 00:21:37,780 --> 00:21:39,340 to a standalone device, 471 00:21:39,340 --> 00:21:41,160 and in fact there's an ISP header 472 00:21:41,160 --> 00:21:42,460 at the top of the board. 473 00:21:43,140 --> 00:21:46,320 There's a header that allows you to use this board 474 00:21:46,320 --> 00:21:47,980 to in-system program your own part 475 00:21:47,980 --> 00:21:49,700 if you accommodate that in your design 476 00:21:50,300 --> 00:21:51,340 in an external board. 477 00:21:51,800 --> 00:21:52,920 Oh, and one other thing, 478 00:21:52,960 --> 00:21:55,120 there's an IR transceiver pair on this thing 479 00:21:55,120 --> 00:21:57,120 if you want to develop an IR remote control, 480 00:21:57,300 --> 00:21:59,040 and I'll talk about that a little bit shortly. 481 00:22:01,140 --> 00:22:03,380 Okay, so what if you hate this OS? 482 00:22:03,740 --> 00:22:04,720 Or what if you want, 483 00:22:04,800 --> 00:22:05,920 or why can't you use C? 484 00:22:06,820 --> 00:22:08,180 Specifically cross assemblers, 485 00:22:08,320 --> 00:22:09,260 and that's, 486 00:22:09,340 --> 00:22:10,340 my preferred development tool, 487 00:22:10,500 --> 00:22:12,640 are available for pretty much any OS. 488 00:22:12,940 --> 00:22:14,860 The assemblers are relatively simple to write. 489 00:22:14,940 --> 00:22:16,100 One of the nice things that falls out 490 00:22:16,100 --> 00:22:17,620 of a RISC architecture 491 00:22:18,220 --> 00:22:19,520 is the assemblers are pretty straightforward. 492 00:22:20,740 --> 00:22:22,600 The ISP tools are also available. 493 00:22:22,800 --> 00:22:24,680 I do not recall off the top of my head 494 00:22:24,680 --> 00:22:27,120 what the preferred Linux ISP 495 00:22:27,120 --> 00:22:28,360 or BSD ISP is. 496 00:22:29,120 --> 00:22:31,140 I'll try to get pointers to those up on the website 497 00:22:31,140 --> 00:22:32,040 fairly quickly. Yes? 498 00:22:40,140 --> 00:22:42,060 A terminal emulator and a Z modem transfer 499 00:22:43,000 --> 00:22:44,500 with the STK? 500 00:22:44,980 --> 00:22:46,420 With this particular development environment? 501 00:22:52,520 --> 00:22:52,960 Okay. 502 00:22:54,940 --> 00:22:55,820 If you've got, 503 00:22:56,440 --> 00:22:57,640 if you've got a minimal system, 504 00:22:57,800 --> 00:22:59,860 I'm not sure if that will work 505 00:22:59,860 --> 00:23:00,720 with this particular board. 506 00:23:00,840 --> 00:23:01,160 It may. 507 00:23:02,100 --> 00:23:03,240 I honestly don't know. 508 00:23:03,400 --> 00:23:05,600 He suggested you can just do a Z modem, 509 00:23:05,620 --> 00:23:06,440 was it Z modem transfer? 510 00:23:07,040 --> 00:23:07,480 Okay. 511 00:23:07,480 --> 00:23:09,080 Okay, to the part. 512 00:23:09,880 --> 00:23:11,280 But the upshot of it is that 513 00:23:11,280 --> 00:23:12,480 even though Canda, 514 00:23:12,620 --> 00:23:13,860 who makes this board for Atmel, 515 00:23:13,940 --> 00:23:15,640 does not publish this stuff widely enough, 516 00:23:16,140 --> 00:23:17,580 it is readily available online. 517 00:23:18,760 --> 00:23:19,780 And as far as C, 518 00:23:20,020 --> 00:23:20,700 you can use, 519 00:23:20,800 --> 00:23:22,560 there's a variety of C development environments. 520 00:23:22,740 --> 00:23:23,300 A lot of people say, 521 00:23:23,400 --> 00:23:23,700 well, you know, 522 00:23:23,820 --> 00:23:25,140 C can be done efficiently, 523 00:23:25,280 --> 00:23:25,980 and it in fact can. 524 00:23:26,520 --> 00:23:28,480 IAR makes a third-party development set. 525 00:23:28,540 --> 00:23:30,100 Unfortunately, that costs about 5K. 526 00:23:31,120 --> 00:23:33,940 GCC, which actually arguably produces better code, 527 00:23:34,460 --> 00:23:36,420 is available widely. 528 00:23:36,760 --> 00:23:37,200 And, 529 00:23:38,140 --> 00:23:39,020 it does, 530 00:23:39,220 --> 00:23:41,440 it's really easy to set up a C environment. 531 00:23:41,660 --> 00:23:43,500 I don't do it simply because I prefer to see 532 00:23:43,500 --> 00:23:45,060 exactly what instructions I'm twiddling 533 00:23:45,060 --> 00:23:47,980 and be able to run the simulator environment. 534 00:23:49,060 --> 00:23:50,540 One of the things you've got to be aware of 535 00:23:50,540 --> 00:23:51,200 when you're using C, 536 00:23:51,260 --> 00:23:52,620 especially with a part like this, 537 00:23:52,680 --> 00:23:54,960 some of the compilers will choke on this 538 00:23:54,960 --> 00:23:56,640 simply because you have no SRAM, 539 00:23:56,680 --> 00:23:58,380 and they really want a stack 540 00:23:58,380 --> 00:23:59,520 to maintain stack frames. 541 00:24:00,120 --> 00:24:02,680 And they get cranky when they've got no SRAM at all. 542 00:24:04,440 --> 00:24:04,880 But, 543 00:24:05,740 --> 00:24:06,880 they can do it. 544 00:24:07,840 --> 00:24:08,360 Okay, 545 00:24:08,700 --> 00:24:09,840 so what can you actually do? 546 00:24:09,940 --> 00:24:11,200 What are some of my sample applications? 547 00:24:11,760 --> 00:24:13,220 An AT keyboard interface, 548 00:24:13,760 --> 00:24:15,060 a serial flash connection, 549 00:24:15,680 --> 00:24:16,980 and audio output, 550 00:24:17,060 --> 00:24:19,120 and some of the canonical audio examples 551 00:24:19,120 --> 00:24:21,060 are Morse and DTMF. 552 00:24:23,680 --> 00:24:26,160 Some other example modules would be a soft UART, 553 00:24:26,180 --> 00:24:27,120 I alluded to that earlier, 554 00:24:27,500 --> 00:24:28,760 data stream manipulator, 555 00:24:28,880 --> 00:24:30,460 otherwise known as a mod chip, 556 00:24:30,720 --> 00:24:32,240 an IR remote control, 557 00:24:32,500 --> 00:24:34,340 or even a small parallel application, 558 00:24:34,540 --> 00:24:36,040 in this case a 4-bit parallel application, 559 00:24:36,040 --> 00:24:37,200 a stepper motor controller. 560 00:24:38,920 --> 00:24:40,880 So the AT keyboard interface. 561 00:24:41,160 --> 00:24:43,100 At this point, I'm going to delve into these. 562 00:24:43,220 --> 00:24:45,560 I'm going to try to give you a sort of glancing overview 563 00:24:45,920 --> 00:24:47,180 of a bunch of different things, 564 00:24:47,340 --> 00:24:49,340 reference some of the application notes 565 00:24:49,340 --> 00:24:50,000 you may want to look at. 566 00:24:50,100 --> 00:24:51,440 If you have more questions, 567 00:24:51,620 --> 00:24:52,680 feel free to raise them, 568 00:24:52,720 --> 00:24:54,900 either now, Q&A, or after the talk. 569 00:24:55,580 --> 00:24:56,780 But the AT keyboard interface, 570 00:24:56,980 --> 00:24:57,700 for anyone who's looked at it, 571 00:24:57,760 --> 00:24:59,320 is a synchronous serial interface, 572 00:24:59,460 --> 00:25:00,740 meaning you have a clock and a data line. 573 00:25:01,180 --> 00:25:03,000 It's very well documented, very straightforward. 574 00:25:03,800 --> 00:25:06,020 It also includes 5-volt power with it. 575 00:25:06,040 --> 00:25:06,840 This is really nice, 576 00:25:06,920 --> 00:25:09,220 because it means that the AT connector 577 00:25:09,220 --> 00:25:11,100 can power your little widget, 578 00:25:11,220 --> 00:25:13,700 and you're well within the current limitations 579 00:25:13,700 --> 00:25:17,500 of any device hanging off an AT port. 580 00:25:17,660 --> 00:25:21,080 In fact, virtually every keyboard in the world 581 00:25:21,080 --> 00:25:22,740 has a microcontroller in it, 582 00:25:22,800 --> 00:25:24,160 which is just running an AT interface. 583 00:25:24,520 --> 00:25:26,120 Most of them are 8051s, 584 00:25:26,120 --> 00:25:29,040 because they were all designed back in about 1983, 585 00:25:30,320 --> 00:25:32,400 ported over when AT became popular, 586 00:25:32,660 --> 00:25:34,120 when XT became AT, 587 00:25:34,120 --> 00:25:36,740 and then they largely haven't changed them. 588 00:25:36,820 --> 00:25:39,140 It's a ROM-based microcontroller. 589 00:25:39,600 --> 00:25:41,860 The QCAT makes a great housing 590 00:25:41,860 --> 00:25:43,000 and a source of cable 591 00:25:43,000 --> 00:25:44,880 if you're looking for a keyboard interface. 592 00:25:46,340 --> 00:25:47,820 In taking apart the QCAT, 593 00:25:47,880 --> 00:25:49,620 you will also learn some interesting truths. 594 00:25:49,860 --> 00:25:52,060 One of them is that there is no direct electrical connection 595 00:25:52,060 --> 00:25:55,120 between the keyboard in and keyboard out from the QCAT, 596 00:25:55,220 --> 00:25:57,940 which means that it is at least handing along 597 00:25:57,940 --> 00:26:00,080 and being aware of every keystroke. 598 00:26:00,300 --> 00:26:01,220 This makes sense, 599 00:26:01,320 --> 00:26:02,740 but it's also a little insidious 600 00:26:02,740 --> 00:26:04,100 for reasons I'll get to momentarily. 601 00:26:06,980 --> 00:26:11,160 So the Atmel reference AT keyboard interface 602 00:26:11,160 --> 00:26:12,480 is Application Note 313. 603 00:26:12,800 --> 00:26:13,740 They wrote it in C. 604 00:26:13,940 --> 00:26:14,740 I went through it, 605 00:26:14,800 --> 00:26:16,900 and I've done parts of it in assembly. 606 00:26:17,020 --> 00:26:20,460 I haven't got that up and available online yet either, 607 00:26:20,540 --> 00:26:21,340 but hopefully it will be. 608 00:26:22,020 --> 00:26:24,700 They actually put the clock on the external interrupt line. 609 00:26:24,780 --> 00:26:25,920 One of the nice things about the AT interface 610 00:26:25,920 --> 00:26:28,280 is it has a maximum clock rate of, I believe, 611 00:26:28,320 --> 00:26:30,240 around 100 kilohertz, 110 kilohertz, 612 00:26:30,320 --> 00:26:31,640 which means you can actually, 613 00:26:32,360 --> 00:26:33,200 it's slow enough, 614 00:26:33,200 --> 00:26:34,600 you can just trigger an interrupt 615 00:26:34,600 --> 00:26:36,320 every time a clock signal comes in 616 00:26:36,320 --> 00:26:37,600 and read the bit. 617 00:26:38,840 --> 00:26:40,480 Sample the data every interrupt, 618 00:26:40,660 --> 00:26:43,680 and then it's possible to get out of sync 619 00:26:43,680 --> 00:26:45,780 with the 11-bit frame that it sends 620 00:26:45,780 --> 00:26:48,240 if you somehow miss a bit for some reason. 621 00:26:48,460 --> 00:26:49,240 In that case, 622 00:26:49,320 --> 00:26:50,860 what you generally want to do is timeout. 623 00:26:51,080 --> 00:26:54,640 Their canonical example uses an 8-bit timer 624 00:26:54,640 --> 00:26:56,620 for a 1.5 millisecond timeout, 625 00:26:56,680 --> 00:26:58,000 and then this is where, 626 00:26:58,060 --> 00:27:00,840 if you're clever and want to save a few bytes of code space, 627 00:27:00,980 --> 00:27:02,000 you just set up the watchdog 628 00:27:02,000 --> 00:27:04,520 to timeout after 15 milliseconds. 629 00:27:04,640 --> 00:27:06,060 Every time you receive a bit 630 00:27:06,060 --> 00:27:08,200 or you've gotten to the end of the 11-bit frame, 631 00:27:08,480 --> 00:27:10,720 you kick the watchdog timer. 632 00:27:11,000 --> 00:27:12,560 Otherwise, it'll get to 15 milliseconds. 633 00:27:12,600 --> 00:27:13,940 It'll assume that it's gotten out of sync 634 00:27:13,940 --> 00:27:14,960 and it'll timeout and reset. 635 00:27:17,000 --> 00:27:20,020 What are some amusing widgets you could build 636 00:27:20,020 --> 00:27:21,800 with just an 8-bit microcontroller 637 00:27:21,800 --> 00:27:23,420 hooked up to an AT keyboard? 638 00:27:23,660 --> 00:27:25,160 A few I came up with were the typo generator, 639 00:27:25,740 --> 00:27:26,860 where you could have something 640 00:27:26,860 --> 00:27:28,720 that sits on the keyboard line 641 00:27:28,720 --> 00:27:31,280 and turns, say, every fourth R into a T 642 00:27:31,280 --> 00:27:34,260 or just does minor transformations 643 00:27:34,260 --> 00:27:36,480 in a non-obvious way on the keyboard stream. 644 00:27:36,740 --> 00:27:38,140 This will annoy the hell out of anyone 645 00:27:38,140 --> 00:27:40,180 who doesn't know that it's there. 646 00:27:42,760 --> 00:27:44,500 Another that I would like to build 647 00:27:44,500 --> 00:27:45,500 is the keyboard pipeline, 648 00:27:46,100 --> 00:27:48,160 where it doesn't actually release a keystroke 649 00:27:48,160 --> 00:27:49,020 until the next one, 650 00:27:49,120 --> 00:27:53,840 so you've got a lag of keystroke in your keyboard. 651 00:27:54,720 --> 00:27:56,580 And then something that's actually useful, 652 00:27:56,800 --> 00:27:59,400 something that actually has some use, 653 00:27:59,440 --> 00:28:00,560 would be a keyboard remapper. 654 00:28:01,280 --> 00:28:02,580 You might want to do a QWERTY to VORAC 655 00:28:03,140 --> 00:28:04,420 or a PC to Sun, 656 00:28:04,600 --> 00:28:06,280 because a lot of people get cranky 657 00:28:06,280 --> 00:28:09,500 about transposing caps lock and control 658 00:28:09,500 --> 00:28:10,460 when they're changing keyboards. 659 00:28:10,880 --> 00:28:14,300 So there are actually a lot of useful applications, 660 00:28:14,400 --> 00:28:17,360 even with just the AT keyboard interface. 661 00:28:17,880 --> 00:28:17,980 Yeah? 662 00:28:18,860 --> 00:28:19,420 . 663 00:28:23,060 --> 00:28:23,620 . 664 00:28:23,620 --> 00:28:23,740 . 665 00:28:31,280 --> 00:28:31,460 . 666 00:28:35,580 --> 00:28:35,820 . 667 00:28:45,780 --> 00:28:46,020 . 668 00:28:46,020 --> 00:28:46,040 . 669 00:28:46,040 --> 00:28:46,060 . 670 00:28:46,060 --> 00:28:46,120 . 671 00:28:46,120 --> 00:28:47,980 Say you want a lot of memory. 672 00:28:48,340 --> 00:28:49,920 A serial flash, for example. 673 00:28:50,380 --> 00:28:51,900 Atmel makes this great little part. 674 00:28:51,980 --> 00:28:53,620 It's the AT24C512. 675 00:28:53,680 --> 00:28:58,540 It is 64k bytes of flash in an eight-pin DIP package. 676 00:28:59,180 --> 00:29:02,940 It has, again, a two-wire bidirectional interface. 677 00:29:03,440 --> 00:29:09,320 You can actually stack them, and because they're using power and ground as two of their pins, 678 00:29:09,860 --> 00:29:14,280 clock and data as two of their other pins, they have a write protect pin, and then two 679 00:29:14,280 --> 00:29:15,480 of the pins are address lines. 680 00:29:15,480 --> 00:29:20,740 So, you can actually set these address lines, basically as a bootstrapping, you hardwire 681 00:29:20,740 --> 00:29:25,680 the address lines, and then in the command frame to the serial EEPROM, you can address 682 00:29:26,180 --> 00:29:26,680 an address. 683 00:29:26,820 --> 00:29:30,300 You provide two address bits, so you can address up to four of them, which means you can stack 684 00:29:30,300 --> 00:29:37,260 them and you can basically bust them together and get up to 256k bytes of storage in serial 685 00:29:37,260 --> 00:29:39,800 EEPROM in a very small form factor. 686 00:29:41,020 --> 00:29:42,060 Here's an example. 687 00:29:43,100 --> 00:29:44,940 One of the nice things is because it's... 688 00:29:44,940 --> 00:29:48,440 They're both eight-pin DIP packages, they share power and ground pins, so you can do 689 00:29:48,440 --> 00:29:54,320 this little bug sex thing where you basically just stack them together. 690 00:29:54,800 --> 00:29:56,520 In this case, I would actually... 691 00:29:56,520 --> 00:30:00,540 To do what I want to do with it, I'd actually have to route some of the pins around with 692 00:30:00,540 --> 00:30:06,100 some wires because this unfortunately puts one of the serial data lines on top of the 693 00:30:06,100 --> 00:30:08,620 ATML interrupt line, which you want for the keyboard interface. 694 00:30:09,340 --> 00:30:13,880 But I mean, if you look at it, it's pretty cool that you've got in the left-hand picture, 695 00:30:13,880 --> 00:30:17,120 you have a microcontroller with 64k of flash hanging off it. 696 00:30:17,160 --> 00:30:18,020 That's non-volatile memory. 697 00:30:19,080 --> 00:30:24,100 The whole system runs at five volts and basically you could make that work with no other hardware 698 00:30:24,100 --> 00:30:24,920 hanging off it. 699 00:30:25,580 --> 00:30:29,520 The right-hand example is if you want to boost that up to 192k of flash. 700 00:30:31,300 --> 00:30:32,620 I have the one pin... 701 00:30:32,620 --> 00:30:36,640 That's one of the address lines and basically, I just wanted to provide an example of how 702 00:30:36,640 --> 00:30:36,920 you... 703 00:30:36,920 --> 00:30:41,660 If you don't want that pin connected, normally you would tag the pins together with solder, 704 00:30:41,820 --> 00:30:43,860 but if you want a pin to go somewhere else, it's much easier. 705 00:30:43,880 --> 00:30:45,960 It's really easy to just lift it up and run a wire off it. 706 00:30:48,200 --> 00:30:48,600 Hmm. 707 00:30:49,640 --> 00:30:54,360 Okay, so you've got an AT keyboard interface, you've got a large non-volatile memory, you've 708 00:30:54,360 --> 00:30:56,440 got a tiny size, and you've got a bunch of people at DEF CON. 709 00:30:58,620 --> 00:31:00,240 What could we build with this? 710 00:31:01,200 --> 00:31:05,680 Now, at this point, I will go into a brief aside on a moral conundrum I found myself 711 00:31:05,680 --> 00:31:06,760 in when preparing this talk. 712 00:31:07,280 --> 00:31:11,100 It resolved itself in part because I was behind schedule and didn't get the thing completely 713 00:31:11,100 --> 00:31:11,460 built. 714 00:31:11,540 --> 00:31:13,560 But I was actually going to provide a reference design. 715 00:31:13,880 --> 00:31:16,940 It was designed for a keyboard sniffer that anyone could build. 716 00:31:17,580 --> 00:31:20,620 I read an article, though, about giving guns to children. 717 00:31:23,920 --> 00:31:28,420 And it struck a chord with me that, you know, there should be a certain minimal sincerity 718 00:31:28,420 --> 00:31:29,260 check to this. 719 00:31:29,360 --> 00:31:31,620 You should at least have to build your own gun. 720 00:31:32,840 --> 00:31:40,140 So I largely leave it at that, but the implication is you could build a really spiffy little 721 00:31:40,140 --> 00:31:41,980 keyboard sniffer. 722 00:31:42,680 --> 00:31:43,120 And... 723 00:31:43,120 --> 00:31:48,460 And as to the question of how you get it out, how you get the data out, if you've seen the 724 00:31:48,460 --> 00:31:51,880 Ghost Board, which is actually a commercial product that does this, and is in fact based 725 00:31:51,880 --> 00:31:52,540 on... 726 00:31:52,540 --> 00:31:54,780 I think it might be based on an AVR, I don't remember. 727 00:31:54,940 --> 00:31:57,540 There's a web page, someone tore one apart and saw what's in there. 728 00:31:57,680 --> 00:31:59,520 And they actually used a larger microcontroller. 729 00:31:59,540 --> 00:32:03,780 I think this is a little slick, a little cooler solution, because it's just that much smaller. 730 00:32:03,900 --> 00:32:06,540 I mean, you could probably make it look like just the keyboard connector. 731 00:32:07,560 --> 00:32:12,620 But in their solution, they actually capture keystrokes and then output keystrokes. 732 00:32:12,720 --> 00:32:13,080 And... 733 00:32:13,720 --> 00:32:14,700 And you can actually just out the code, you can actually use the code as the means of 734 00:32:14,700 --> 00:32:15,120 getting to it. 735 00:32:15,140 --> 00:32:17,420 You actually type an activation sequence. 736 00:32:17,580 --> 00:32:21,980 And since it's sniffing the AT keyboard interface, you can just use that to trigger it to have 737 00:32:21,980 --> 00:32:25,280 it kick over and reveal that it's there and start dumping its log. 738 00:32:27,760 --> 00:32:30,620 I would be inclined to actually make the thing completely transparent. 739 00:32:30,800 --> 00:32:33,660 You want it to be completely out of band, so there is nothing you can type that would 740 00:32:33,660 --> 00:32:34,420 make it reveal itself. 741 00:32:34,820 --> 00:32:41,140 And also I would prefer to, given the number of pins and what I'd like to use them for, 742 00:32:41,260 --> 00:32:42,980 I would probably actually set the hardware up. 743 00:32:42,980 --> 00:32:47,180 so that I would have to drop it into a second fixture to extract the memory, 744 00:32:47,260 --> 00:32:49,400 but that's just because I want to be the only one who can read it. 745 00:32:51,760 --> 00:32:55,760 Anyway, so skipping, skipping, oh, yes, sure. 746 00:33:07,140 --> 00:33:10,520 Yes, the question is, is there a security bit in the Atmel 747 00:33:10,520 --> 00:33:14,300 that will prevent reading back the contents of the program memory? 748 00:33:14,420 --> 00:33:15,080 And the answer is yes. 749 00:33:15,200 --> 00:33:18,200 There's a couple of flash fuses that set different functionality, 750 00:33:18,360 --> 00:33:19,720 but one of them is a security bit. 751 00:33:19,800 --> 00:33:26,540 There's a read protect that will make it impossible to extract the contents. 752 00:33:27,000 --> 00:33:32,500 There is also a write protect, I believe, that makes it impossible to overwrite it, 753 00:33:32,520 --> 00:33:34,580 although you can still erase it if you want to, 754 00:33:35,700 --> 00:33:38,660 so you don't end up turning it into a one-time programmable part. 755 00:33:40,560 --> 00:33:45,640 But anyway, it depends on the specific part, but check the data sheet. 756 00:33:45,740 --> 00:33:47,720 There are definitely things you can do to make your code, 757 00:33:47,860 --> 00:33:49,660 I won't say impossible to extract, 758 00:33:49,880 --> 00:33:52,300 but you can require them to shave off the top of the part 759 00:33:52,300 --> 00:33:53,940 and use really expensive probing equipment. 760 00:33:56,160 --> 00:33:58,460 And there are some really neat probing tools. 761 00:33:59,640 --> 00:34:00,620 So audio output. 762 00:34:01,440 --> 00:34:05,500 There is a proud history with 8-bit systems of generating audio 763 00:34:05,500 --> 00:34:07,860 by twiddling one bit to a speaker. 764 00:34:08,140 --> 00:34:09,700 Anyone who grew up with an Apple II 765 00:34:09,700 --> 00:34:10,500 knows that you can... 766 00:34:10,520 --> 00:34:12,520 You can do some pretty amazing things with one bit to a speaker. 767 00:34:13,300 --> 00:34:16,240 You can also use a lookup table to generate a more pure tone, 768 00:34:16,480 --> 00:34:19,660 and I talk about using a lookup table in either EEPROM 769 00:34:19,660 --> 00:34:21,000 or using load program memory. 770 00:34:23,600 --> 00:34:24,900 You may be wondering how... 771 00:34:24,900 --> 00:34:26,220 If you've only got one bit going out, 772 00:34:26,280 --> 00:34:27,920 how do you get anything other than on or off, 773 00:34:27,980 --> 00:34:30,480 and I'll talk about that in just a second. 774 00:34:32,540 --> 00:34:36,640 With program space, I talked about this briefly earlier, 775 00:34:36,740 --> 00:34:39,960 but the way you extract your lookup tables from program spaces 776 00:34:39,960 --> 00:34:41,120 with the LPM command, 777 00:34:41,420 --> 00:34:43,820 you put the address you're looking for in the Z register, 778 00:34:44,080 --> 00:34:46,140 which is basically the R30 and R31, 779 00:34:46,460 --> 00:34:50,620 and then because of the way they want to represent the program memory 780 00:34:50,620 --> 00:34:52,740 as a 16-bit word, 781 00:34:53,040 --> 00:34:56,480 they call the upper 15 bits the word address 782 00:34:56,480 --> 00:34:58,260 and the lower bit the byte select, 783 00:34:58,560 --> 00:35:00,740 which is the same as saying a byte address, 784 00:35:00,980 --> 00:35:02,960 but that's the way they represent it. 785 00:35:03,020 --> 00:35:06,100 But basically, it means that you can store constants efficiently 786 00:35:06,100 --> 00:35:09,620 in the 16-bit flash code space. 787 00:35:09,960 --> 00:35:11,860 So you can store lookup tables 788 00:35:11,860 --> 00:35:14,340 even though you don't have the EEPROM in this particular part. 789 00:35:16,080 --> 00:35:19,700 Morse code, like I said, is a real canonical audio interface. 790 00:35:19,900 --> 00:35:26,840 It's kind of cool because it represents a fairly well-known audio output, 791 00:35:26,980 --> 00:35:30,020 and it's kind of nice to have your part alert itself 792 00:35:30,020 --> 00:35:32,620 that it needs to do something by just going . 793 00:35:34,220 --> 00:35:37,640 An interesting exercise when you're working with a system with no space, 794 00:35:38,220 --> 00:35:39,940 such as this, or minimal space, 795 00:35:39,960 --> 00:35:42,460 is how do you encode Morse code 796 00:35:43,120 --> 00:35:46,180 for your lookup table to do the ASCII to Morse conversion? 797 00:35:46,560 --> 00:35:49,840 And I touch on this just because it's a neat example 798 00:35:49,840 --> 00:35:52,900 of figuring out how to store things really efficiently. 799 00:35:53,680 --> 00:35:56,360 Morse is essentially binary in that you've got short and long, 800 00:35:56,460 --> 00:35:57,800 but you've got variable length symbols 801 00:35:58,720 --> 00:36:00,680 anywhere from E and T, which are 1, 802 00:36:00,920 --> 00:36:03,680 up to some of the punctuation, which I believe are 6 or 7. 803 00:36:03,760 --> 00:36:05,340 I don't remember if there's any 7 punctuation. 804 00:36:06,340 --> 00:36:09,940 If you use a counter and a bitmap, 805 00:36:09,960 --> 00:36:12,880 then you quickly run out of bits for anything longer than 5. 806 00:36:13,080 --> 00:36:13,980 And I talk about L. 807 00:36:14,220 --> 00:36:17,680 There you could use the 4 and then a bitmask, 808 00:36:17,720 --> 00:36:21,920 and you could concatenate them together using 3 bits of length 809 00:36:21,920 --> 00:36:24,240 and 5 bits of data. 810 00:36:24,680 --> 00:36:28,940 Or you could use 0 null bits at the start, 811 00:36:29,080 --> 00:36:32,200 a 1 start bit, and then the bitmask after that, 812 00:36:32,320 --> 00:36:36,380 in which case you've managed to reduce the length indicator to 1 bit. 813 00:36:37,860 --> 00:36:39,940 And this struck me as something that's not a big deal, 814 00:36:39,960 --> 00:36:42,160 not immediately obvious, but is a nice efficient way 815 00:36:42,160 --> 00:36:44,420 of storing things that are variable length 816 00:36:44,420 --> 00:36:45,560 and little lookup tables. 817 00:36:46,300 --> 00:36:48,580 So I felt compelled to include that. 818 00:36:50,460 --> 00:36:51,500 Okay, DTMF. 819 00:36:51,660 --> 00:36:53,380 Say instead of a Morse application, 820 00:36:53,560 --> 00:36:54,960 you want to be able to dial a phone. 821 00:36:55,360 --> 00:36:57,000 Atmel has an application note for you. 822 00:36:57,480 --> 00:36:58,580 AVR 314. 823 00:36:58,920 --> 00:37:03,160 They do it in 260 bytes of code and 128 byte lookup table. 824 00:37:03,260 --> 00:37:06,240 The lookup table is basically just a representation 825 00:37:06,240 --> 00:37:09,500 of the pulse width modulation constants for a sine wave. 826 00:37:09,960 --> 00:37:15,500 And what you do is you output variable length constant values 827 00:37:15,500 --> 00:37:18,880 on the speaker pin, and then you take advantage of the fact 828 00:37:18,880 --> 00:37:22,700 that there is a characteristic capacitance to act as a low pass filter. 829 00:37:23,400 --> 00:37:27,060 And so what you do is by turning the speaker on and off faster 830 00:37:27,060 --> 00:37:29,100 than it could possibly represent in audio, 831 00:37:29,300 --> 00:37:32,900 you get the low pass equivalent of that, 832 00:37:32,940 --> 00:37:35,620 which turns into a sine wave or something close enough to it 833 00:37:35,620 --> 00:37:37,460 that you can actually do fairly pure tones. 834 00:37:37,540 --> 00:37:39,360 You can do tones pure enough to do DTMF. 835 00:37:40,200 --> 00:37:42,680 In this case, the example in the data sheet 836 00:37:42,680 --> 00:37:46,100 uses a pulse width modulation feature 837 00:37:46,100 --> 00:37:50,660 that is included on a lot of the timer counters on the larger AVRs. 838 00:37:50,740 --> 00:37:53,000 In this case, there is a timer counter, 839 00:37:53,160 --> 00:37:54,920 but there is no pulse width modulation feature to it, 840 00:37:54,980 --> 00:37:57,000 so you would have to jerry-rig that in software, 841 00:37:57,180 --> 00:37:57,840 but it can be done. 842 00:37:59,220 --> 00:38:01,600 And that's how you can do pure tones. 843 00:38:02,120 --> 00:38:04,340 Obviously, if you want to do complex sounds, 844 00:38:04,440 --> 00:38:06,280 you would need a much larger external memory. 845 00:38:06,400 --> 00:38:09,940 But again, if you've got, say, a 64k K-byte phone, 846 00:38:09,960 --> 00:38:10,960 and you've got flash memory hanging off it, 847 00:38:11,080 --> 00:38:14,480 you could actually do a pulse width modulation representation 848 00:38:14,480 --> 00:38:18,280 of more complex waveforms to generate more complex sounds. 849 00:38:20,960 --> 00:38:21,820 Soft UART. 850 00:38:22,000 --> 00:38:26,060 Say you want your device to be able to talk to the outside world 851 00:38:26,060 --> 00:38:28,180 in an obvious way. 852 00:38:29,180 --> 00:38:32,540 Application note AVR 304 is a really complete, 853 00:38:32,740 --> 00:38:35,900 interrupt-driven, timer-based UART. 854 00:38:36,080 --> 00:38:38,980 It takes several hundred words of code space, 855 00:38:39,960 --> 00:38:41,060 you eat up a good chunk of your code space, 856 00:38:41,200 --> 00:38:43,540 but you end up with a UART that is unobtrusive, 857 00:38:43,740 --> 00:38:44,600 sits in the background, 858 00:38:45,300 --> 00:38:48,920 uses the interrupt pin to detect start bits, 859 00:38:49,100 --> 00:38:51,440 and then samples based on the timer. 860 00:38:52,120 --> 00:38:55,200 All of these, if you're going to hook them up to, say, an RS-232 port, 861 00:38:55,300 --> 00:38:56,960 are going to require an external transceiver 862 00:38:56,960 --> 00:39:00,100 to do the level shifting from 0 to 5 to 0 to 12. 863 00:39:00,980 --> 00:39:02,520 But those are readily available. 864 00:39:02,740 --> 00:39:06,300 Or if you've got a system that's all things you've built, 865 00:39:06,360 --> 00:39:08,160 you can just keep it all at 5-volt signaling. 866 00:39:08,160 --> 00:39:12,020 I believe that's RS-422 or something. 867 00:39:14,520 --> 00:39:15,000 What? 868 00:39:16,560 --> 00:39:17,540 422 is balanced. 869 00:39:17,780 --> 00:39:19,680 Okay, 422 is balanced, thank you. 870 00:39:19,780 --> 00:39:20,200 Yes? 871 00:39:20,900 --> 00:39:22,620 The clock is somewhat unstable. 872 00:39:23,040 --> 00:39:29,240 He asks, the clock is somewhat unstable. 873 00:39:29,560 --> 00:39:32,080 Do you use a crystal to clock it? 874 00:39:32,220 --> 00:39:34,140 And again, the audience is getting ahead of me. 875 00:39:34,180 --> 00:39:35,780 If you wait just about two more slides, 876 00:39:35,900 --> 00:39:36,940 I will, in fact, address that. 877 00:39:38,160 --> 00:39:40,740 But yes, there are definitely clocking problems 878 00:39:40,740 --> 00:39:44,660 on an asynchronous interface that you have clock drift. 879 00:39:45,660 --> 00:39:47,140 And there's a couple of ways around that. 880 00:39:47,280 --> 00:39:49,100 If you want a minimal software UART, 881 00:39:49,180 --> 00:39:52,740 application note AVR-305 is 32 words, 882 00:39:52,940 --> 00:39:55,320 busy wait loops, no interrupt, no timer, 883 00:39:55,500 --> 00:39:57,460 quick and dirty, and it's really kind of cool. 884 00:39:57,540 --> 00:40:01,340 Basically, there's one hard-coded busy wait delay loop 885 00:40:01,340 --> 00:40:02,480 that's half a bit time long 886 00:40:03,100 --> 00:40:05,240 for whatever bit speed you want the thing to accommodate, 887 00:40:05,500 --> 00:40:07,880 and then it just does shift register, 888 00:40:08,160 --> 00:40:13,960 work, and calling this delay loop one, two, or three times, 889 00:40:14,000 --> 00:40:15,940 depending on how many half-bit delays it needs. 890 00:40:16,520 --> 00:40:20,640 And that's a good example of sort of sexy little, 891 00:40:22,100 --> 00:40:25,320 very small, efficient coding for microcontrollers. 892 00:40:25,400 --> 00:40:27,180 I mean, 32 words for a UART is pretty neat. 893 00:40:28,560 --> 00:40:30,480 Some thoughts on software UARTs. 894 00:40:30,480 --> 00:40:35,000 At high bit rates, your clock alignment 895 00:40:35,000 --> 00:40:37,460 with whatever baud rate you're trying to support 896 00:40:37,460 --> 00:40:40,600 will get worse and worse, and as was brought up, 897 00:40:40,640 --> 00:40:42,380 the clocking is only as stable as a system clock. 898 00:40:42,480 --> 00:40:43,700 Beware of the internal oscillator. 899 00:40:43,900 --> 00:40:45,720 If you're using a part like this running at one megahertz, 900 00:40:45,920 --> 00:40:51,160 you can theoretically do a UART that supports 38.4 k baud. 901 00:40:52,120 --> 00:40:55,240 However, you probably want to bring that way back 902 00:40:55,240 --> 00:40:56,840 because as your clock drifts, 903 00:40:56,920 --> 00:40:58,820 the error gets more and more severe. 904 00:41:00,000 --> 00:41:02,040 And you've got thermal drift, you've got voltage drift, 905 00:41:02,120 --> 00:41:03,220 you've got manufacturing variations. 906 00:41:03,600 --> 00:41:06,620 As I said, the AT12 also includes a calibrated clock 907 00:41:06,620 --> 00:41:07,080 that you can use. 908 00:41:07,160 --> 00:41:07,340 Yes? 909 00:41:08,500 --> 00:41:08,940 Yes? 910 00:41:08,940 --> 00:41:09,920 This is my own question. 911 00:41:10,060 --> 00:41:10,340 Oh. 912 00:41:10,420 --> 00:41:12,000 My question was, what's the baud rate 913 00:41:12,000 --> 00:41:15,620 of the AT keyboard serial? 914 00:41:16,140 --> 00:41:17,240 But then it's synchronous. 915 00:41:17,340 --> 00:41:18,820 We've got to cooperate, so it doesn't really matter. 916 00:41:18,940 --> 00:41:19,100 Yeah. 917 00:41:19,340 --> 00:41:22,600 The AT keyboard is a synchronous interface 918 00:41:22,600 --> 00:41:24,540 that can go up to 100 kilohertz, 919 00:41:24,660 --> 00:41:26,680 but fortunately, you don't have to extract 920 00:41:26,680 --> 00:41:27,580 your own clocking out of it. 921 00:41:27,740 --> 00:41:28,080 Yes? 922 00:41:28,340 --> 00:41:30,600 This is a weird question regarding the . 923 00:41:31,380 --> 00:41:34,240 But is it possible to compare the internal clock 924 00:41:34,240 --> 00:41:36,160 with the external clock in order to determine 925 00:41:36,620 --> 00:41:38,780 how much the internal clock is drifting 926 00:41:38,780 --> 00:41:42,320 to do thermal measurement with the die of the part? 927 00:41:42,880 --> 00:41:43,400 Okay. 928 00:41:43,420 --> 00:41:46,300 The question is, can you measure the internal clock 929 00:41:46,300 --> 00:41:48,960 to an external clock to do thermal measurement 930 00:41:48,960 --> 00:41:53,260 of the part with the clock drift? 931 00:41:53,900 --> 00:41:55,340 Not that I am aware of. 932 00:41:55,380 --> 00:41:56,560 I don't believe there is anything. 933 00:41:56,880 --> 00:42:01,820 Well, it might be possible if you had an external counter 934 00:42:01,820 --> 00:42:03,340 to do counter matching. 935 00:42:03,440 --> 00:42:05,840 The trouble is, you can't get single clock resolution 936 00:42:05,840 --> 00:42:08,780 for, it would be difficult to get single clock resolution 937 00:42:08,780 --> 00:42:09,880 for doing comparisons. 938 00:42:11,620 --> 00:42:12,800 It might be possible. 939 00:42:13,260 --> 00:42:17,080 It's much cheaper to just stick a thermal measuring device 940 00:42:17,080 --> 00:42:17,740 in the system. 941 00:42:18,900 --> 00:42:25,040 Either a thermal diode or an explicit thermistor. 942 00:42:26,220 --> 00:42:28,820 Another point you bring up though is clock drift, 943 00:42:29,040 --> 00:42:31,260 if you do have a stable external reference 944 00:42:31,260 --> 00:42:33,300 and you are willing to believe that clock drift 945 00:42:33,300 --> 00:42:34,060 is truly random, 946 00:42:35,180 --> 00:42:36,980 is a good source of randomness. 947 00:42:37,540 --> 00:42:39,420 You can actually use clock noise 948 00:42:39,420 --> 00:42:40,880 to feed your entropy buffer 949 00:42:42,000 --> 00:42:43,840 if you are into that sort of thing. 950 00:42:47,020 --> 00:42:48,240 So, data stream manipulation. 951 00:42:49,000 --> 00:42:49,660 How am I doing? 952 00:42:50,020 --> 00:42:50,520 Oh my. 953 00:42:51,160 --> 00:42:52,600 Data stream manipulation, mod chips. 954 00:42:52,700 --> 00:42:54,160 Like I said, I'm going to only touch on this. 955 00:42:54,280 --> 00:42:56,600 If you do a search on AVR mod chips for the PlayStation, 956 00:42:56,880 --> 00:42:58,000 you will find that there is someone 957 00:42:58,000 --> 00:42:59,620 who actually has source code available online. 958 00:43:00,480 --> 00:43:02,680 The way a mod chip works, at least in a PlayStation, 959 00:43:02,680 --> 00:43:05,680 is you are just replacing the very low bitrate, 960 00:43:05,820 --> 00:43:08,560 out-of-band serial stream 961 00:43:09,020 --> 00:43:10,660 that says what the region code 962 00:43:10,660 --> 00:43:12,680 for this particular disk is. 963 00:43:12,920 --> 00:43:16,640 And what it does is instead spits out all of the region codes 964 00:43:16,640 --> 00:43:18,200 so that any mod chip will work anywhere. 965 00:43:18,540 --> 00:43:21,300 And the PlayStation hardware that reads this, 966 00:43:21,400 --> 00:43:22,840 at least initially, was forgiving enough 967 00:43:22,840 --> 00:43:23,840 to accept this sort of behavior. 968 00:43:25,360 --> 00:43:27,360 Most of the mod chips that you can buy online 969 00:43:27,360 --> 00:43:29,140 are implemented on the PIC device. 970 00:43:30,040 --> 00:43:32,240 Like I said, there is at least one AVR available online. 971 00:43:32,240 --> 00:43:34,520 And again, beware of clock deviation. 972 00:43:35,140 --> 00:43:36,260 If you are going to do a mod chip, 973 00:43:36,360 --> 00:43:37,560 you might want to do it on an AT12 974 00:43:37,560 --> 00:43:39,320 which has a calibrated clock 975 00:43:39,320 --> 00:43:41,800 because if you have thermal drift, 976 00:43:42,100 --> 00:43:43,420 you can actually get far enough out 977 00:43:43,420 --> 00:43:44,580 that your mod chip will stop working. 978 00:43:44,700 --> 00:43:46,040 Some of the early generation mod chips 979 00:43:46,040 --> 00:43:47,340 suffered from thermal failure 980 00:43:47,340 --> 00:43:49,820 where as your PlayStation is on for half an hour, 981 00:43:49,880 --> 00:43:52,400 it warms up and the thing no longer works. 982 00:43:55,280 --> 00:43:57,080 PlayStation 2 mod chips are showing this behavior. 983 00:43:57,760 --> 00:43:59,460 I know that there was also some effort 984 00:43:59,460 --> 00:44:01,320 in the design of the PlayStation 2 985 00:44:01,320 --> 00:44:03,380 to make it a little harder to do this sort of thing. 986 00:44:05,020 --> 00:44:06,160 Obviously, in any system 987 00:44:06,160 --> 00:44:07,380 where you have got the signals running around, 988 00:44:07,500 --> 00:44:08,880 someone is going to figure out a way to get in there. 989 00:44:09,120 --> 00:44:11,300 I think their goal is merely to make the mod chip 990 00:44:11,300 --> 00:44:12,400 more expensive than the PlayStation. 991 00:44:14,120 --> 00:44:15,720 And that may well happen. 992 00:44:18,580 --> 00:44:22,060 And then I talked briefly about doing an IR receiver 993 00:44:22,060 --> 00:44:23,820 if you want to be able to build 994 00:44:23,820 --> 00:44:26,960 a wireless remote control application. 995 00:44:27,540 --> 00:44:30,880 Philips Sony RC5 protocol is explained in AVR 410. 996 00:44:31,400 --> 00:44:33,140 It is similar to a soft UART, 997 00:44:33,160 --> 00:44:35,380 except it uses biphase or Manchester encoding 998 00:44:35,380 --> 00:44:37,640 where there is a transition on every bit time. 999 00:44:37,960 --> 00:44:40,620 That means that a high to low transition is a zero. 1000 00:44:40,780 --> 00:44:42,120 A high to low transition with the transition 1001 00:44:42,120 --> 00:44:43,460 in the middle of the bit is a zero. 1002 00:44:43,560 --> 00:44:44,560 A low to high is a one. 1003 00:44:44,900 --> 00:44:46,740 The reason you do this is because it is easier 1004 00:44:46,740 --> 00:44:49,200 to spot transitions than long runs of constant value, 1005 00:44:49,440 --> 00:44:51,100 especially in a medium like IR. 1006 00:44:51,860 --> 00:44:54,300 It also means that the signal is self-clocking. 1007 00:44:54,500 --> 00:44:57,340 You don't have to maintain clock synchronization 1008 00:44:57,340 --> 00:44:58,480 over many bit times. 1009 00:44:59,240 --> 00:45:01,300 It takes an input from an external IR diode 1010 00:45:01,320 --> 00:45:03,700 and the IR diode is actually available on this board. 1011 00:45:05,580 --> 00:45:07,140 And then the RC5 framing, 1012 00:45:07,360 --> 00:45:09,300 and they get into this in the data sheet, 1013 00:45:09,380 --> 00:45:10,260 but I just wanted to mention it, 1014 00:45:10,320 --> 00:45:12,220 is two start bits, which are always ones, 1015 00:45:12,320 --> 00:45:14,260 a control bit, which is toggled every time 1016 00:45:14,260 --> 00:45:15,600 any particular button is pressed, 1017 00:45:15,900 --> 00:45:18,380 five address bits, because of course you want 1018 00:45:18,380 --> 00:45:20,540 two to the fifth devices to control with your remote, 1019 00:45:21,520 --> 00:45:23,580 and six command bits, because of course 1020 00:45:23,580 --> 00:45:24,580 you've got that many devices. 1021 00:45:24,940 --> 00:45:26,160 What do you have to say to that many? 1022 00:45:27,320 --> 00:45:28,860 And then the small parallel example 1023 00:45:28,860 --> 00:45:29,920 is a stepper motor controller. 1024 00:45:29,920 --> 00:45:31,800 And I include this because there was actually 1025 00:45:31,800 --> 00:45:34,760 a lot of interest in doing servo designs 1026 00:45:34,760 --> 00:45:36,980 at last year's talk, and stepper motors 1027 00:45:36,980 --> 00:45:39,460 are really nice because once you understand 1028 00:45:39,460 --> 00:45:40,780 what they're doing, they're fairly easy, 1029 00:45:40,960 --> 00:45:42,780 they are open loop control mechanisms 1030 00:45:42,780 --> 00:45:45,100 that are still deterministic. 1031 00:45:45,120 --> 00:45:47,160 If you try to run a DC motor and you turn it on 1032 00:45:47,160 --> 00:45:50,400 for one second, you have no idea how many times 1033 00:45:50,400 --> 00:45:52,540 it's gone around, and you can gear it way down, 1034 00:45:52,660 --> 00:45:54,320 but you still don't know exactly how far you've moved. 1035 00:45:54,540 --> 00:45:56,660 With stepper motors, as long as you don't overload them, 1036 00:45:57,060 --> 00:45:59,300 they have moved as many steps as you've clocked, 1037 00:45:59,300 --> 00:46:01,440 and so it's open control loop. 1038 00:46:01,500 --> 00:46:02,560 You don't need an encoder on the shaft, 1039 00:46:02,640 --> 00:46:03,680 but you still know where the thing is. 1040 00:46:04,460 --> 00:46:07,260 For a unipolar stepper motor, the control is trivial. 1041 00:46:07,400 --> 00:46:09,680 For a dual polar, you actually have the possibility 1042 00:46:09,680 --> 00:46:11,380 of building a software-destroyable system, 1043 00:46:11,500 --> 00:46:13,060 and I'll talk about that in just a second. 1044 00:46:13,580 --> 00:46:15,840 A unipolar drive is commonly called 1045 00:46:15,840 --> 00:46:17,980 a six-wire stepper motor, where you've got 1046 00:46:18,460 --> 00:46:22,380 a center tap on each of two coils in the magnet, 1047 00:46:22,460 --> 00:46:23,500 and then you've got the end taps, 1048 00:46:23,680 --> 00:46:26,020 and you want to turn on one or the other end tap 1049 00:46:26,020 --> 00:46:28,740 to change the polarity on either of the coils. 1050 00:46:28,740 --> 00:46:33,680 There is a datasheet that I reference here at Ericsson, 1051 00:46:33,780 --> 00:46:35,900 which is a great introduction to stepper motor control. 1052 00:46:36,240 --> 00:46:38,380 I just swiped some diagrams from them, 1053 00:46:38,460 --> 00:46:40,580 and if you're interested in building a servo, 1054 00:46:40,660 --> 00:46:43,160 I'd recommend you go there and look at it. 1055 00:46:43,580 --> 00:46:45,900 If you're using a bipolar, you have a coil. 1056 00:46:46,040 --> 00:46:47,180 It's a four-wire stepper motor, 1057 00:46:47,320 --> 00:46:53,500 and you want to be able to reverse the polarity across the coil. 1058 00:46:53,760 --> 00:46:55,960 So what you do is you build what's called an H-bridge driver, 1059 00:46:56,160 --> 00:46:56,940 and if you look at this, 1060 00:46:56,940 --> 00:47:00,200 the alternate corners of the H-bridge are controlled by the same bit, 1061 00:47:00,240 --> 00:47:03,060 so it's still only four control bits required for an H-bridge, 1062 00:47:03,220 --> 00:47:04,020 but if you look at it, 1063 00:47:04,060 --> 00:47:05,880 you'll also notice a really nasty failure mode. 1064 00:47:06,760 --> 00:47:11,280 If you turn on both sets of switches on any H-bridge, 1065 00:47:11,520 --> 00:47:15,580 you suddenly have a very low impedance path from VCC to ground, 1066 00:47:15,700 --> 00:47:20,040 and the thing will emit light, smoke, or fire, 1067 00:47:20,180 --> 00:47:22,860 depending on how much power you're putting into it. 1068 00:47:24,680 --> 00:47:26,260 So what if you want more I.O.? 1069 00:47:27,660 --> 00:47:29,700 Well, then you may want to look at other parts. 1070 00:47:29,740 --> 00:47:31,700 What are you doing with an 8-pin part if you want more I.O.? 1071 00:47:31,700 --> 00:47:34,100 But if you are some kind of sadist, 1072 00:47:35,040 --> 00:47:37,800 you can use serial-to-parallel shift registers, 1073 00:47:38,040 --> 00:47:42,860 and in fact, there's some examples of this in really old LED signboards, 1074 00:47:43,100 --> 00:47:47,420 where they actually control a large multi-hundred LED array 1075 00:47:47,940 --> 00:47:49,360 with essentially two pins 1076 00:47:49,860 --> 00:47:51,620 by just shifting everything out into shift registers, 1077 00:47:51,880 --> 00:47:55,280 and then if you want your transitions on these shift registers to be clean, 1078 00:47:55,340 --> 00:47:56,860 make sure to use one with output latches, 1079 00:47:56,940 --> 00:47:59,260 and then it takes a third pin because you've got to clock the output latch, 1080 00:48:00,380 --> 00:48:04,300 but you can chain these things together and have an arbitrary number of I.O.s, 1081 00:48:04,320 --> 00:48:06,320 but the parts are so cheap for the larger parts, 1082 00:48:06,400 --> 00:48:08,360 you might as well just use a larger controller. 1083 00:48:09,020 --> 00:48:11,840 How do I blah for anything I have failed to mention here? 1084 00:48:11,980 --> 00:48:14,000 And there is an infinite number of things I've failed to mention here. 1085 00:48:14,380 --> 00:48:14,980 Hit the web. 1086 00:48:15,640 --> 00:48:18,120 If you search, you'll be amazed that there's... 1087 00:48:18,120 --> 00:48:20,660 Chances are, if you've got a great idea, someone else has already built it, 1088 00:48:20,700 --> 00:48:21,940 or at least has thought about building it. 1089 00:48:22,240 --> 00:48:26,020 Also, the manufacturer application notes, as you may have gotten an idea from my presentation, 1090 00:48:26,020 --> 00:48:28,380 provide a lot of good reference designs. 1091 00:48:29,240 --> 00:48:33,020 Often, if you look at manufacturers of parts that aren't the one you're working on, 1092 00:48:33,660 --> 00:48:36,180 you will find someone who's doing it on some other part, 1093 00:48:36,380 --> 00:48:38,460 and then you can port it over to your architecture of choice, 1094 00:48:38,540 --> 00:48:41,060 or change parts, depending on how agnostic you are. 1095 00:48:41,200 --> 00:48:42,980 You know, maybe there's a reason they chose a PIC, 1096 00:48:43,060 --> 00:48:45,540 or maybe there's a reason they chose an 8051, or some other part. 1097 00:48:46,480 --> 00:48:49,640 Or finally, if you don't find what you're looking for, create your own. 1098 00:48:49,720 --> 00:48:51,180 And please, share it with the world, 1099 00:48:51,240 --> 00:48:55,220 because that's how the next guy who goes out looking on the web finds your project. 1100 00:48:56,180 --> 00:48:58,740 If you're looking for a starter book, 1101 00:48:59,620 --> 00:49:01,300 the kit is the hardware you need. 1102 00:49:01,460 --> 00:49:05,500 The kit doesn't provide a good first-order reference. 1103 00:49:06,380 --> 00:49:07,180 I finally... 1104 00:49:07,180 --> 00:49:09,020 Last year, a lot of people were asking for a book, 1105 00:49:09,100 --> 00:49:11,460 and there's a book called Get Going with AVR by Peter Sharpe. 1106 00:49:11,520 --> 00:49:16,240 It's written in British, so it's got a few strange words in it, 1107 00:49:16,320 --> 00:49:18,080 but it's a really good explanation. 1108 00:49:18,200 --> 00:49:19,860 It starts at very low-level stuff, 1109 00:49:20,280 --> 00:49:22,880 and it will explain to you what binary is, 1110 00:49:22,960 --> 00:49:24,620 but it gets past that by about page four. 1111 00:49:24,620 --> 00:49:28,460 And then it really does get into some interesting applications. 1112 00:49:28,720 --> 00:49:30,520 It shows you how to make good use of the hardware. 1113 00:49:30,900 --> 00:49:33,580 It's designed around a slightly different Canda development board, 1114 00:49:33,720 --> 00:49:35,700 but you should be able to make the transition fairly painlessly. 1115 00:49:36,600 --> 00:49:38,920 Do read the documentation for this stuff, 1116 00:49:39,000 --> 00:49:41,100 because there are some quirks to the STK100. 1117 00:49:42,600 --> 00:49:44,740 The control device, which is the... 1118 00:49:44,740 --> 00:49:46,280 There's actually a microcontroller on there 1119 00:49:46,280 --> 00:49:50,160 that it uses to send the code to your device through. 1120 00:49:50,560 --> 00:49:52,460 It's basically an in-system program controller. 1121 00:49:52,740 --> 00:49:54,420 It actually controls the... 1122 00:49:54,620 --> 00:49:56,720 the voltage that the processor runs at. 1123 00:49:56,840 --> 00:49:58,720 And it took me the longest damn time to figure this out. 1124 00:49:59,900 --> 00:50:01,800 In spite of looking at the schematics, 1125 00:50:01,900 --> 00:50:03,840 I was really embarrassed that I could not figure out 1126 00:50:03,840 --> 00:50:05,460 why the thing would run three times faster 1127 00:50:05,460 --> 00:50:07,240 when it was in run mode than in program mode 1128 00:50:07,240 --> 00:50:08,760 until I realized three. 1129 00:50:09,180 --> 00:50:11,500 Three. One megahertz, 350 kilohertz. 1130 00:50:11,700 --> 00:50:15,080 This sounds like the RC oscillator running at three volts. 1131 00:50:15,380 --> 00:50:15,820 Duh. 1132 00:50:16,940 --> 00:50:19,860 Also, the ISP software requires Intel hex files, 1133 00:50:20,000 --> 00:50:21,640 which is not the default of AVR Studio. 1134 00:50:22,360 --> 00:50:24,180 This was also the source of... 1135 00:50:24,640 --> 00:50:26,560 far more wasted time than it should have been for me. 1136 00:50:26,780 --> 00:50:28,940 So it's embarrassing, but I admit it here to... 1137 00:50:28,940 --> 00:50:31,840 to remind you that make sure the files you're generating... 1138 00:50:31,840 --> 00:50:33,500 Because I had generated one hex file, 1139 00:50:33,600 --> 00:50:34,720 generated one output file, 1140 00:50:34,920 --> 00:50:38,260 and then had failed to save that change to the AVR Studio. 1141 00:50:38,420 --> 00:50:39,620 So I could never figure out why my code, 1142 00:50:39,700 --> 00:50:40,720 no matter how I would change it, 1143 00:50:40,780 --> 00:50:42,260 didn't ever get better. 1144 00:50:42,680 --> 00:50:44,800 And it turns out I was downloading the same image 1145 00:50:44,800 --> 00:50:46,060 into the... into the part repeatedly. 1146 00:50:48,760 --> 00:50:49,160 Then... 1147 00:50:49,780 --> 00:50:50,980 chance for me to drink some water? 1148 00:50:58,440 --> 00:50:58,800 Okay. 1149 00:50:59,540 --> 00:51:01,480 I like to close these with an inspirational message. 1150 00:51:01,840 --> 00:51:02,940 And one of the things I always say, 1151 00:51:03,020 --> 00:51:04,480 like any... like any good project, 1152 00:51:04,560 --> 00:51:06,240 the hard part of these is getting started. 1153 00:51:06,400 --> 00:51:08,120 And this year I added the caveat that you should cheat 1154 00:51:08,120 --> 00:51:09,460 by starting with someone else's work. 1155 00:51:10,300 --> 00:51:11,540 Or... or a trivial example. 1156 00:51:13,080 --> 00:51:15,660 And I... I have some trivial examples I'm happy to give you. 1157 00:51:16,860 --> 00:51:19,360 I've got a very few minutes left in the talk, 1158 00:51:19,420 --> 00:51:23,060 so I'm probably not going to... to do a demo of the dev studio. 1159 00:51:23,060 --> 00:51:24,060 It's... it's pretty straightforward. 1160 00:51:24,240 --> 00:51:26,200 It's available online at the Atmel website for free. 1161 00:51:26,260 --> 00:51:27,480 I would encourage you to go take a look at it. 1162 00:51:27,660 --> 00:51:29,040 Even if you don't have the starter kit, 1163 00:51:29,140 --> 00:51:30,180 you can at least play with the simulator. 1164 00:51:31,400 --> 00:51:32,700 Start small and work up from there. 1165 00:51:32,780 --> 00:51:33,940 Be willing to make... make mistakes, 1166 00:51:34,160 --> 00:51:36,560 because that's... like I said, 1167 00:51:36,640 --> 00:51:38,100 I've tried to share my mistakes here, 1168 00:51:38,280 --> 00:51:39,800 but if you do something stupid, 1169 00:51:39,940 --> 00:51:41,260 at least you will only do it once. 1170 00:51:42,020 --> 00:51:42,340 Hopefully. 1171 00:51:43,820 --> 00:51:45,160 And then... and then get involved. 1172 00:51:45,320 --> 00:51:46,320 Join the community of developers. 1173 00:51:46,480 --> 00:51:48,380 There's a lot of people who are interested in this stuff. 1174 00:51:48,540 --> 00:51:50,480 And no matter how retarded your project is, 1175 00:51:50,580 --> 00:51:52,140 there's probably at least one other person on Earth 1176 00:51:52,140 --> 00:51:53,040 who thinks it's as cool as you. 1177 00:51:55,600 --> 00:51:59,360 So, to recap, microcontrollers, 1178 00:51:59,360 --> 00:52:00,240 a different development opportunity. 1179 00:52:00,660 --> 00:52:02,980 Gone over some of the characteristics of the AVR, 1180 00:52:03,040 --> 00:52:04,520 specifically the ATtiny11. 1181 00:52:04,840 --> 00:52:06,480 We've looked at a lot of example functions, 1182 00:52:06,600 --> 00:52:07,800 and then I've put the fun... 1183 00:52:07,800 --> 00:52:09,040 It's just fun to tinker with these. 1184 00:52:09,120 --> 00:52:10,480 It's neat to make blinking lights. 1185 00:52:11,740 --> 00:52:14,780 And then now is the chance to win the development environment. 1186 00:52:15,100 --> 00:52:16,800 I'll go into QA mode in just a second, 1187 00:52:16,940 --> 00:52:18,900 but if you would like to submit feedback, 1188 00:52:19,040 --> 00:52:20,660 I would... I would strongly encourage you 1189 00:52:20,660 --> 00:52:22,280 to give me feedback if you... 1190 00:52:22,280 --> 00:52:22,860 if you have... 1191 00:52:23,060 --> 00:52:23,560 a pen and paper. 1192 00:52:23,740 --> 00:52:25,820 If you don't, ask... ask the guy next to you. 1193 00:52:26,240 --> 00:52:27,760 Please write down your name or handle. 1194 00:52:28,200 --> 00:52:30,460 If you win one, it will be at the bellhop desk 1195 00:52:30,460 --> 00:52:32,140 with your name or handle on it in an hour. 1196 00:52:33,280 --> 00:52:34,800 Because I've got to read the project ideas. 1197 00:52:36,000 --> 00:52:37,800 Tell me what I should change about this talk. 1198 00:52:38,020 --> 00:52:41,040 If... if there's anything you would have liked to see more of, less of, 1199 00:52:41,900 --> 00:52:44,180 please tell me what... what I could do differently next year 1200 00:52:44,180 --> 00:52:44,960 if I... if I come back. 1201 00:52:45,840 --> 00:52:47,320 What, if anything, you liked about it. 1202 00:52:47,360 --> 00:52:48,320 This is less important to me, 1203 00:52:48,380 --> 00:52:51,140 but I ask this merely so I don't take out something good. 1204 00:52:51,820 --> 00:52:54,680 And then the important question for getting the development kit 1205 00:52:54,680 --> 00:52:55,960 is why do you want an STK100? 1206 00:52:56,140 --> 00:52:57,180 What's your cool project idea? 1207 00:52:57,500 --> 00:52:59,060 The feedback is important to me, 1208 00:52:59,160 --> 00:53:01,280 but the kits are awarded based on the project idea. 1209 00:53:01,440 --> 00:53:03,780 So even if you tell me I'm stupid, ugly, and I suck, 1210 00:53:04,140 --> 00:53:05,460 but you have a good project idea, 1211 00:53:05,560 --> 00:53:06,260 you will win a kit. 1212 00:53:07,420 --> 00:53:09,060 And like I said, winners can pick up theirs 1213 00:53:09,060 --> 00:53:10,280 at the bellhop desk out front. 1214 00:53:10,420 --> 00:53:11,760 It's the thing out in front of the... 1215 00:53:12,140 --> 00:53:14,020 It's... it's outside where you can check your bags, 1216 00:53:14,140 --> 00:53:16,140 and I will just stick your name on it and check it there. 1217 00:53:16,960 --> 00:53:19,740 And... and I'll try to post a list of the winning handles, 1218 00:53:19,860 --> 00:53:21,120 and I will get... 1219 00:53:21,120 --> 00:53:22,440 I'll give away any I don't give away here. 1220 00:53:23,480 --> 00:53:24,720 If you want to contact me, 1221 00:53:24,800 --> 00:53:27,780 my email address, pking at pkscientific.com, 1222 00:53:28,480 --> 00:53:32,140 and the... the subtle implicit plug for my not-an-agent jackets, 1223 00:53:32,260 --> 00:53:33,740 which I'm not selling at the moment anyway, 1224 00:53:34,220 --> 00:53:36,920 the website for this talk is notanagent.com, 1225 00:53:37,780 --> 00:53:40,160 and the slides and some of the examples 1226 00:53:40,160 --> 00:53:41,400 will be available on there shortly. 1227 00:53:41,560 --> 00:53:42,100 I'm also... 1228 00:53:42,100 --> 00:53:44,200 If you have other things you'd like me to add to the website, 1229 00:53:44,340 --> 00:53:45,360 please feel free to send them along. 1230 00:53:45,980 --> 00:53:49,900 There's an AVR web ring I may or may not add the site to, 1231 00:53:50,700 --> 00:53:51,100 but... 1232 00:53:51,120 --> 00:53:53,540 but there's a lot of project rings that you can find 1233 00:53:53,540 --> 00:53:54,680 if you just look around. 1234 00:53:54,880 --> 00:53:56,320 It's... it's a very fertile... 1235 00:53:57,000 --> 00:53:58,840 very fertile environment online. 1236 00:53:59,920 --> 00:54:01,220 So, Q&A. 1237 00:54:01,900 --> 00:54:04,400 Are there any general microcontroller questions, 1238 00:54:04,780 --> 00:54:05,880 AVR-specific, or... 1239 00:54:05,880 --> 00:54:08,560 or who wants to try and win something with a project idea? 1240 00:54:13,080 --> 00:54:14,360 Oh, sorry, yeah. 1241 00:54:15,560 --> 00:54:16,380 Hold on. 1242 00:54:17,920 --> 00:54:18,960 Yeah, that's... 1243 00:54:18,960 --> 00:54:20,040 that's the information I'm looking for 1244 00:54:20,040 --> 00:54:20,660 in terms of feedback. 1245 00:54:21,680 --> 00:54:22,560 Was there... 1246 00:54:22,560 --> 00:54:23,200 Yes. 1247 00:54:24,160 --> 00:54:24,680 Yeah. 1248 00:54:24,780 --> 00:54:25,260 Sorry, you. 1249 00:54:25,960 --> 00:54:27,600 For a project idea... 1250 00:54:27,600 --> 00:54:28,200 Project idea. 1251 00:54:28,460 --> 00:54:29,240 I have a little ambition. 1252 00:54:29,780 --> 00:54:32,860 Trying to take a basic Ethernet chip set, 1253 00:54:33,780 --> 00:54:36,300 somehow get it worked into a whole situation 1254 00:54:36,840 --> 00:54:40,800 and have a very basic, you know, kind of frame set of memories, 1255 00:54:40,960 --> 00:54:43,040 and then a simple type of keyboard interface 1256 00:54:43,040 --> 00:54:47,020 to input, you know, maybe an arbitrary UIC address 1257 00:54:47,020 --> 00:54:48,600 into the source, nothing too much. 1258 00:54:48,600 --> 00:54:50,840 And that way you could, you know, 1259 00:54:50,840 --> 00:54:52,000 plug it into a network. 1260 00:54:52,580 --> 00:54:53,880 A little bit smaller. 1261 00:54:54,040 --> 00:54:57,100 And then maybe your favorite IP and IP packet 1262 00:54:57,100 --> 00:55:00,640 would be good for an arbitrary host 1263 00:55:00,640 --> 00:55:03,500 and to an arbitrary destination. 1264 00:55:04,600 --> 00:55:06,260 A very small spam bot, 1265 00:55:06,320 --> 00:55:07,940 or IP storm bot. 1266 00:55:08,340 --> 00:55:10,880 So, his idea was an IP... 1267 00:55:11,880 --> 00:55:13,660 an IP packet spewer 1268 00:55:13,660 --> 00:55:14,960 based on a microcontroller 1269 00:55:14,960 --> 00:55:17,020 where you precompute the frame 1270 00:55:17,020 --> 00:55:18,080 and have it sitting in memory, 1271 00:55:18,080 --> 00:55:20,280 and have the thing hooked up to an Ethernet controller. 1272 00:55:22,480 --> 00:55:23,940 Hooking up to an Ethernet controller 1273 00:55:23,940 --> 00:55:26,300 is a few more pins than we have here, 1274 00:55:26,460 --> 00:55:28,320 but you could probably do it 1275 00:55:28,320 --> 00:55:30,140 with a couple of 8-pin ports. 1276 00:55:30,300 --> 00:55:32,580 What you've described in part is the PicoWeb. 1277 00:55:32,640 --> 00:55:34,380 I don't know if anyone is raising their hand 1278 00:55:34,380 --> 00:55:34,840 to mention this. 1279 00:55:34,920 --> 00:55:38,240 There actually is an AVR 1280 00:55:38,240 --> 00:55:43,380 to an ISA Ethernet controller device. 1281 00:55:43,680 --> 00:55:45,400 It's not designed to spew out packets 1282 00:55:45,400 --> 00:55:46,500 as fast as you want to. 1283 00:55:46,500 --> 00:55:48,660 It's designed to actually be a complete web server. 1284 00:55:48,960 --> 00:55:53,900 But let's get an audience approval rating. 1285 00:55:54,020 --> 00:55:55,840 Does a packet storm generator 1286 00:55:56,300 --> 00:55:58,220 based on a microcontroller and an Ethernet chip 1287 00:55:58,220 --> 00:55:59,500 merit a development box? 1288 00:56:00,400 --> 00:56:01,640 Yes? No? Yes? 1289 00:56:02,020 --> 00:56:02,800 Show of hands. 1290 00:56:02,860 --> 00:56:03,880 Everyone who thinks he should get one? 1291 00:56:06,720 --> 00:56:07,800 Everyone who doesn't? 1292 00:56:08,220 --> 00:56:09,320 Clock rate problems. 1293 00:56:10,020 --> 00:56:11,220 Clock rate problems. 1294 00:56:12,900 --> 00:56:14,140 Even at 10 megabits, 1295 00:56:14,180 --> 00:56:15,220 your 1 megahertz processor 1296 00:56:15,220 --> 00:56:17,260 is going to run fast enough 1297 00:56:17,260 --> 00:56:18,060 to spew those out. 1298 00:56:18,340 --> 00:56:20,020 But it might be running fast enough 1299 00:56:20,020 --> 00:56:21,760 if you've got an Ethernet controller 1300 00:56:21,760 --> 00:56:22,960 with onboard memory 1301 00:56:22,960 --> 00:56:23,800 to at least tell it, 1302 00:56:23,840 --> 00:56:24,520 send that frame again. 1303 00:56:25,320 --> 00:56:26,780 So for what it's worth, 1304 00:56:26,940 --> 00:56:30,100 I will at least concede 1305 00:56:30,100 --> 00:56:31,200 that you could build it. 1306 00:56:31,280 --> 00:56:33,880 Is there anyone speaking in his defense? 1307 00:56:34,580 --> 00:56:35,540 I have a solution 1308 00:56:35,540 --> 00:56:38,360 that will make this idea work. 1309 00:56:38,660 --> 00:56:39,740 A solution, okay. 1310 00:56:39,960 --> 00:56:41,620 We have a hardware 1311 00:56:41,620 --> 00:56:42,900 that we've got to keep that 1312 00:56:43,520 --> 00:56:45,760 so we can interface with SPI 1313 00:56:47,140 --> 00:56:51,280 and just use clock data. 1314 00:56:52,680 --> 00:56:54,420 Okay, it's a three-wire interface 1315 00:56:54,420 --> 00:56:57,440 to a hardware-based IP stack, 1316 00:56:57,560 --> 00:56:57,940 did you say? 1317 00:56:58,160 --> 00:56:58,460 Exactly. 1318 00:56:58,840 --> 00:57:00,360 Okay, well, so that makes it work. 1319 00:57:00,660 --> 00:57:02,160 You can actually look at a reference design 1320 00:57:02,940 --> 00:57:04,180 at ireddy.org. 1321 00:57:04,400 --> 00:57:05,760 So a reference design for that 1322 00:57:05,760 --> 00:57:07,080 available at ireddy.org. 1323 00:57:07,400 --> 00:57:09,420 So, okay, it sounds like it's going to work. 1324 00:57:09,460 --> 00:57:10,760 I think I'm going to give it to him. 1325 00:57:17,640 --> 00:57:18,500 Hold on a sec. 1326 00:57:18,560 --> 00:57:19,260 Could you hand that back? 1327 00:57:22,820 --> 00:57:23,960 Yeah, it's a big green box. 1328 00:57:24,040 --> 00:57:24,600 We can see it. 1329 00:57:27,640 --> 00:57:28,320 Okay, yes. 1330 00:57:31,980 --> 00:57:33,320 A single-key keyboard. 1331 00:57:54,100 --> 00:57:56,660 A single-key keyboard 1332 00:57:56,660 --> 00:57:59,380 for going from Morse code to AT 1333 00:57:59,900 --> 00:58:02,000 so that you can use it while driving 1334 00:58:02,000 --> 00:58:03,360 or roller skating. 1335 00:58:07,740 --> 00:58:09,900 I think that's a winner, yeah. 1336 00:58:10,520 --> 00:58:12,380 Let me recommend you use power 1337 00:58:12,380 --> 00:58:14,220 a lot faster than a single-key. 1338 00:58:15,900 --> 00:58:17,360 And if you're really ambitious 1339 00:58:17,360 --> 00:58:18,860 and want to stick four buttons on it, 1340 00:58:18,900 --> 00:58:20,960 you could do a nibble-based Cordic keyboard. 1341 00:58:30,340 --> 00:58:32,320 I always neglect the people in the back. 1342 00:58:32,420 --> 00:58:35,780 Let me try and find someone in the back. 1343 00:58:36,800 --> 00:58:38,420 See, the people in the back always get screwed. 1344 00:58:38,420 --> 00:58:41,600 You, the guy in the white. 1345 00:58:41,760 --> 00:58:42,960 Is that Free Geek? 1346 00:58:43,420 --> 00:58:45,760 Is that a label or a command? 1347 00:58:47,120 --> 00:58:47,720 Okay. 1348 00:58:48,200 --> 00:58:49,920 So, okay. 1349 00:58:54,420 --> 00:58:55,020 . 1350 00:58:57,320 --> 00:58:57,920 . 1351 00:58:57,920 --> 00:58:58,600 . 1352 00:58:58,600 --> 00:58:58,740 . 1353 00:58:58,740 --> 00:58:59,480 . 1354 00:58:59,480 --> 00:58:59,580 . 1355 00:58:59,580 --> 00:58:59,640 . 1356 00:59:03,280 --> 00:59:03,880 . 1357 00:59:03,880 --> 00:59:04,220 . 1358 00:59:05,020 --> 00:59:05,620 . 1359 00:59:05,620 --> 00:59:05,660 . 1360 00:59:05,660 --> 00:59:05,880 . 1361 00:59:05,880 --> 00:59:05,980 . 1362 00:59:06,940 --> 00:59:07,540 . 1363 00:59:07,540 --> 00:59:07,680 . 1364 00:59:07,680 --> 00:59:07,740 . 1365 00:59:07,740 --> 00:59:08,020 . 1366 00:59:08,020 --> 00:59:08,360 . 1367 00:59:08,360 --> 00:59:08,620 . 1368 00:59:08,620 --> 00:59:09,340 . 1369 00:59:17,160 --> 00:59:17,680 . 1370 00:59:20,060 --> 00:59:20,580 . 1371 00:59:20,580 --> 00:59:20,800 . 1372 00:59:20,800 --> 00:59:20,880 . 1373 00:59:20,880 --> 00:59:20,900 . 1374 00:59:20,900 --> 00:59:21,640 . 1375 00:59:21,640 --> 00:59:21,660 . 1376 00:59:21,660 --> 00:59:21,720 . 1377 00:59:24,600 --> 00:59:25,120 . 1378 00:59:28,520 --> 00:59:29,040 . 1379 00:59:29,040 --> 00:59:29,560 . 1380 00:59:29,560 --> 00:59:29,600 . 1381 00:59:29,600 --> 00:59:29,660 . 1382 00:59:29,660 --> 00:59:29,800 . 1383 00:59:29,800 --> 00:59:30,060 . 1384 00:59:30,060 --> 00:59:30,360 . 1385 00:59:38,360 --> 00:59:42,740 The trouble that leaps to mind is at least with the minimal I.O., 1386 00:59:42,740 --> 00:59:45,680 you're going to get one stepper motor, so you're going to have one degree of freedom, 1387 00:59:45,880 --> 00:59:47,900 which is a fairly limited robotic arm. 1388 00:59:48,580 --> 00:59:51,880 I'm going to be cruel and throw this one entirely to the audience, 1389 00:59:52,000 --> 00:59:53,680 and this time I'm actually going to listen to what they say. 1390 00:59:54,660 --> 00:59:58,280 Who thinks the robotic arm control for a tape farm should get it? 1391 01:00:01,080 --> 01:00:01,920 And not? 1392 01:00:04,180 --> 01:00:05,020 I'm sorry. 1393 01:00:06,260 --> 01:00:07,300 Submit a feedback form. 1394 01:00:09,180 --> 01:00:09,580 What? 1395 01:00:11,000 --> 01:00:12,100 Yeah, that's what eBay is for. 1396 01:00:13,660 --> 01:00:17,340 And another thing I would point out is if you get out of here and you've submitted a feedback form 1397 01:00:17,340 --> 01:00:22,740 and you still don't get one, call up Atmel and sound either really smart or really pathetic, 1398 01:00:22,900 --> 01:00:27,340 and there's a good chance that they will send you one, 1399 01:00:27,400 --> 01:00:28,420 especially if you're a student. 1400 01:00:28,920 --> 01:00:33,860 Ask to speak to the university liaison because they do like to get these things into schools, 1401 01:00:34,340 --> 01:00:36,400 or if you can just say you're a student. 1402 01:00:38,460 --> 01:00:40,540 Okay, the guy with both hands up in the gesture cap. 1403 01:00:42,540 --> 01:00:44,120 We've got a current budget going. 1404 01:00:44,260 --> 01:00:48,740 We're using the BS2SA, and we're using the DCMS app, 1405 01:00:48,780 --> 01:00:52,340 along with the voice recording app, 1406 01:00:52,940 --> 01:00:58,320 and we've got it hooked into a phone line where it'll dial the number and everything. 1407 01:00:58,760 --> 01:01:01,420 When the pulse beats drop and the other end picks up, 1408 01:01:01,600 --> 01:01:06,920 it'll automatically send a recording message and say whatever, 1409 01:01:07,100 --> 01:01:08,340 and that's it. 1410 01:01:18,920 --> 01:01:22,360 So it's an answering machine that calls out for you. 1411 01:01:28,340 --> 01:01:32,520 He's using DTMF and an external voice recorder chip to dial out 1412 01:01:32,520 --> 01:01:34,900 and wait for the other end to pick up and record. 1413 01:01:35,020 --> 01:01:36,140 Am I basically getting it right? 1414 01:01:42,860 --> 01:01:47,080 Okay, and it'll respond to DTMF tones from them. 1415 01:01:50,240 --> 01:01:54,260 A social engineering or telemarketing tool. 1416 01:01:54,980 --> 01:01:55,540 Okay. 1417 01:01:58,460 --> 01:01:59,460 Throwing it to the audience. 1418 01:01:59,620 --> 01:02:00,320 Does he get one? 1419 01:02:02,140 --> 01:02:03,180 Oh, I'm sorry. 1420 01:02:03,260 --> 01:02:04,040 Hostile crowd. 1421 01:02:05,800 --> 01:02:06,540 All right. 1422 01:02:07,440 --> 01:02:08,340 I'm pleased. 1423 01:02:08,360 --> 01:02:09,380 Am I just about out of time? 1424 01:02:09,740 --> 01:02:11,140 How much longer can I go? 1425 01:02:11,340 --> 01:02:13,060 Well, I haven't had any word of the next speaker. 1426 01:02:13,440 --> 01:02:14,020 That'd be me. 1427 01:02:14,520 --> 01:02:14,880 Okay. 1428 01:02:15,440 --> 01:02:15,960 There he is. 1429 01:02:16,180 --> 01:02:17,580 So we've got the next speaker. 1430 01:02:17,760 --> 01:02:20,060 We've got five minutes over, so I guess it's at his discretion now. 1431 01:02:20,120 --> 01:02:22,540 Okay, so I'm pretty much running out of time. 1432 01:02:22,580 --> 01:02:23,340 I'm going to take one more. 1433 01:02:24,220 --> 01:02:28,120 And again, the guy sort of toward the back in the blue cap. 1434 01:02:29,080 --> 01:02:29,440 Yeah. 1435 01:02:29,800 --> 01:02:30,160 Yeah. 1436 01:02:37,260 --> 01:02:38,120 Could you speak up? 1437 01:02:38,360 --> 01:02:44,640 I caught a link between a Game Boy and a PC with a link port. 1438 01:02:44,740 --> 01:02:45,140 Oh, okay. 1439 01:02:45,220 --> 01:02:48,540 Using the link port on the Game Boy Advance and basically building glue between that and a PC? 1440 01:02:52,480 --> 01:02:52,840 Ah. 1441 01:02:54,400 --> 01:02:54,760 Okay. 1442 01:02:54,860 --> 01:03:06,020 So would you be running games on the Game Boy or using the Game Boy as a terminal for the PC? 1443 01:03:14,120 --> 01:03:21,700 Okay, so it's a development project for basically the Game Boy as a console. 1444 01:03:22,760 --> 01:03:23,280 I don't know. 1445 01:03:23,340 --> 01:03:23,900 It sounds kind of cool. 1446 01:03:25,500 --> 01:03:26,940 What's the consensus? 1447 01:03:27,980 --> 01:03:28,660 All in favor? 1448 01:03:30,320 --> 01:03:31,100 All in favor? 1449 01:03:32,240 --> 01:03:33,120 All opposed? 1450 01:03:34,920 --> 01:03:37,700 Okay, the hostile people are less adamant. 1451 01:03:38,520 --> 01:03:39,340 I think you get one. 1452 01:03:39,540 --> 01:03:40,740 Can you come on up here at the end? 1453 01:03:40,940 --> 01:03:44,840 And if everyone could just bring feedback forms if you've got them up to me. 1454 01:03:44,980 --> 01:03:46,900 I'm going to wrap it up now so the next guy can speak. 1455 01:03:47,080 --> 01:03:48,160 But thank you very much. 1456 01:03:48,180 --> 01:03:48,880 You've been a great audience. 1457 01:03:49,460 --> 01:03:49,960 Thank you. 1458 01:03:50,020 --> 01:03:51,540 Thank you. 1459 01:03:51,700 --> 01:03:51,980 Thank you. 1460 01:03:53,380 --> 01:03:53,660 Thank you.