Hacker News new | past | comments | ask | show | jobs | submit login

Or, you can get an stm32g0 for $2, which is faster, has a modern 32 bit cpu, and has more powerful peripherals.



> 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.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)


But 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.


I 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.


Pretty 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.


I 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 page 59 .. could affect sensitivity ... perhaps there exist other mode-related influences, too.


in 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


Inputs which is the default in f0 series. Structure is:

esd cell -> optional pull ups/down -> schmitt trigger.


I'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.


A lot of the pins on STM32 are 5 volt tolerant (and almost all of them are on the smaller devices).


Until 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.


That 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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: