SAMD21 implementation questions

Hello there,

first I want to mention that I'm not a noob what comes to programing or electronics, so please take that in consideration while making a post (mentioning this just to save time).

In my project I want to upgrade from ATMEGA32U4 to ATSAMD21G18A. Purpose of this MCU is to emulate HID/Serial and do a bit more heavy calculation for other stuff (thats why I'm upgrading).

With ATMEGA32U4 out of the box keyboard emulation and serial works just fine (with default Ardino IDE "KeyboardSerial" example). I haven't received any SAMD21 boards yet and can't test it, so I would be really grateful if someone that have tested it share their opinion about this chip and HID+serial.

What is the cheapest/fastest way to burn bootloader on it?
I didn't find any info in datasheet that pins can handle 5V logic so it's only a 3v3 logic chip?

My project IO requirements:
2 * I2C ports
SPI (optional)
7 digital output pins
9 digital input pins (ideally 5V tolerant)

Cheapest (QFN48, 32K/4K) will do, I can squeeze IO and use QFN32, but due to only 4 cent different it's not worth to use less IO chip.

Do Atmel and Microchip versions have any differences that I should know?

I found this minimal configuration schematic, is it right?

Thanks in advance.

Hey :wink:
I will try to answer some of your questions.
Some of the questions are showing that you are not familiar with electronics. Be careful and ask, when you are not sure what you are doing.

What is the cheapest/fastest way to burn bootloader on it?

One really easy way is with ISP, for this you need an ISP programmer

I didn't find any info in datasheet that pins can handle 5V logic so it's only a 3v3 logic chip?

This is right, it is a 3V3 logic chip. For other voltage level you may need level shifter/translator. That can change the 3V3 to 5V logic. Otherwise you will damage the chip.

Do Atmel and Microchip versions have any differences that I should know?

The pinout could be different. But you have to look into the data sheets. When you are not familiar with reading data sheets, you should not do this project.

I found this minimal configuration schematic, is it right?
  • For the reset you will need a pull-up resistor. It will not work like this. Put 10k between reset and 3V3.
  • What is connected to the 1uF cap?
  • You should add a ferrite (470Ohms@100MHz) for VDDANA

Really, you come to my thread and write "you should not do this project"?
Really? Guess where in my opinion you should go and what you should do to yourself :wink:
You should go and do that.

read more carefull :wink:
I said what your skills should be, when doing this.
And I tried to help you :slight_smile:

No, you just came and tried to look like a smart ass and dumped a pile of crap while ignoring my first line.
You can go, you have saved the day already, don't forget to bow down and don't let doors hit you while you leave :wink:

sorry when I was getting you upset. This was not my intention.
It is the right way to ask, when you don't know things.
So I will help you again, when you have any questions. :slight_smile:

You still here? You are not finished still? Need a toilet paper after? :grinning:
I'm not upset at all, I am rather amused of your insolence.
I will listen to you, I will not do this upgrade, I will dispose that project entirely, PCB design, working prototypes, I will burn everything cos of you, thanks for your honest help, you solved all my issues 8)

The nerve of this dude...

3Dgeo:
With ATMEGA32U4 out of the box keyboard emulation and serial works just fine (with default Ardino IDE "KeyboardSerial" example). I haven't received any SAMD21 boards yet and can't test it, so I would be really grateful if someone that have tested it share their opinion about this chip and HID+serial.

It should work fine, but unfortunately it seems there is an issue with HID in the newest version of Arduino SAMD Boards. I have reported it here:

Using the previous production release (1.6.21), it works fine.

3Dgeo:
What is the cheapest/fastest way to burn bootloader on it?
I didn't find any info in datasheet that pins can handle 5V logic so it's only a 3v3 logic chip?

I have been on a quest to find the cheapest programmer for these chips for a little while now.

I started by using an Arduino board as a programmer following these instructions:

