Author Topic: Second, very basic MCU board using the ATSAMD21G18A  (Read 923 times)

0 Members and 1 Guest are viewing this topic.

Online LoveLaikaTopic starter

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: us
Second, very basic MCU board using the ATSAMD21G18A
« on: September 20, 2021, 09:41:29 pm »
In my last project, I mentioned how I was working on a 'project' of sorts to give me some experience in building MCU boards (at least laying them out on a schematic for now). I figured it would be good to know, if only as a hobby. Sure, I could buy an Arduino, but others here seem to have a lot of experience building their own, so I figured I'd give it a shot. My first board may have been a bit too much with the ATtiny4, so for this board, I decided to take a page from the Arduino Nano and focus it around the ATSAMD21G18A. I was wondering what you all might think of it and if there were some feedback that you would recommend.


So, using the Nano Every as a template, it used an ATSAMD11D14A processor to be programmed via USB, and it communicates with the ATMEGA4809 for GPIO, peripherals, etc. I never really got why this was needed if the ATSAMD could do all that. So, I designed my schematic to only use the ATSAMD21G18A (mainly because it was available in KiCAD already). So, following from the Nano Every and the MCU's datasheet, I just simply followed the layout, allowing my design to be powered from either a barrel connector or USB. The LM2673 converts the barrel voltage down to +5V. I saw that the Nano used the MPM3610, but I felt the current output was too small. Thus, I decided to beef it up. An isolated regulator converts the +5V to +3.3V for the MCU, and appropriate routing is done to connect the USB data pins for programming. As for peripherals, I don't really have an end design/goal for it, so all I did was just put some headers and MOSFETs in order to allow for I2C communication. It's the first draft, and I can certainly pick some better parts, but I was wondering what you all thought of it?
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6352
  • Country: ca
  • Non-expert
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #1 on: September 20, 2021, 11:41:09 pm »
Looks good.
I would recommend always drawing Gnd symbol pointing down.
Add at least some extra headers for spare IO, for future use.
Add a programming/debug header.
I wouldn't bother with the shield RC and just tie it straight to ground, but up to you (C16/R2). You can always install 0R into R2 if needed.
USB supply can backfeed the U1 regulator if it is not powered on.
What is MEE1SD503xxx (PS1)?

You can also look at the Metro M0 for a 21g18 product:
https://www.adafruit.com/product/3505
https://cdn-learn.adafruit.com/assets/assets/000/041/522/original/microcontrollers_schem.png
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Online LoveLaikaTopic starter

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: us
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #2 on: September 21, 2021, 02:10:27 pm »
Thanks for replying. Yeah, I probably could have done the top caps a bit neater and oriented downwards, but it felt like it would have caused more room. I would have had to move the caps up or rotate them to the side. I'm never really good at making the top pins look neat. Same with the bottom.

The MEE1S0503SC is a 5V to 3.3V isolated DC-DC converter. Certainly, I could have picked a different part, but this was already pre-loaded in KiCAD. For the USB supply backfeeding into U1, I isolated it with D2, at least that's what I've learned from asking questions. That's what they did with the Nano Every, so I thought it would work here.

Thanks for letting me know about the Metro boards. Interesting to note that Adafruit has their own boards too. I'll be sure to have a look at them, though reading the description made me think of something. For their board, they used Pins 31 and 32 for I2C (PA22/23), whereas I used Pins 13 and 14 (for PA08/09). Though the processor datasheet showed the pins that would work for I2C, what determines what pins are designated for I2C? Perhaps I should have thought of this, but do you have to flash an image onto the processor via a bootloader in order to have this board work with the Arduino IDE (or whatever IDE you decide to program this with)? Would that be how you determine what pins are good for what protocol and the like? Knowing that might help with adding headers, so you can determine what pin does what.

