Right 16MHz crystal for ATMEGA328

I'm trying to do bare bone ATMEGA328 from this tutorial: Blinking led with Atmel studio – hdhprojects

I don't know fuses, I select arduino pro -> 5V 16MHz ATMEGA328 on arduino ide and hope it put them right? Also I skipped bootloader as I send sketch directly to board -> chip does work if put on UNO board (yay ^^)

But of course, it didn't work on bread board. I started to look bit more help and there was a lot stuff about fuses and full swing oscillators and stuff.

I used HC49/4H: https://www.mouser.fi/datasheet/2/445/830003240B-2005173.pdf and I dont have any idea is that fullswing...

I dont know where to even start looking for? everything else seems to be ok, but oscillator was easiest to start.

Let's see a schematic of what you have built.

As I have never done anything with resonators / oscillators, I followed tutorial physical connections as closely as possibly to see if its working (used that schematics:

only exception was 9,x kOhmh resistor to pull reset up, but that should be close enough.

Yeah, I always use 10k but 9k2 would work fine.

Can you post a photo of the physical layout?

I'm missing something rather essential int he schematic though: the power supply decoupling capacitors. They should be present on both Vdd pins and preferably on Aref as well. Use 100nf.

Sometimes with a non-starting ATmega it helps to put 100nF or 470nF between RST and GND so there's a brief delay in RST going high giving the power supply the possibility to stabilize before the ATmega starts.

Ill do when I get home.

I do have somewhat stable "lab power". but could try that capasitor between GND and reset

Don't forget those decoupling capacitors. Not having them is bad practice and can result in problems. Refer to the ATMega328 datasheet for design considerations and search for the Microchip/Atmel application note on crystal oscillator layout.

This resonator works for ATMEGA328 (I've tried it) and has inbuilt capacitors for the (resonant impedance I think its called?) micro processor clock. Might make life easier.

Sure, but there's no reason any generic 16MHz crystal with appropriate load capacitors wouldn't work. The ATMega328 isn't very iffy about resonator choice. The 22pF capacitors used by OP are likely just fine.

Nick Gammon (gammon.au) has thorough tutorial on bare-boarding 328.
Definitely worth a read.

Always an excellent tutorial, but you really have to wonder "what's the point"?

Sure it gives you a warm feeling to do it (as the saying goes), but negligible practical advantage when a Pro Mini (clone) is ready to go, compact, reliable and in general, cheaper.

I would agree that the economic and neatness arguments probably win, and I do use clones, but personally, spending a couple of hours with a raw chip, burning a bootloader and flashing an LED was satisfying and educational.
I don't always want all the facilities of a development board and incorporating a raw chip into a project is sometimes better. Plus I've got a stash of ready to go 328's, bootloaded for my Uno boards when one gets too hot.

Sure, I overdid everything, new crystal and 22pF caps. Led has 330ohm resistor (~9mA)

and closeup

Ill check that out

Edit: wtf, it worked, I measured blinking voltage on pin 19... my led was "broken", I gave it DC Voltage up to 5V and it didnt burn at all, then it flashed and started to "work"... (its flickkering :smiley:

Sounds like a good result :slight_smile:

I do admit it gives nice feel to do... but chip 2,06€, crystal 0,24€ and 2 capasitors 0,22€, total is 2,52 € + tax, so lets say 3,12€, and then you need some extra stuff around it. 4€?
I think you can get pro mini around 3€ so it seems to be cheaper.

But for example I had china nanos and I fight with them around 2 weeks because I didn't seem to get serial data working, it worked on leonardo but immediate I put it on nano, it was able to only send data -> it had ch340 chip that had so low impedance input so it eated my RS data... wasnt cheap to use china copy when normal nano should work.

my case space isn't broblem, but current is, I had to remove leds anyway because they increase load

I've never noticed any problems with the ch340 requiring a very low impedance signal line. Yes, I've had my fair share of problems with ch340g's in custom/diy pcb's, but the issue you mentioned doesn't seem to be among them.

yeah, me neither, but I found (german) conversation about that, it was connecting siemens 5WG1117-2AB12 to arduino. normal nano or copy pro mini works (one based on leonardo) (I heard, didnt test)

quote from forum was: "Because the CH340G and BCU are connected to the same pins, they interfere with each other. Workaround: there are 2x 1k resistors that lead from CH340 to D0 and D1, if you solder them away, the BCU works again, but you can no longer program via USB (then only via ISP or with an external USB-to-UART adapter): /"

I did solder ch340g off from board, but didnt have time to test does it work after that (I was idiot and took chip off from empty board, and not one that had code already :slight_smile:

That's not exactly the same as an impedance mismatch. It might have to do with it, but it's not necessarily the case. Since Serial is intended to link exactly two nodes together, as soon as you start using it as a proper bus with more than two nodes, you're evidently on your own. Complaining about problems with using products in ways they aren't intended to be used is kind of, well, moot.

Hmm, not sure did I get that right. It does just serial link from nano rx/tx to siemens, there isnt "other devices" in that line. and atmega328 alone works perfectly, or leonardo.

Edit: uno works too if you keep second icsp reset & gnd jumpered so U3 stays "off"

Ok, I missed that; I thought the CH340G, Siemens and a host PC were sharing the same pair of tx/rx lines. Having looked at the product flyer of the 5WG1117-2AB12, I'm a bit confused. It mostly looks like a wall outlet for data lines. I.e., it's not an actual node/device in a serial connection; it's basically just a connector. Moreover, it's intended for Siemens' Gammabus, apparently a 24V powered proprietary bus with 5V and/or 12V data lines. I see nothing about it being intended for serial as we use it in a microprocessor environment. In the post you quoted from the German forum, it's also not clear what kind of infrastructure was used besides this particular wall outlet.
So...lots of unknowns, but also lots of indications that this is still a case of "let's use device A intended for purpose B and use it instead for application C".

of course you cant see it without opening package, but that has tpuart chip in it : TPUART2 the next generation
it says:
• Signaling for standard UART
• Baud rate 9600 or 19200 baud:TPUART2 >< Host - Controller
• Baud rate 115200 or 19200 baud:TPUART2+ >< Host - Controller
• Direct coupling to host controller (TxD, RxD)

its just its way easier to buy that siemens "full packet", than those invidual SMD uart + knx chip and do same thing by yourself