11 ms·
PSA: If you're a fan of ATmega, try AVR Dx
- genter 2y agoOr, you can get an stm32g0 for $2, which is faster, has a modern 32 bit cpu, and has more powerful peripherals.
- Rinzler89 2y agoBut what if I don't need all that. What if the AVR is better for some of the uses cases? Or if you already have code for AVR/Arduino.
- bigiain 2y agoI often use Arduino (or AT Mega/Tiny) purely for it's 5V and very robust GPIO pins. I can short circuit an Arduino pin for days, or (attempt to) pull 3 or 4 times the rated current from them - and they just keep on rocking. I've even accidentally hit them with 7.2V or even 12V on the GPIO and not had them let the magic smoke out. You only have to look sideways past a 5V rail at as RasPi to kill it, and ESP aren't a heap better. If I can get all the code I need onto an Arduino/AVR, I'll use one. If I need more complex code than I can run on an Arduino but still need GPIO (especially anything 5V tolerant) I'll use an ESP or RasPi (or some other Linux SOC board) with an Arduino (or other AVR) for GPIO. At least for the prototyping stage when I'm using breadboards and moving wires around - if I'm building something permanent (or at least semi permanent) I'll sometimes build a version 2 with level shifters to deal with 3.3-5V stuff, but mostly only once I've got to the "prototype that's got to the PCB stage" iterations. I've almost never killed an Arduino, but I've killer too many RasPis and way way too many ESPs.
- cantours 2y agoPretty much all ICs these days have builtin ESD protection which usually involves current steering diodes to supply rails. So if you limit the input current (typically <5mA, and assuming the steered-to rail uses at least 5mA to sink it) it will survive any voltage. (Of course if it's a low power design or the device is off this wont work that well, then you want external clamping) I have tested 24V AC applied to an stm32f0 pin with a 10K series resistor and it survives that indefinitetly.
- contingencies 2y agoI have tested 24V AC applied to an stm32f0 pin with a 10K series resistor and it survives that indefinitetly. Which mode was the pin in? I'm not an STM person but my understanding is that most MCU pins are tri or at least multi-mode, if you have the wrong mode set it's effectively isolated. Edit: Can't reply to child. Schmitt trigger circuitry is disabled if pin is in analog mode or is an ADC pin according to https://www.st.com/resource/en/datasheet/stm32f071cb.pdf https://www.st.com/resource/en/datasheet/stm32f071cb.pdf page 59 .. could affect sensitivity ... perhaps there exist other mode-related influences, too.
- cantours 2y agoInputs which is the default in f0 series. Structure is: esd cell -> optional pull ups/down -> schmitt trigger.
- kragen 2y agoin most cases diode clamping to the rails is still active though? and that's what sinks those 2.4 milliamps and keeps your gate oxides from avalanching. i think the stm32 datasheet only guarantees withstanding 0.5 milliamps of such 'injection current' per pin there do exist cmos chips with pins without input clamping diodes but they are rather exotic usually
- GianFabien 2y agoI've spent years working with TTL so 5V is just more convenient. Besides USB is 5VDC as well. When breadboarding, more than once I've mixed up 3.3V and 5V domains with dire consequences - always on the 3.3V side. Unless I really need WiFi, I prefer to go with ATmega. Once you get used to writing structured assembly language, you can get so much more functionality fit within flash memory.
- genter 2y agoA lot of the pins on STM32 are 5 volt tolerant (and almost all of them are on the smaller devices).
- genter 2y agoUntil you design and solder up a PCB with $50 worth of parts, then discover the timers can't do what you needed them to do. (Ask me how I know). If you're a hobbyist, the STM32 has so much more functionality, and I've wasted so much time trying to get the underpowered AVRs to work, I'll never touch them again.
- dragontamer 2y agoThat seems a bit weird of a complaint. All of these chips have devboards in the order of $20. Surely you could have built a code prototype with a devboards before designing up a PCB? In the embedded world, timers are very specifically designed. Yeah, TimerA is more flexible and maybe you needed more of that, but the less flexible TimerB on AVR is more power efficient (like 1/3rd the power or something). So TimerB has it's other uses. (Really, I'd say TimerB is specialized at frequency counting tasks but is less good at PWM or other "output" tasks. So TimerB is kind of an "input timer") And TimerD is this weird behemoth that I don't understand yet. But someone probably used it for something good out there... -------- But given the nature of TimerA vs TimerB vs TimerD (as well as the knowledge that TimerA is on different pins than TimerB), surely that should have cued you into the point that you should prototype your design? Don't lock down your PCB until you have idea of what wires should go to which pins. And part of that process is deciding if TimerA vs TimerB vs TimerD was what you needed.
- dragontamer 2y ago> and has more powerful peripherals. I severely doubt that. On a G0? AVR DB has 3x OpAmps. AVR EA and AVR EB have a x16 gain differential amplifier on the ADC (!!!). The peripherals on the AVR Dx and AVR Ex series are just out-of-this-world good. And unlike ESP32, the ADC has good linear qualities and reasonable accuracy. ------ Even the "runt" of the bunch, the AVR DD (fewest features / cheapest price) has an Event System and Programmable Logic. You get ~4x 3-LUTs + 2x 1-bit memory that can perform operations on your inputs before the AVR Core/CPU even wakes up. In fact, there's a sample demo of AVR Programmable Logic + AVR Event System (which is a "router" to tie inputs and outputs more flexibly. Its not a perfect router but its better than nothing) + ties it to AVR Timers, so that a quadrature-encoder could be offloaded outside of the core. https://ww1.microchip.com/downloads/en/AppNotes/00002434A.pdf https://ww1.microchip.com/downloads/en/AppNotes/00002434A.pd... -------- STM32 G0-series is somewhat comparable to AVR DD in that the STM32 G0-series is "barebones". But the AVR DD's "barebones" has more features than STM32 G-series. Now STM32 G0 has a lot more SRAM and MHz. But peripherals? Peripherals is where the PIC and AVR series shines. The only competitor to peripherals is like... TI's new MSP M0 line (which also ships with 1 to 3 OpAmps... zero-drift / chopper OpAmps to boot). If you want a comparable 32-bit processor, I'd go to TI MSP M0 (also ARM but TI is adding an event-system, OpAmps, and other nice low-level peripherals that are familiar to the AVR Dx users) -------- STM32 does have OpAmps / Event Systems and all that good stuff. But they're locked to the more expensive G4 series. ------- Ultimately, STM32 and AVR Dx aren't competing in the same league. AVR Dx is more of a competitor to your I2C ADCs or simple logic (now that AVR Dx and Ex have Four 3-LUTs, you have a surprising amount of glue-logic available that can take the place of old 7xxx chips). PIC and AVR core sucks. Its all about the peripherals. (Well.... AVR and PIC are also absurdly power-efficient. In part because of how well designed the peripherals are)
- throwaway81523 2y agoYeah these are cool, there is a bunch of info on SpenceKonde's github pages, https://github.com/SpenceKonde/DxCore https://github.com/SpenceKonde/DxCore
- andrewstuart 2y agoThere's actually tons of really interesting microcontrollers of every size and shape. Many of them are available as dev boards for under $20. You can burn plenty of hours and dollars browsing all the good stuff on electrodragon at https://www.electrodragon.com/product-category/dev-board/ https://www.electrodragon.com/product-category/dev-board/
- ThrowawayTestr 2y agoIf anyone wants to get into hobby electronics, please just go on AliExpress. It has everything and it's way cheaper.
- RecycledEle 2y agoI've ordered from Ali Express, but a few day to a few weeks later I get a message from someone who has not shipped my item and thinks my order and payment was the first step in a negotiation. Can you please tell me how to deal with Ali Express sellers? I have several hundred dollars of embedded systems parts on order from Chinese eBay sellers right now.
- ssl-3 2y agoWith AliExpress, my orders never feel like a negotiation. I put stuff in the cart, eventually push the "buy this stuff" button, give them money, and stuff eventually shows up -- just as with other e-commerce sites for decades. Sometimes it's slower (months), and sometimes it's stupid-fast (a few days), but outside of things like Chinese New Year the sellers generally seem to be very prompt at handling the orders and getting things into the delivery stream. I've come to expect most things to show up in a couple of weeks (at least here in the States). I'm not doing anything particularly weird, I don't think. My order history consists of almost entirely of small electronics (sometimes components, sometimes populated PCBs) and 3D printer parts, from dozens of different sellers.
- waynesonfire 2y ago
- watermelon0 2y agoI generally use ESP32 nowadays, since most things I do benefit from having WiFi connectivity, but I have fond memories of using AVR microcontrollers in the past. For hobbyists, AVR (ATmega, ATtiny) microcontrollers were really great. Easy to use in C for most cases, great cross-platform toolchain, and many of them came as DIP package, which made them breadboard/protoboard friendly. Heck, we even had a USB 1.1 library, that could bitbang USB 1.1 on practically any AVR, including 8-pin ATtiny: https://www.obdev.at/products/vusb/index.html https://www.obdev.at/products/vusb/index.html Not to mention, that Arduino started with ATmega, and still have many board featuring it. I definitely might check Dx line, just to see if the experience is the same as it was before.
- guitarbill 2y agoI'm a bit torn. While there's something nice about the simplicity of an 8-bit device and DIP packages, I've come to enjoy ARM's Serial Wire Debug, and ARM tooling. Definitely don't miss avr-gcc and avrdude. In a way, it's ironic. The AVR tooling back in the day was just so much better than PIC (for a novice hobbyist, pre-Arduino).
- aldami 2y agoAh, the good old days where computers had a serial port and you could assemble an AVR programmer on a breadboard to flash an AVR and build a USB programmer.. Programmer bootstrapping ? But you're right, the tooling has come a long way. The proliferation of ARM in so many domains means lowly microcontrollers can benefit, as opposed to being bound by the manufacturer or community size. Hopefully RISC-V will improve this even further.
- SomeoneFromCA 2y agoThe simpest AVR programer, widely used in ex-USSR was called "5 wires" and consisted of 5 wires, ic-socket and 25 pin connector for the parallel port.
- crest 2y agoThree resistors and a parallel port?
- hashtag-til 2y ago> Hopefully RISC-V will improve this even further. In was more hopeful in past then I'm now with the RISCV ecosystem. The issue there is fragmentation, so it's not RISCV... every vendor will have their tooling because they'll be adding their secret sauce that they wont be sharing with everyone else, which is a shame.
- clumsysmurf 2y ago> The AVR tooling back in the day was just so much better than PIC I'm disappointment MPLAB X Ide only supports x86 Macs. Also, release 6.20 was Jan 2024 so the release cycles are pretty long... doesn't inspire confidence.
- ThrowawayTestr 2y agoDoes it have Arduino support?
- blutack 2y agoSee also the CH32V003 [0] (more expensive variants also available), a neat, cheap and standalone RISC-V with plenty of modern & flexible peripherals, good package options, single wire debug and an open toolchain [1] for ~20c per. Mitxela has a great article on them [2] and I totally agree they have a lot of the same joy & simplicity of the ATTiny - but with the added bonus of lots of interesting DMA controller misuse! The peripherals have a very STM feel (in a good way) which perhaps isn't surprising given WCH's history. 0: https://www.wch-ic.com/products/CH32V003.html https://www.wch-ic.com/products/CH32V003.html 1: https://github.com/cnlohr/ch32v003fun https://github.com/cnlohr/ch32v003fun 2: https://mitxela.com/projects/badge https://mitxela.com/projects/badge
- janekm 2y agoCame to say this too... I was really pleasantly surprised by how easy it was to get a full dev & build & test environment set up with Visual Studio Code, and how well their little WCH-LinkE debugger works (both SWD and UART in one, Segger could learn from that...). Now I'm experimenting with their BLE variant, which is a lot more complex, but still simpler than what I'm used to.
- sircastor 2y agoI just stumbled onto these recently. The big hang up for me is that the programmer is proprietary. I was hoping there would be a bootloader onboard like the CH552. No dice. In waiting a bit more than a week to get one shipped. They’re not expensive, but I’m annoyed that I can’t just load some software on an Arduino and flash the chip. (Note you can debug open source, just not program afaict)
- snvzz 2y agoAVR was cool, but I have moved on to RISC-V (ch32v, esp32c...).
- contingencies 2y agoChina prices are still double the old chips, with very limited availability (single digit volume for 2-3 models only). I trust China prices. If it aint there, it aint real.
- violet13 2y agoI don't understand what you mean. These chips are available in bulk from the manufacturer and from all major distributors worldwide. Why would you want to go through China? These chips aren't even manufactured there. The fab is in Thailand. If you mean a PCBA shop, Mouser or DigiKey can ship your order directly to your favorite PCBA place.
- contingencies 2y agoThe wisdom of the crowd can be substantial in supply chain. That is to say, for non-trivial projects, selecting any kind of component which may not be immediately available in arbitrary quantities represents a huge project risk. The numbers currently available in China show that the chips' position in the market is too early days / small volume to be considered a viable development target given the fact that the world center of electronics production is yet to see enough aggregate demand to stock more than a handful. Now if you want to develop against a chip on a 10 year outlook, go for it. But if you want to get work done this week, or this month, or even this year, I'd argue that the distribution is too premature to make that a smart decision.
- dragontamer 2y agoChina is full of counterfeits though. I don't actually expect those chips in China to be legitimate. Its public information that these chips are made in Taiwan or other locations, so Chinese supply is pretty equestionable. I can order 3000+ from Microchip's website right now for any of the AVR Dx series. And Microchip has decades-long reputation of a solid supply chain, even in the 2020 COVID19 period when STM32 got issues. -------- The older chips are fully obsolete compared to these modern designs. The newer AVR DD is cheaper, faster, loses the Voltage-slowdown issue (1.8V is only qualified for like 4MHz on ATMega328. 1.8V on AVR DD can go full 24MHz), etc. etc. I don't see any reason why anyone would ever choose the decades-old ATMega328 when AVR DD is right here, cheaper and better in every conceivable way. One exception: if you really need the ATMega328 pinout _exactly_ because you can't change the PCB or update the electronics, I can understand legacy issues. But new projects should pretty much switch to AVR Dx or AVR Ex (depending on your project's needs, since the different chips specialize in different purposes). Ditto for legacy software because ATMega328 peripherals are older. (Modern TimerA and TimerB are much better than ATMega328's legacy Timer0 and Timer1)
- buserror 2y agoHaven't played with these yet, but they do look interesting. Might have also to add support for the new IO blocks in my AVR simulator simavr[0] -- I still use the AVR a lot, since they have no pipeline and other fancy CPU optimization, they are 'cycle accurate' and are a lot closer to a PIO than most other more complex 32 bit CPUs.. Now that they ALSO have an equivalent to PIO it might even help with reaching faster IO speed when toggling pins. [0]: https://github.com/buserror/simavr https://github.com/buserror/simavr
- lloydatkinson 2y agoPICs have had these CPU independent logic blocks for a while too so it makes sense they ported the idea to AVR too. I don’t remember exactly how many “things” you can do with them in comparison to PIO though. Probably a lot less, as it’s pure gates and not a set of extra instructions like PIO.
- SomeoneFromCA 2y agoI want my AT90S2313 back. The best most versatile AVR imho of its era.
- _benj 2y agoI have worked with DD and have some DA laying around. The UPDI is a very nice and simple programming interface. All that it takes is a USB-UART and a diode or a resistor (I used a diode) to connect between RX/TX. I didn’t used ATmega a lot, but comparing the experience to MSP430 and EFM8 the AVR chip has a bunch of niceties, superb documentation and life improvements like, in order to clear some registers all one need to do is write 1 instead of the whole =& ~(REG | 0x8) (or something like that, it’s been a while since I write embedded C) The other thing that I loved is that one can download headers for the chip directly from the manufacturer! Way too many chip manufacturers keep locking headers/libraries behind their proprietary IDEs, but Microchip, even though they have an IDE let’s you download the headers so one can use whatever tooling one is comfortable with! Props to Microchip for that!!
- lloydatkinson 2y agoHow’s debugging and breakpoints for these?
- Mister_Snuggles 2y ago> life improvements like, in order to clear some registers all one need to do is write 1 instead of the whole =& ~(REG | 0x8) (or something like that, it’s been a while since I write embedded C) This is a really interesting feature since it addresses a shortcoming of the C language (inability to easily express bit set/clear) by introducing a new hardware feature.
- garaetjjte 2y ago
- deleted 2y ago[deleted]
- newswasboring 2y agoThis unlocked such fond memories, I'll buy some just to make some LEDs blink. I am glad my first exposure to embedded systems was through ATmega series, not for the chip, but the user's manual. That is perhaps the only manual I have read cover to cover, that thing took me to knowing rudimentary electronics to actually understanding a full system. The first real world system I could hold fully in my head, and that was an amazing feeling. Who ever wrote that, hats off. I remember then encountering the ARM manual which had similar clarity of writing. Were there like professional writers for these things?
- smallpipe 2y agoYes.
- lloydatkinson 2y agoWould Rust for AVR work with these too I wonder?
- blueflow 2y agoYes. Its the same architecture.
- dotdi 2y agoI started working with Microcontrollers when 80C51s were still somewhat modern, and I remember how frustrating the toolchain and the general experience was. When AVR came out with their ATmegas, it was a revelation. Not having to use shitty proprietary programmers and windows-only software was amazing. We could finally use Linux. PIC was one of the main competitors in our circles, but it was losing the foothold quickly, because the AVR tooling was just hands-down better. Also, documentation was easier to read and interpret, especially compared to PIC, which is still giving me slight PTSD when I try to recall how hard it was to get non-mainstream features to work. Whenever I had to deep-dive PIC documentation I stumbled over weird behaviour or outright hardware bugs that, in some cases, could not even be worked around. I don't actively work with microcontrollers nowadays, but I am excited to hear that AVR is still making an effort to have an objectively good product. The market is tough nowadays, with ESP32s and ESP8266s being so cheap and widespread, but I hope AVR keeps it up.
- violet13 2y agoVery few hobby designs that use more capable chips actually need more capable chips, and the added complexity - hardware and software - often bites hard. That said, wifi is a major selling point, and you need a beefy 32-bit computer to run the protocol. This is the brilliance of ESP32: you can actually use it just as a wifi dongle for another microcontroller, but since it needs so much computing power, might as well give you some RAM and CPU to do your thing directly on the wifi chipset...
- t0mas88 2y agoThe ESP32 is very overpowered for random home projects. But the cost is low, and they can be used with the Arduino ecosystem which is very beginner friendly. Often the ESP32 is far cheaper than whatever sensor you're making it monitor. WiFi isn't the perfect technology to upload sensor data in the home, but anything proper Zigbee is more expensive and more complex to use. So the ESP32 ends up in all kinds of projects.
- gothroach 2y ago
- megous 2y agoLooks like a modern PIC with swapped out MCU core. Probably nothing to miss if you use PIC already.
- ndiddy 2y agoSounds like a great improvement to me, the 8-bit PICs have great peripherals and are easy to use but the CPU cores are garbage (slow 4T architecture, no hardware stack, bank switching necessary, forced to use Microchip's proprietary compiler instead of GCC).
- dragontamer 2y agoAVR gives up on core/SRAM and instead offers incredible peripherals. While AVR DA, DB, DD, EA, and EB chips can serve as replacements to ATmega (albeit with new pinouts), the newer chips are a completely different ballgame. AVR DB has 3x OpAmps for free. AVR EA and EB have differential 12-bit ADCs with programmable 1x to 16x gain. We're not just talking about measuring 4mA to 20mA protocol easily, but you can measure uA of current with reasonable accuracy with just a shunt-resistor + the AVR EA's ADC. AVR DD has a dual power-supply with 1.8V to 5V support. That means that some pins can be on 3.3V logic while other pins are on 5V logic. IE: The AVR DD's job is to be a built-in full-and-proper level shifter. Bonus points: All modern AVR chips (Dx and Ex) have an event-system to route events from any peripheral (Timers, Pins, UART, etc. etc.) to many other pins and even interrupts to the CPU. This combines with the CCL programmable logic unit (Four 3-LUTs + two 1-bit memory cells) to have an incredible amount of "glue logic" built into these chips. Anyone who comes in this topic and talks about "But 32bit whatevers", ESP32 or about super-cheap RISC-V chips is missing the point of the AVR line. You're not really the ones in the market for this chip. Anyone who has to deal with a cheap design that manipulates a bit of analog sensors, or glue together logic... well... AVR is the right chip for these jobs. ---------- There's one problem. It means that you need to know the ins-and-outs of the peripherals that are offered on these chips. AVR DD cannot do the same current-measuring job that an AVR EA or AVR EB can do. Mixed-signal Peripherals are so much harder to understand than MHz and SRAM. But for those who are "in the know", well... these are awesome peripherals. Its difficult to find competitors to these chips. Indeed, a proper bidirectional 3.3V to 5V level shifter across 28 I/O pins alone would probably cost you more than the $1-ish AVR DD. 3x Rail-to-Rail OpAmps with programmable voltage-reference, a DAC and differential ADC is a *bargain* for the AVR DB's $2 price point. --------- And the whole line offers like 5V and 50mA in/out on the GPIO. Its an extremely forgiving chip. The fun trick is to run Resistor+LED directly off of GPIO because... you can. (Typical LEDs are 20mA).
- kragen 2y agoi feel like the ch32v003 might plausibly be the right chip for these jobs, even though it's risc-v, because it's so much cheaper than the avrs. as a bonus, it's made by a chinese company, so you can use it even in contexts where foreign hardware isn't allowed (this has become a big deal as the usa has started ramping up its sanctions) in theory it's 12¢ each at lcsc, but it's out of stock, so that's only theoretical: https://www.lcsc.com/product-detail/Microcontroller-Units-MCUs-MPUs-SOCs_WCH-Jiangsu-Qin-Heng-CH32V003J4M6_C5346354.html https://www.lcsc.com/product-detail/Microcontroller-Units-MC... it's not competitive with the expensive avrs when it comes to mixed-signal peripherals and 1.8-volt support, but it does have some tasty stuff. you get 3.3 to 5 volts, a 10-bit adc (1.7 megasamples per second with a ±2% bandgap reference), and an op-amp (so you can do differential input to the adc and set its gain), a basic set of digital peripherals, and that's about it. that's still better than an atmega328 or an stm32f103 but not in the same league as the stuff you're talking about i haven't actually tried the chips myself, so i don't know if they're all they're cracked up to be, but except for a fatal problem with the spi peripheral in the smaller packages, other people seem to report good success, even without speaking chinese: https://hackaday.com/tag/ch32v003/ https://hackaday.com/tag/ch32v003/ in this price range, there's also the arm puya py32, and of course the padauk chips with their redoubtable multithreading so you can do your i/o from a separate hardware thread instead of from interrupt handlers
- JoeCortopassi 2y agoIf you are a hobbyist reading all this, and trying to compare it to arduino or raspberry pi, do yourself a favor and buy one of these: https://www.adafruit.com/product/5325 https://www.adafruit.com/product/5325 $12, fantastic documentation and tutorials, and you can literally just plug it in via usb and edit the python code as if it's just a text file on a thumb drive. No programmers, special IDE's, or specialty equipment Microcontrollers are fun again
- cellularmitosis 2y agoThank you for highlighting this — I hadn’t realized how far the lower end of the price range had advanced since the days of cheap Pro Micro clones. 240MHz, 2MB ram, 4MB flash, circuit python —- this is incredible for $12, and from Adafruit no less!
- HeyLaughingBoy 2y agoThen take a look at the RPi Pico. All of the above at an even lower price point: I think I bought 3 for $12. Only thing missing is wireless, which you can get in the Pico-W.
- schmookeeg 2y ago+1! the Picos have been an absolute joy to work with, and take me back to my C coding start from.. gosh.. 38 years ago. :) Mix in some I2C components and a few jumper wires, and you basically have my whole childhood distilled down and reborn -- legos and code.
- Cheer2171 2y agoThe only thing the Pico-W beats the ESP32 on is power consumption. ESP32 costs the same as Pico non-wireless. ESP32 has double the clock speed, ram, and flash, plus wifi and Bluetooth, at the same price. Plus ESP32 has a huge ecosystem of software and hardware, the same way the original big Raspberry Pis are much easier to develop on. Pico ecosystem isn't nearly as big.
- beryilma 2y agoI regularly use both atmega328p (Arduino Uno) and stm32g0 (st-nucleo boards) microcontrollers for hobby projects. The linux toolchain for both are equally good. But the Nucleo boards are a lot cheaper than Arduino Uno/Mega boards, have a lot more capabilities, any are 32-bit microcontrollers. I am actually fascinated with the things you can do with stm32 chips. If I ever do a commercial project, I would definitely use stm32 chips. Bare metal programming them has been a lot of fun.
- hi-v-rocknroll 2y agoThe key points of marketing and executing a successful a MCU are: 0. simplicity 1. robustness 2. developer support 3. essential features