With a debugging/programming header, isn't that done through USB, or is it done through another protocol like JTAG? Also, do you think the extra MOSFETs for I2C is too much? Adafruit's board just has it going to headers, so what would determine the I2C voltage you are working at: 5V or 3.3V (or is it always 3.3V)? I added the MOSFETs to allow for level translation if you're working with 5V instead of 3.3V, but is that too much?
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3342
  • Country: nl
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #3 on: September 21, 2021, 07:01:47 pm »
Most of those isolated SMPS modules are unregulated, and you won't get 3V3 out of it if it's a 3V part. On top of that you connect the GND of primary and secondary side and you also bridge the isolation with the USB wires. So you may as well skip that part altogether and connect D2 to U1 and use a variant with 3V3 output.
 (And also use a diode for the barrel jack)

There is also not much to gain with an SMPS if you go from 5V to 3V3. At those voltages typical efficiency is 80% or so, and you're just as good by taking a linear regulator, which can also keep some of the SMPS noise out of your uC (and its ADC / DAC). Instead of a stepdown you can also consider a SEPIC converter to make 5V out of the raw input

Especially for development boards, putting in a PPTC fuse is useful. You can bridge the PPTC with an PNP transistor and a LED so you can see when you overload your power supply.

What sort of form factor do you want to make the PCB?
I have a preference for a DIP-like form if it fits such as the Blue / Black pills or ardunno nano. If it's too big to fit in a breadboard I prefer standard dual row IDC connectors. These can be used with flatcables, individual dupont wires or standard dual-row 2.54mm headers. In this case, also put in some mounting holes.


I don't like the "upside down" capacitors much at the top of your Atsam. Is VddCore from an internal voltage regulator?

I do not know if your Atsam has an ADC and  how good it is. Maybe it can benefit from some extra filterig after the SMPS.
No crystal at all on your microcontroller? Or is that part just not finished yet?

Wiring around TVS diodes is always critical. Never connect the USB wires straight to you uC with some side track buggering off to the TVS diodes. Always route from the connector to the TVS diodes, and then continue to the microcontroller.
I find your GND connection of your TVS diodes... strange, and would have expected it to be connected directly to GND (Not a wire, the GND plane itself, and close to the connector).

 
The following users thanked this post: thm_w

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6352
  • Country: ca
  • Non-expert
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #4 on: September 21, 2021, 09:06:40 pm »
Thanks for letting me know about the Metro boards. Interesting to note that Adafruit has their own boards too. I'll be sure to have a look at them, though reading the description made me think of something. For their board, they used Pins 31 and 32 for I2C (PA22/23), whereas I used Pins 13 and 14 (for PA08/09). Though the processor datasheet showed the pins that would work for I2C, what determines what pins are designated for I2C? Perhaps I should have thought of this, but do you have to flash an image onto the processor via a bootloader in order to have this board work with the Arduino IDE (or whatever IDE you decide to program this with)? Would that be how you determine what pins are good for what protocol and the like? Knowing that might help with adding headers, so you can determine what pin does what.

There are multiple I2C ports on the samd21 (6 of them), generally shouldn't matter which port is used for that. However, to be on the safe side you can use the same pins as an existing design.
You can find the pin table in the datasheet, ports may be assigned to multiple pins.
Or this image shows a number of the pins, for example: https://learn.adafruit.com/assets/46244
Would be good to have I2C, SPI, some analog pins.

Yes you have to flash a bootloader before it will work with Arduino IDE.

Quote
With a debugging/programming header, isn't that done through USB, or is it done through another protocol like JTAG? Also, do you think the extra MOSFETs for I2C is too much? Adafruit's board just has it going to headers, so what would determine the I2C voltage you are working at: 5V or 3.3V (or is it always 3.3V)? I added the MOSFETs to allow for level translation if you're working with 5V instead of 3.3V, but is that too much?

You can debug with USB somewhat.
For programming and deeper level debugging you use SWD (SWDClk, SWDIO, etc. seen in the adafruit schematics).


I2C voltage would be determined from whatever module or part you are connecting to. Most modern devices would be 3.3V.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Online LoveLaikaTopic starter

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: us
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #5 on: September 22, 2021, 02:59:48 pm »
Most of those isolated SMPS modules are unregulated, and you won't get 3V3 out of it if it's a 3V part. On top of that you connect the GND of primary and secondary side and you also bridge the isolation with the USB wires. So you may as well skip that part altogether and connect D2 to U1 and use a variant with 3V3 output.
 (And also use a diode for the barrel jack)

