Microcontroller programmin in 2019

Hi, I'm fairly new to the world of microcontrollers, have had a dip a few years ago with arduino and quickly switched to standalone then stopped and now starting again.

I really just want a clarification as what i'm currently doing looks like it might be an outdated process.

I currently have an atmel atmega328p on a breadboard hooked up to a 5V regulator and avrispmk2 (an a crystal) and that's how the guide i'm following is telling me to do things (minus the crystal which i assume is included in the programmer they are using)

I'm not new to programming so there seem to be a lot of things here that i believe would already have been improved in this modern world like the requirement for the crystal should be in the programmer and the power supply could be as well.

So my question is, am I using an outdated process or is it how this is done?

PS: I'm not a fan of abstraction layers of the arduino language type and wanted to code in C directly

fANZY:
minus the crystal which i assume is included in the programmer they are using

Far for likely is that they have the configuration fuses set so that the internal oscillator of the microcontroller is being used for a clock source.

fANZY:
the requirement for the crystal should be in the programmer

Why? Then you would never be able to use the project without having the programmer connected. It is true that there are some "Arduino as ISP" style sketches that provide a clock signal. However, the reason for this is because if you accidentally set the configuration fuses on the microcontroller for an external clock source, but you have no external clock connected, then the microcontroller is effectively "bricked" because it can't run without a clock. Many Arduino beginners won't already have a crystal and load capacitors sitting in a parts stash and so they would be blocked from further progress waiting for those parts to show up in the mail. So the clock source provided by these sketches allows you to recover from that situation.

fANZY:
and the power supply could be as well.

Most ISP programmers do have a voltage output you can use to power the target microcontroller. The AVRISP mkII is the only one I know of without. The AVRISP mkII has the neat feature of automatically detecting the appropriate logic level voltage of the target and adjusting its levels accordingly. The people who need that sort of thing would generally not want the programmer to provide an arbitrary power supply voltage, since there might components on the board that are not compatible with that voltage.

fANZY:
So my question is, am I using an outdated process or is it how this is done?

That's how it's done.

fANZY:
PS: I'm not a fan of abstraction layers of the arduino language type and wanted to code in C directly

Good for you. There's nothing stopping you from doing that, even if you are using the Arduino IDE.

Most ISP programmers do have a voltage output you can use to power the target microcontroller. The AVRISP mkII is the only one I know of without.

It seems pretty common for “pro” programmers to “sense” power, rather than provide power. As you say, this gives them the ability to work with boards designed with different supply voltages.
Pickit4 and Milan SNAP both do this (and don’t provide power.). I think Atmel ICE and Dragon as well...

Good information westfw.

I don't have any experience with the expensive or non-AVR/non-avrdude programmers other than the AVRISP mkII. I'm always making do with the cheapskate stuff from eBay. I'm surprised I plunked down the cash for a real Atmel AVRISP mkII from Digikey back when I first started with Arduino. I've barely used the thing, and I hit both of the big headaches that only happen with that programmer right away, so I certainly didn't get my money's worth out of it. Well, maybe it's a collector's item now that they no longer make the real ones?

Well i found some info about using the internal oscillator and set the fuses to E:FD, H:99, L:62 by mistake thinking these were the default ones but these were for another chip.

I have another chip but this one wont work either with the crystal or without. Any idea how i can read the fuse bits or event change their values when avrdude is returning

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1

https://www.avrfreaks.net/forum/tutsoft-recovering-locked-out-avr

It looks like you've set the "enable debugWire" fuse, which is one of the more difficult things to recover from... :frowning:

See also AVR® Fuse Calculator – The Engbedded Blog

Yeah i figured. That's fine i know now :slight_smile: I bounght some more and now that i know what's the deal with the crystal I guess there'll be less not knowing what's going on and more actual prototyping

On another note, any up to date guide on microcontroller programming that's not using arduino? Currently following the "Make: AVR Programming"

any up to date guide on microcontroller programming that's not using arduino?

You should definitely read AVRFreaks.net (despite the name, this is/was one of Atmel's official forums...)

And probably look for tutorials on Microchip.com. Since they've introduced a bunch of new chips with slightly different architectures recently (including the ATmega4809 used on Uno Wifi2 and Nano Every), I'd imagine that they're working pretty hard to attract "professionals." Tutorials "aimed at professionals" can range from incomprehensibly complex to insultingly simple (and the frequent "sales pitch"), but most should be in the range that is useful to someone who wants to step beyond Arduino programming.
(although ... a common theme might be "learning C, if you're an experienced AVR Asm programmer", which can be a be weird...)
Here are some: https://www.youtube.com/playlist?list=PL9B4edd-p2agO7oNwuk47f5peA98Nueda
(also watch out for tutorials that might be essentially obsolete. Probably don't install "winavr", for example.)