No luck for me, but another forum member reports it did work for them (possibly after some modification to Adafruit's sketch):

I then tried using one of the ST-Link V2 clones sold on eBay and Adalink:
[url=http://https://github.com/adafruit/Adafruit_Adalink]GitHub - adafruit/Adafruit_Adalink: Python wrapper for Segger's J-Link Commander & STMicro STLink V2 to flash various ARM MCUs
No luck. I had read some reports that it wouldn't work, despite Adafruit's claims that it does:
burn arduino zero's bootloader to SAMD21 with STlink_v2 - #20 by westfw - Microcontrollers - Arduino Forum

I'm now waiting for a J-Link clone I bought from Aliexpress and will give that a try with Adalink.

It seems like after the J-Link, things are getting much more expensive. I'd be interested to hear of other options. I can afford to pay more, but I'd like to find the cheapest reliable solution because I think that would be helpful information to be able to share with users who managed to erase the bootloader on their Arduino board and are just looking for a fix, and then maybe never use the programmer again.

Rudeldi:
The pinout could be different.

I would be very surprised if they changed the pinout.

Thank You, pert.

Bugs – thats not good...
Well, I need only keyboard and the serial at the same time, no mouse. Any version will do if it works as good as with 32U4.

So what you're saying is that uploading to SAMD21 is a pain in the rear and expensive.
As I understand to get easy uploads I have to buy this owerpriced peace of...:
ATATMEL-ICE-PCBA-ND or ATATMEL-ICE-ND

Well, again, if it will work same as 32U4 I can live with that price cos I'm planing to make a lot of products with it.

Can I ask You a big favor? If You have SAMDy with bootloader could You upload a default "KeyboardSerial" to it, test it if it works, after that in Your PC go to "devices and printers>SAMDy chip>Hardware", take a screenshot of that window and share it here? You would help me a lot.

Result should look somewhat like this:

3Dgeo:
So what you're saying is that uploading to SAMD21 is a pain in the rear and expensive.

That's what I found when I looked at moving to 32bit micros, so I went with the STM32 instead. They have an onboard serial bootloader so you don't even need a dedicated programmer, and if you do want a programmer you can get them for about the same price as a USBASP.

BJHenry:
That's what I found when I looked at moving to 32bit micros, so I went with the STM32 instead. They have an onboard serial bootloader so you don't even need a dedicated programmer, and if you do want a programmer you can get them for about the same price as a USBASP.

I actually considered and was already designed a PCB for STM32, but I dropped it due to no/poor HID/serial support.

3Dgeo:
Bugs – thats not good...

Not good, but as anyone who writes code knows, inevitable. Luckily one of the Arduino developers has already done an investigation on my report and found the problem. Pretty fast response time!

3Dgeo:
Well, I need only keyboard and the serial at the same time, no mouse. Any version will do if it works as good as with 32U4.

Keyboard emulation is broken in Arduino SAMD Boards 1.8.1 but if you don't mind using Arduino SAMD Boards 1.6.21 until the next release of Arduino SAMD Boards comes out then you'll be fine.

3Dgeo:
So what you're saying is that uploading to SAMD21 is a pain in the rear and expensive.

Well, burning the bootloader has been a major pain in my rear so far but once you get a bootloader on there, uploading is easy and free.

I paid $4.29 for my Chinese J-Link. If that works (Adafruit claims it does, but they also claimed the previous two would) then I don't think that's too expensive. I did waste another $1.96 on the ST-Link V2, but I can save you from that expense by telling you it didn't work for me. I haven't investigated what the next option after the J-Link will cost me. Hopefully I won't need to go past the J-Link.

I'd love to figure out how to get the Arduino board programmer working. Although it's well worth having a dedicated programmer if you're going to be doing this regularly, being able to use a spare Arduino board in a pinch is great for people just trying to revive a "bricked" Arduino board.

3Dgeo:
If You have SAMDy with bootloader

I'll admit to having two SAMD boards that are currently "bricked" because I did something dumb and erased their bootloaders, but luckily I have a handful more SAMD boards that are still good.

3Dgeo:
test it if it works

It works fine if compiled with Arduino SAMD Boards 1.6.21. It doesn't work on Windows if compiled with Arduino SAMD Boards 1.8.1.

3Dgeo:
after that in Your PC go to "devices and printers>SAMDy chip>Hardware", take a screenshot of that window and share it here?

Here it is:

What is the cheapest/fastest way to burn bootloader on it?

One really easy way is with ISP, for this you need an ISP programmer

It's an ARM Cortex M chip, which means that you'll need an SWD interface/programmer. There are "many" choices, with varying degree of support for varying IDEs. "Best" is probably the Atmel-ICE at $50 to $130. Most 3rd party programmers tend to interface through "OpenOCD", which I find "substantially confusing." :frowning: The $15 Microchip "SNAP" programmer looks like it will be a good choice "eventually."

I didn't find any info in datasheet that pins can handle 5V logic so it's only a 3v3 logic chip?

Yea, 3V only. If you're building your own board, you might consider SAMC chips, which are 5V (no USB through!) They should be "mostly compatible" with Arduino.

Do Atmel and Microchip versions have any differences that I should know?

The pinout could be different. But you have to look into the data sheets.

They certainly SHOULD be the same. Microchip bought Atmel; it's not like they just cloned the chip...
I have not heard any reports of differences (and I read forums where there would be loud complaining.)

I found this minimal configuration schematic, is it right?

  • For the reset you will need a pull-up resistor. It will not work like this. Put 10k between reset and 3V3.

It looks pretty close. RESET on the ARM has a built-in pullup, so that shouldn't be needed unless you have other circuitry that might need the pullup to be "stronger."

  • What is connected to the 1uF cap?

Vddcore.

  • You should add a ferrite (470Ohms@100MHz) for VDDANA

the datasheet actually recommends a 10uH inductor. And a few lines later calls it a ferrite bead. YMMV; probably only needed if you care a lot about the ADC performance.

You're missing the "large" resevoir capacitor (~10uF) that should be on the board "somewhat nearby."

Section 42 of the datasheet is a "Schematic Checklist." Check it out.

There are some 3rd-party small-form-factor SAMD21 board in the $10 price range ("ready to use" with Arduino.) Are you sure you want to build your own? (if so, their OSHW schematics might be a good starting point...)

Oh yeah. You also shouldn't actually need the 32kHz crystal.

pert:
Not good, but as anyone who writes code knows, inevitable. Luckily one of the Arduino developers has already done an investigation on my report and found the problem. Pretty fast response time!
Keyboard emulation is broken in Arduino SAMD Boards 1.8.1 but if you don't mind using Arduino SAMD Boards 1.6.21 until the next release of Arduino SAMD Boards comes out then you'll be fine.

By writing "Arduino SAMD Boards 1.8.1", You mean SAMD core for Arduino? If so I have no issues with using older one until they fix new one. Either way I will do DAMD testing for a few month, I'm sure they will figure it out in that time.

pert:
Well, burning the bootloader has been a major pain in my rear so far but once you get a bootloader on there, uploading is easy and free.

My bad, I had burning bootloader in mind, not uploading code. I will make custom board so burning bootloader is important thing.

pert:
I paid $4.29 for my Chinese J-Link. If that works (Adafruit claims it does, but they also claimed the previous two would) then I don't think that's too expensive. I did waste another $1.96 on the ST-Link V2, but I can save you from that expense by telling you it didn't work for me. I haven't investigated what the next option after the J-Link will cost me. Hopefully I won't need to go past the J-Link.

I need a stable, well working way to upload bootloader, so I guess I have to pull a trigger on ICE.
Is this one OK for that:
ATATMEL-ICE-PCBA-ND

Are they really charge 40USD for a plastic case and another 40USD for few cables/adapters?

pert:
I'd love to figure out how to get the Arduino board programmer working. Although it's well worth having a dedicated programmer if you're going to be doing this regularly, being able to use a spare Arduino board in a pinch is great for people just trying to revive a "bricked" Arduino board.
I'll admit to having two SAMD boards that are currently "bricked" because I did something dumb and erased their bootloaders, but luckily I have a handful more SAMD boards that are still good.
It works fine if compiled with Arduino SAMD Boards 1.6.21. It doesn't work on Windows if compiled with Arduino SAMD Boards 1.8.1.

Yes, usually I would play with other bootloader burning options as well, but implementing SAMD in my project and debugging it is a big task in it self. Plus waiting a few weeks for other options to be shipped from Ali is not acceptable.

pert:
Here it is:

You are the Man, thank You so much!

3Dgeo:
By writing "Arduino SAMD Boards 1.8.1", You mean SAMD core for Arduino?

Yes.

3Dgeo:
Are they really charge 40USD for a plastic case and another 40USD for few cables/adapters?

Yeah, I've been tempted to just get the PCB and make the cable myself.

There's no doubt that an Atmel programmer is well worth the price for a professional, but it's a bit of a shame they decided to put such a markup on the things. No matter what they charge for a programmer, their profits will always be in selling chips, so why not set the price of the tools necessary to use those chips at an impulse buy level?

3Dgeo:
Plus waiting a few weeks for other options to be shipped from Ali is not acceptable.

The price of saving money by buying from China can be very high sometimes. I've been trying to get a SAMD programmer solution since the middle of April and there is no end in sight because I have gone the cheapskate route. The first shipment for my ST-Link order showed up and turned out to be some janky USB to TTL serial adapter instead of the ST-Link advertised on the listing. It was in the exact same enclosure with the same form factor so I wasted some time trying to figure out how to wire the thing to the SWD pins before realizing what I had. The seller sent me out the correct item without complaint, but then I had yet another China shipping delay to go through. Then I received the ST-Link I ordered, found out it didn't work, and ordered the J-Link, which I've been waiting for since 2019-05-24. The expected delivery date is not until 2019-07-24, so I can't complain until then, but I usually find that if the China stuff doesn't show up after a month, it never does. Meanwhile, I have $60 worth of Arduino boards I can't use.

I like the bargains of Chinese electronics, but between shipping delays and having packages disappear, it can really put a damper on a project. Sometimes by the time I finally get all the components I need 6 months later, I've lost interest in the project I bought them for. There's a lot to be said for buying things domestically and having them on your doorstep in two days.

3Dgeo:
You are the Man, thank You so much!

You're welcome. I'm glad if I was able to be of assistance.

westfw:
It's an ARM Cortex M chip, which means that you'll need an SWD interface/programmer. There are "many" choices, with varying degree of support for varying IDEs. "Best" is probably the Atmel-ICE at $50 to $130. Most 3rd party programmers tend to interface through "OpenOCD", which I find "substantially confusing." :frowning: The $15 Microchip "SNAP" programmer looks like it will be a good choice "eventually."

I will buy this one:
ATATMEL-ICE-PCBA-ND
Opinion on it?

westfw:
Yea, 3V only. If you're building your own board, you might consider SAMC chips, which are 5V (no USB through!) They should be "mostly compatible" with Arduino.

I't not big of a deal, only few pins is 5V in my design, I already implemented voltage dividers to chop them. USB is essential for my project.

westfw:
RESET on the ARM has a built-in pullup, so that shouldn't be needed unless you have other circuitry that might need the pullup to be "stronger."

Oh, thats a nice feature I didn't know. Well, I already have pull up in my design on reset left from ATMEGA32U4, thats why I didn't give it any attention.

westfw:
the datasheet actually recommends a 10uH inductor. And a few lines later calls it a ferrite bead. YMMV; probably only needed if you care a lot about the ADC performance.

I might add it to PCB design, but I'll probably will not populate it cos I don't use any analog signals.

westfw:
You're missing the "large" resevoir capacitor (~10uF) that should be on the board "somewhat nearby."

Section 42 of the datasheet is a "Schematic Checklist." Check it out.

I already have a good power filtering on an existing design, but I definitely revise it.

westfw:
There are some 3rd-party small-form-factor SAMD21 board in the $10 price range ("ready to use" with Arduino.) Are you sure you want to build your own? (if so, their OSHW schematics might be a good starting point...)

I'm making commercial product, it's not break out board for SAMD.

westfw:
Oh yeah. You also shouldn't actually need the 32kHz crystal.

Really? Can You tell me more about crystals and SAMD chips? I know SAMD have internal oscillator, potential issues when using it? Do they have enough accuracy?

pert:
Yeah, I've been tempted to just get the PCB and make the cable myself.

I will do that, I have many similar cables laying around.

pert:
There's no doubt that an Atmel programmer is well worth the price for a professional, but it's a bit of a shame they decided to put such a markup on the things. No matter what they charge for a programmer, their profits will always be in selling chips, so why not set the price of the tools necessary to use those chips at an impulse buy level?

Yes, from a simple maker perspective I can see the pain of spending 50USD only for a bootloader. Most expensive MCU I own is under 6USD. :smiley: I would explore other options if it would be one off project.
But now I'm planing to make money with it so I can invest a little more.

pert:
The price of saving money by buying from China can be very high sometimes. I've been trying to get a SAMD programmer solution since the middle of April and there is no end in sight because I have gone the cheapskate route. The first shipment for my ST-Link order showed up and turned out to be some janky USB to TTL serial adapter instead of the ST-Link advertised on the listing. It was in the exact same enclosure with the same form factor so I wasted some time trying to figure out how to wire the thing to the SWD pins before realizing what I had. The seller sent me out the correct item without complaint, but then I had yet another China shipping delay to go through. Then I received the ST-Link I ordered, found out it didn't work, and ordered the J-Link, which I've been waiting for since 2019-05-24. The expected delivery date is not until 2019-07-24, so I can't complain until then, but I usually find that if the China stuff doesn't show up after a month, it never does. Meanwhile, I have $60 worth of Arduino boards I can't use.

Well, You have to ask Yourself – is the time You are spending is worth it. People tend to devalue their time, for me my time becomes more valuable day by day. Things I used to spend days on is just don't make any sense now :slight_smile:
I can't complain about products from China tho, I'm getting stuff from Ali and they are descent quality. There are missing parcels time to time, but it's like one in a hundred.

pert:
I like the bargains of Chinese electronics, but between shipping delays and having packages disappear, it can really put a damper on a project. Sometimes by the time I finally get all the components I need 6 months later, I've lost interest in the project I bought them for. There's a lot to be said for buying things domestically and having them on your doorstep in two days.

Well known feeling :slight_smile: But usually I'm working on a few projects at the time (not only with electronics) so it's somewhat not that big of a deal. Also longest I have to wait from Ali is 2 month, usually up to 1 month.
I never buy elsewhere if it's available in china cheaper, I live in a small country where there isn't a lot of option to buy locally.

Are they really charge 40USD for a plastic case and another 40USD for few cables/adapters?

Apparently they do :frowning:
Be really careful about the micro-usb cable connector. They’re apparently fully SMT, and have a reputation for ripping off the board (taking the PCB traces with them) if you tug on the cable wrong. Even on versions WITH the case. OTOH Microchip has a reputation for replacing hardware that breaks (Atmel didn’t.)

westfw:
Be really careful about the micro-usb cable connector. They're apparently fully SMT, and have a reputation for ripping off the board (taking the PCB traces with them) if you tug on the cable wrong. Even on versions WITH the case. OTOH Microchip has a reputation for replacing hardware that breaks (Atmel didn't.)

Thanks for heads up, I will hotglue it as soon as I'll get it.