There is also not much to gain with an SMPS if you go from 5V to 3V3. At those voltages typical efficiency is 80% or so, and you're just as good by taking a linear regulator, which can also keep some of the SMPS noise out of your uC (and its ADC / DAC). Instead of a stepdown you can also consider a SEPIC converter to make 5V out of the raw input

Especially for development boards, putting in a PPTC fuse is useful. You can bridge the PPTC with an PNP transistor and a LED so you can see when you overload your power supply.

What sort of form factor do you want to make the PCB?
I have a preference for a DIP-like form if it fits such as the Blue / Black pills or ardunno nano. If it's too big to fit in a breadboard I prefer standard dual row IDC connectors. These can be used with flatcables, individual dupont wires or standard dual-row 2.54mm headers. In this case, also put in some mounting holes.


I don't like the "upside down" capacitors much at the top of your Atsam. Is VddCore from an internal voltage regulator?

I do not know if your Atsam has an ADC and  how good it is. Maybe it can benefit from some extra filterig after the SMPS.
No crystal at all on your microcontroller? Or is that part just not finished yet?

Wiring around TVS diodes is always critical. Never connect the USB wires straight to you uC with some side track buggering off to the TVS diodes. Always route from the connector to the TVS diodes, and then continue to the microcontroller.
I find your GND connection of your TVS diodes... strange, and would have expected it to be connected directly to GND (Not a wire, the GND plane itself, and close to the connector).


I'm not looking to make the board right now. I'm just trying to get some experience in drawing schematics for microcontroller boards. I thought it would be fun. Nevertheless, thanks for your design inputs. Ideally, I envision it to be smaller than the nano since I'm only dealing with one processor, but the LM2673 is quite big. I'll have to think of another IC to use in its place.

The Nano Every uses the AP2112k-3.3 linear regulator to convert 5V to 3.3V. I suppose this would be better than the SMPS I had. The 5-volt is mainly for off-board circuitry; the Nano Every uses the MPM3610 to step down voltage to 5V, but the current output was too low for my tastes, so I thought to juice it up a little with the LM2673 instead. Given how this would better as a smaller unit, I'll have to think of another way.

I believe the ATSAMD21G18A  has an internal oscillator, so there's no need for an external one. Yes, VDDCORE does seem to be internal. If you look at page 1112 of the datasheet, it doesn't require a connection to a power source. Perhaps my GND connection of the TVS diodes is strange, but that's what it said on the datasheet (page 1122). It connected the anode end to the shield rather than directly to GND, and then it goes to GND via the RC filter.

 

Online LoveLaikaTopic starter

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: us
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #6 on: September 22, 2021, 03:18:48 pm »
Thanks for letting me know about the Metro boards. Interesting to note that Adafruit has their own boards too. I'll be sure to have a look at them, though reading the description made me think of something. For their board, they used Pins 31 and 32 for I2C (PA22/23), whereas I used Pins 13 and 14 (for PA08/09). Though the processor datasheet showed the pins that would work for I2C, what determines what pins are designated for I2C? Perhaps I should have thought of this, but do you have to flash an image onto the processor via a bootloader in order to have this board work with the Arduino IDE (or whatever IDE you decide to program this with)? Would that be how you determine what pins are good for what protocol and the like? Knowing that might help with adding headers, so you can determine what pin does what.

There are multiple I2C ports on the samd21 (6 of them), generally shouldn't matter which port is used for that. However, to be on the safe side you can use the same pins as an existing design.
You can find the pin table in the datasheet, ports may be assigned to multiple pins.
Or this image shows a number of the pins, for example: https://learn.adafruit.com/assets/46244
Would be good to have I2C, SPI, some analog pins.

Yes you have to flash a bootloader before it will work with Arduino IDE.

Quote
With a debugging/programming header, isn't that done through USB, or is it done through another protocol like JTAG? Also, do you think the extra MOSFETs for I2C is too much? Adafruit's board just has it going to headers, so what would determine the I2C voltage you are working at: 5V or 3.3V (or is it always 3.3V)? I added the MOSFETs to allow for level translation if you're working with 5V instead of 3.3V, but is that too much?

You can debug with USB somewhat.
For programming and deeper level debugging you use SWD (SWDClk, SWDIO, etc. seen in the adafruit schematics).


I2C voltage would be determined from whatever module or part you are connecting to. Most modern devices would be 3.3V.

Thanks for the reply. I guess if it's determined by the part/module, I won't need the MOSFETs for level translation on my board. I thought that since the MCU operated on 3.3V, it can't take 5V input, so I had to use something for I2C voltage level translation. Then again, with other boards like the Nano, they don't have it. They just wire it directly to headers. In that case, pull-down resistors can be set on one end to 5V or 3.3V depending on your sensor and that would be fine?

Thanks for your suggestions on debugging. I see that in the datasheet, they included a pinout for a JTAG connector. Doesn't seem so difficult to include it. Would that be the way to flash a bootloader onto the ATSAMD, or can that be done via USB? Honestly, I didn't really search for existing boards around this MCU. I just picked it out from Digikey and thought it would be an exercise to build a board around it.

So, I can flash a bootloader and then use it with the Arduino IDE, and I can do it based on an existing design. However, if you want to customize it (like for instance, changing the pin functionality, etc.), how would you do so? This feels like another interesting fascet of MCU boards to look at.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3342
  • Country: nl
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #7 on: September 22, 2021, 06:11:47 pm »
Lot's of microcontrollers can run from an internal oscillator, but typical accuracy is 1% or even worse over the temperature range. The optional crystal is typically used for applications that need a more accurate clock. Quite often the accuracy of the internal RC oscillator is so bad that it eats away most of the timing margin for even something simple like a UART (Over the full temperature range).
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6352
  • Country: ca
  • Non-expert
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #8 on: September 22, 2021, 09:07:58 pm »
It looks like at least you need an external 32.768kHz crystal for USB to work, as Doctorandus explained.

ATSAMD21G18A is not 5V tolerant so you can't feed 5V in.
What I mean is, if you have a module thats running off 3.3V, then I2C 3.3V signalling would be used. If the module requires 5V, then the I2C signals would be 5V and should not be hooked up directly, without your level translator.
But modules that require 5V to operate are relatively rare AFAIK.

Some micros will have a built in bootloader, from what I see SAMD21 does not "SAM-BA bootloader is not factory programmed on SAM D21 devices and has to be programmed using an external programmer"

JTAG port works, I prefer SWD port as there are less pins to deal with.

Some pin mapping discussion here: https://forum.arduino.cc/t/atsamd21-pin-mapping-battery-measurement-variant-cpp/625438/5
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Online LoveLaikaTopic starter

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: us
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #9 on: September 22, 2021, 10:00:36 pm »
Thanks for the reply. While this isn't something that I'm planning to lay out right now, I'm definitely learning a lot about what to include in an MCU board. I would have thought the internal clock would be fine, but I see now how it can be good to have an external one.

I'm not surprised that the SAMD21 doesn't have a pre-programmed bootloader. Thanks for the link to the pin-mapping post. I'll have to give that a read through, but it seems like it's better to just design with a certain boot image in mind, and then you can just remap the pins in code. Or, just design around the boot meant for Arduino IDE and save myself the trouble.



Maybe I'm harping on this too much, but say the MCU runs at 3.3V, so like you said, I2C signals would be 3.3V. Say you have a breakout sensor that can take 3.3V or 5V, but in this case you build centered around 5V. Arduino Nano Every can supply 5V or 3.3V. Since you build around 5V, you wire 5V to the sensor along with SCL, SDA, and GND. Then, you add pull-up resistors connecting SCL/SDA to 5V. If the Nano Every runs at 3.3V and SCL/SDA traces go directly from the MCU to its headers, how is this okay?
 

Offline jeremy0

  • Contributor
  • Posts: 23
  • Country: es
Re: Second, very basic MCU board using the ATSAMD21G18A
« Reply #10 on: October 06, 2021, 01:40:54 pm »
I decided to take a page from the Arduino Nano and focus it around the ATSAMD21G18A.

Just make sure you read the SAMD21 Silicon Errata before trying anything clever with the peripherals (in particular anything involving the event system, or DMA linked descriptors - and I think the TCCs have some quirks as well).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf